:root {
  --bg: #e6ebed;
  --panel: #ffffff;
  --ink: #111214;
  --sub: #5a6068;
  --hair: #c9d0d4;
  --amber: #b8661c;
  --amber-soft: #f4e3d0;
  --amber-text: #7f4510;
  --over: #c8102e;
  --over-soft: #fbe3e6;
  --ok: #17704a;
  --ok-soft: #dcefe5;
  --rni: #2856c4;
  --focus: #2856c4;
  --font: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }

/* 머리 */
.top { display: flex; align-items: flex-end; gap: 12px; padding: 20px 0 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; fill: none; }
.top h1 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -0.02em; }
.top p { margin: 0; color: var(--sub); font-size: 14px; flex: 1 1 220px; }
.langsw { margin-left: auto; font-size: 13px; color: var(--sub); text-decoration: none; border-bottom: 1px solid var(--hair); }

/* 사람 */
#who { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0 16px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--hair); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 7px; display: inline-flex; gap: 6px; align-items: center; min-height: 44px; }
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.seg.small button { padding: 7px 10px; font-size: 14px; }
.age select { min-height: 44px; border: 1px solid var(--hair); border-radius: 10px; background: var(--panel); padding: 0 10px; }

/* 두 칸 */
.cols { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.cols > * { min-width: 0; }
@media (min-width: 900px) {
  .pcol { grid-column: 1; grid-row: 1; }
  #facts { grid-column: 2; grid-row: 1; }
}
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
  #facts { position: sticky; top: 12px; }
}
.col-h { font-size: 13px; font-weight: 700; color: var(--sub); margin: 0 0 8px; letter-spacing: 0.02em; }

/* 제품 카드: 약병 라벨 띠 */
#plist { display: grid; gap: 10px; }
.card { background: var(--panel); border-radius: 12px; padding: 12px 14px 12px 18px; position: relative; border: 1px solid var(--hair); }
.card::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 6px; border-radius: 0 4px 4px 0; background: var(--amber); }
.card.can-drop::before { background: var(--ok); }
.row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row1 h3 { margin: 0; font-size: 16px; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card:not(.editing) .row1 { flex-wrap: nowrap; }
.pd { white-space: nowrap; }
.tag { font-size: 12px; font-weight: 700; color: var(--amber-text); background: var(--amber-soft); padding: 2px 6px; border-radius: 4px; }
.pd { font-size: 12px; color: var(--sub); }
.sp { flex: 1; }
.ings { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 13px; color: var(--sub); }
.ing b { color: var(--ink); font-weight: 700; }
.ing.bad, .ing.bad b { color: var(--over); text-decoration: underline wavy; }
.verdict { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.band { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; padding: 4px 8px; border-radius: 6px; }
.band svg { width: 16px; height: 16px; }
.band.ok { background: var(--ok-soft); color: var(--ok); }
.band.key { background: var(--over-soft); color: var(--over); }
.band.muted { background: #eef0f2; color: var(--sub); font-weight: 500; }
.gaps { width: 100%; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; }
.gl { color: var(--sub); }
.gap { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.find { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.find svg { width: 14px; height: 14px; color: var(--sub); }
.find a { color: var(--rni); text-decoration: underline; text-underline-offset: 3px; min-height: 36px; padding: 0 6px; display: inline-flex; align-items: center; }
.adnote { width: 100%; margin: 2px 0 0; font-size: 11px; color: var(--sub); }

.icon { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 8px; }
.ghost { border: 1px solid var(--hair); background: transparent; border-radius: 8px; padding: 8px 12px; display: inline-flex; gap: 6px; align-items: center; min-height: 40px; }
.icon.ghost { padding: 0; border-color: transparent; color: var(--sub); }
.icon.ghost:hover { background: #eef0f2; color: var(--ink); }
.ghost.danger { color: var(--over); }
.solid { border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 14px; display: inline-flex; gap: 6px; align-items: center; min-height: 40px; font-weight: 700; }
.padd { display: flex; gap: 8px; flex-wrap: wrap; }
.add { border: 2px dashed #9aa5ab; background: transparent; border-radius: 12px; padding: 12px; flex: 1 1 200px; display: inline-flex; gap: 6px; justify-content: center; align-items: center; font-weight: 700; min-height: 48px; }
.add:hover { border-color: var(--ink); }

/* 편집 */
.card.editing { border: 2px solid var(--ink); }
.pname { flex: 1 1 180px; font-size: 16px; font-weight: 700; border: 0; border-bottom: 2px solid var(--hair); padding: 6px 2px; background: transparent; min-height: 40px; }
.perday { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--sub); }
.perday input { width: 52px; }
.ing-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid #eef0f2; }
.ing-edit select, .ing-edit input, .perday input { min-height: 40px; border: 1px solid var(--hair); border-radius: 8px; padding: 0 8px; background: #fff; }
.ing-edit select[data-f="nutrient"] { flex: 1 1 170px; max-width: 100%; }
.ing-edit input[data-f="amount"] { width: 92px; }
.ing-edit .u { width: 104px; }
.ing-edit input[data-f="label"] { flex: 1 1 140px; }
.mini { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--sub); }
.mini input { width: 80px; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* 합친 라벨: 영양정보 표의 굵은 괘선 */
#facts { background: var(--panel); border: 2px solid var(--ink); padding: 12px 14px 14px; border-radius: 4px; }
.facts-head { border-bottom: 10px solid var(--ink); padding-bottom: 6px; }
.facts-head h2 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; }
.facts-head .who { margin: 2px 0 0; font-weight: 700; }
.facts-head .note { margin: 0; font-size: 12px; color: var(--sub); }
.summary { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--ink); font-weight: 700; font-size: 14px; }
.s-over { color: var(--over); }
.s-ok { color: var(--ok); }
.s-drop { color: var(--ok); }
.fcols { display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1.2fr) 22px; gap: 8px; font-size: 11px; font-weight: 700; padding: 6px 0 4px; border-bottom: 4px solid var(--ink); }
.fcols span:nth-child(2) { text-align: right; }
.frows { list-style: none; margin: 0; padding: 0; }
.frow { border-bottom: 1px solid var(--ink); }
.fbtn { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1.2fr) 22px; gap: 8px; align-items: center; border: 0; background: transparent; text-align: left; padding: 7px 0; min-height: 44px; }
.fbtn:hover { background: #f5f6f7; }
.fname { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
.ov { font-style: normal; font-size: 11px; font-weight: 700; color: var(--amber-text); border: 1px solid currentColor; padding: 0 4px; border-radius: 3px; }
.ftotal { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ftotal small { font-size: 11px; font-weight: 500; margin-left: 2px; color: var(--sub); }
.fbar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar { position: relative; flex: 1; height: 12px; background: #eef0f2; border-radius: 2px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 2px; }
.bar.over .fill { background: var(--over); }
.bar .ulmark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--over); }
.bar .rnimark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--rni); }
.pct { width: 46px; text-align: right; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pct.none { width: auto; flex: 1; text-align: left; font-weight: 500; font-size: 12px; color: var(--sub); }
.frow.over .fname, .frow.over .pct { color: var(--over); }
.finfo { color: var(--sub); }
.finfo svg { width: 16px; height: 16px; }
.frow.open .fbtn { background: #f5f6f7; }
.basis { margin: 0; padding: 4px 0 12px; font-size: 13px; display: grid; gap: 6px; }
.basis div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; }
.basis dt { color: var(--sub); }
.basis dd { margin: 0; overflow-wrap: anywhere; }
.basis a { color: var(--rni); }
.legend { margin: 8px 0 0; font-size: 11px; color: var(--sub); display: flex; align-items: center; gap: 4px; }
.legend i { display: inline-block; width: 2px; height: 12px; margin-left: 6px; }
.lg-ul { background: var(--over); }
.lg-rni { background: var(--rni); }
.empty { color: var(--sub); padding: 18px 0; }
.err { color: var(--over); font-size: 13px; font-weight: 700; }

/* 바닥 */
footer { margin-top: 28px; font-size: 12px; color: var(--sub); display: grid; gap: 6px; }
footer a { color: var(--sub); }
.ivel-line { display: flex; gap: 12px; flex-wrap: wrap; }

@media (max-width: 480px) {
  .top h1 { font-size: 22px; }
  .facts-head h2 { font-size: 26px; }
  .fcols, .fbtn { grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr) 18px; gap: 6px; }
  .pct { width: 40px; }
}

.plain { line-height: 1.7; padding-left: 18px; }
.sub { color: var(--sub); font-size: 12px; }

/* 눌러 보는 설명 */
.tip { width: 22px; height: 22px; min-width: 22px; border-radius: 50%; border: 1px solid currentColor; background: transparent; font-size: 12px; font-weight: 700; line-height: 1; display: inline-grid; place-items: center; margin-left: 4px; padding: 0; color: var(--sub); position: relative; }
.tip::after { content: ""; position: absolute; inset: -11px; }
#tipbox { position: absolute; z-index: 20; background: var(--ink); color: #fff; font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.exnote { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 0; font-size: 13px; }
.ghost.sm { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.s-drop { display: inline-flex; align-items: center; }
.fcols span:last-child { display: inline-flex; align-items: center; }
.legend { flex-wrap: wrap; row-gap: 6px; }
.legend .ov { margin-left: 8px; }
.ftotal small { display: block; margin-left: 0; }
#plist { grid-template-columns: minmax(0, 1fr); }
.card { min-width: 0; }
.band { max-width: 100%; flex-wrap: wrap; }
.gaps .gap { flex-wrap: wrap; }
.find a { padding: 0 4px; }

/* 재검수 반영 */
.lg { display: inline-flex; align-items: center; white-space: nowrap; margin-right: 6px; }
.card:not(.editing) .row1 h3 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.find a { min-height: 44px; padding: 0 8px; }
.ghost.sm { min-height: 44px; }
.langsw { display: inline-flex; align-items: center; min-height: 44px; border-bottom: 0; text-decoration: underline; text-underline-offset: 3px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; }
