:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #26221d;
  --ink-2: #6b635a;
  --line: #e2dcd2;
  --accent: #2f6f62;
  --accent-bg: #e3f0ec;
  --good: #2e7d4f;
  --good-bg: #e2f2e7;
  --warn: #96630a;
  --warn-bg: #fbefd3;
  --bad: #a63a2c;
  --bad-bg: #f9e3df;
  --water: #1f6fb5;
  --tier2: #1f5fa8;
  --tier2-bg: #e1ecf9;
  --tier3: #7a3f9d;
  --tier3-bg: #f0e4f7;
  /* 내 재료의 "특징" 버튼: 다른 표시(초록·청록·파랑·보라)와 겹치지 않는 연한 살구색 */
  --feat: #a4541a;
  --feat-bg: #fbe9da;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --card: #25221e;
    --ink: #ece7df;
    --ink-2: #a39b90;
    --line: #3a3630;
    --accent: #7cc4b3;
    --accent-bg: #223b36;
    --good: #7fd09c;
    --good-bg: #1f3a29;
    --warn: #e6bb62;
    --warn-bg: #40331a;
    --bad: #f0958a;
    --bad-bg: #44241f;
    --water: #7db8ee;
    --tier2: #8cbcf2;
    --tier2-bg: #1e3350;
    --tier3: #cfa3ea;
    --tier3-bg: #3a2749;
    --feat: #f0b07e;
    --feat-bg: #47301f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
.top, main, .foot { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 20px; }
h1 { font-size: 20px; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 0; font-weight: 600; }
.tabs { display: flex; gap: 4px; background: var(--line); padding: 3px; border-radius: var(--radius); }
.tabs button { border: 0; background: none; color: var(--ink-2); padding: 6px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); font-weight: 600; }
.tabs button { white-space: nowrap; }
/* 휴대폰 너비에서는 탭 네 개가 한 줄에 들어가게 글자와 여백을 줄인다. */
@media (max-width: 520px) {
  .tabs { width: 100%; }
  .tabs button { flex: 1 1 auto; padding: 6px 4px; font-size: 13px; }
}
main { padding-top: 20px; padding-bottom: 24px; }
.foot { color: var(--ink-2); font-size: 12px; padding-bottom: 32px; }
a { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.result { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 14px; }
.muted { color: var(--ink-2); font-size: 13px; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }

input[type="text"], input[type="number"], textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input[type="text"] { flex: 1; }
textarea { width: 100%; min-height: 120px; resize: vertical; }
button.btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--card); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 5px 0; text-align: left; font-weight: 400; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th { color: var(--ink-2); font-size: 13px; }
tr.sum td { border-top: 1px solid var(--line); color: var(--ink-2); }
tr.add td { color: var(--ink-2); }

.badge { font-size: 12px; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
/* 계량표: 인쇄할 때만 보이고, 종이에 맞게 흰 바탕에 검은 글씨로 고정한다. */
#print-sheet { display: none; }
body.printing { background: #fff; }
body.printing > *:not(#print-sheet) { display: none; }
/* 폭을 A4 인쇄 영역(190mm)에 맞춰 두어야, 화면에서 잰 높이가 종이에서의 높이와 같다. */
body.printing #print-sheet { display: block; color: #000; background: #fff; width: 190mm; box-sizing: border-box; margin: 0 auto; padding: 0; font-size: 14px; }
body.printing { margin: 0; }
html:has(body.printing), body.printing { height: auto; min-height: 0; }
#print-sheet table, #print-sheet .lines, #print-sheet .written { break-inside: avoid; }
#print-sheet h1 { font-size: 22px; margin: 0 0 4px; }
#print-sheet header p { margin: 0; }
#print-sheet .small { font-size: 12px; color: #444; margin: 6px 0 0; }
#print-sheet .batch { margin: 16px 0 8px; font-size: 16px; }
#print-sheet table { border-collapse: collapse; width: 100%; font-size: 15px; }
#print-sheet th, #print-sheet td { border: 1px solid #000; padding: 6px 10px; color: #000; font-size: 15px; }
#print-sheet th { background: #eee; font-weight: 600; }
#print-sheet .box { width: 52px; text-align: center; font-size: 12px; white-space: nowrap; padding: 8px 4px; }
#print-sheet .blank { width: 110px; }
#print-sheet .big { font-size: 18px; font-weight: 700; }
#print-sheet tr.total td { background: #f4f4f4; font-weight: 600; }
#print-sheet .lines { margin-top: 20px; }
#print-sheet .lines p { margin: 0 0 10px; }
#print-sheet .memo { border: 1px solid #000; height: 90px; }
#print-sheet footer { margin-top: 14px; font-size: 11px; color: #555; }
#print-sheet h2 { font-size: 14px; margin: 12px 0 4px; color: #000; }
#print-sheet table.record th { width: 110px; text-align: left; }
#print-sheet table.record td { height: 26px; }
#print-sheet .written { border: 1px solid #000; padding: 8px 12px; min-height: 60px; line-height: 1.6; }
/* 인쇄용 노트는 담는 내용이 많아 계량표보다 줄 간격을 좁게 쓴다. */
#print-sheet .note-doc th, #print-sheet .note-doc td { padding: 4px 8px; font-size: 13px; }
@page { size: A4; margin: 10mm; }
#print-sheet .print-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#print-sheet .print-photos img { width: 100%; height: 42mm; object-fit: cover; border: 1px solid #000; display: block; break-inside: avoid; }

.guide { line-height: 1.75; }
.guide p { margin: 0 0 6px; }
.guide ul, .guide ol { margin: 0 0 6px; padding-left: 22px; }
.guide li { margin: 4px 0; }
.guide pre { margin: 0 0 8px; padding: 10px 14px; background: var(--bg); border-radius: 8px; font: inherit; font-size: 14px; white-space: pre-wrap; }
/* 목차: 내 재료 탭의 묶음 제목과 같은 먹색 띠. 누르면 펼쳐진다. */
.guide-sec { margin-top: 10px; }
.guide-sec > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  padding: 10px 14px; background: var(--ink); color: var(--card); border-radius: 8px; font-size: 18px; font-weight: 700; }
.guide-sec > summary::-webkit-details-marker { display: none; }
.guide-sec > summary::after { content: '펼치기'; font-size: 13px; font-weight: 500; opacity: 0.75; }
.guide-sec[open] > summary::after { content: '접기'; }
.guide-body { padding: 14px 6px 6px; }
/* 작은 제목 한 덩어리: 왼쪽에 줄을 그어 서로 구분한다. */
.guide-block { padding: 2px 0 2px 14px; border-left: 3px solid var(--line); margin: 0 0 18px; }
.guide-block:last-child { margin-bottom: 6px; }
.guide-block h3 { margin: 0 0 4px; font-size: 16px; }
.guide-steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.guide-steps > li { position: relative; padding: 0 0 4px 44px; margin: 0 0 14px; }
.guide-steps > li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px;
  border-radius: 50%; background: var(--accent-bg); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.guide-steps > li > b { font-size: 16px; }
.guide-steps > li > p { margin: 2px 0 0; }
.guide-table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.guide-table th { width: 30%; text-align: left; vertical-align: top; font-weight: 600; white-space: nowrap; }
.guide-table th, .guide-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--ink); }
.guide-table tr:last-child th, .guide-table tr:last-child td { border-bottom: 0; }
.guide-changes li { margin: 0 0 10px; }
.guide-changes .muted { font-size: 14px; }
.guide-points { list-style: none; padding-left: 0 !important; }
.guide-points > li { padding: 10px 14px; margin: 0 0 8px; background: var(--bg); border-radius: 8px; }
@media (max-width: 520px) { .guide-table th { white-space: normal; width: 34%; } }

/* 바뀐 이유: 연한 띠를 누르면 펼쳐진다 */
details.why > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; background: var(--accent-bg); color: var(--accent); border-radius: 8px; font-size: 17px; }
details.why > summary::-webkit-details-marker { display: none; }
details.why > summary .sub { font-size: 13px; opacity: 0.8; margin-left: 4px; }
details.why > summary::after { content: '펼치기 ▾'; font-size: 13px; white-space: nowrap; }
details.why[open] > summary::after { content: '접기 ▴'; }

.stuck-body { margin-top: 10px; line-height: 1.7; }
.stuck-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.stuck-item p { margin: 4px 0; }
.stuck-item ol { margin: 4px 0; padding-left: 22px; }
.stuck-item li { margin: 4px 0; }

/* 내 재료의 "특징": 누르면 펼쳐지는 작은 글씨 */
details.feat { margin-top: 2px; }
details.feat > summary { display: inline-block; cursor: pointer; list-style: none; font-size: 12px; color: var(--feat);
  padding: 1px 8px; border: 1px solid var(--feat-bg); background: var(--feat-bg); border-radius: 99px; }
details.feat > summary::-webkit-details-marker { display: none; }
details.feat > summary::after { content: ' ▾'; }
details.feat[open] > summary::after { content: ' ▴'; }
details.feat > p { margin: 4px 0 2px; font-size: 13px; line-height: 1.6; color: var(--ink); }
.why-list { margin: 10px 0 0; padding-left: 0; list-style: none; }
.why-list li { padding: 8px 0; border-bottom: 1px solid var(--line); line-height: 1.6; }
.why-list li:last-child { border-bottom: 0; }

/* 치환 결과에서 원본에 없던, 새로 들어온 재료 */
tr.added td, .added-text { color: var(--bad); }
tr.added td:first-child { font-weight: 600; }

/* 설명서의 "만든 이유" */
.why-made { margin: 10px 0; padding: 12px 16px; background: var(--feat-bg); border-radius: 8px; line-height: 1.75; }
.why-made > b { color: var(--feat); font-size: 16px; }
.why-made p { margin: 6px 0 0; }

/* 실험 노트의 "내 노트는 나만 볼 수 있습니다" 안내 */
.privacy { margin: 0 0 14px; padding: 10px 14px; background: var(--accent-bg); border-radius: 8px; font-size: 14px; line-height: 1.6; }
.privacy > b { color: var(--accent); }
.privacy ul { margin: 6px 0 4px; padding-left: 20px; }
.privacy li { margin: 2px 0; }
.privacy p { margin: 4px 0 0; font-size: 13px; }

.mat-note { margin-top: 4px; padding: 4px 10px; border-left: 3px solid var(--tier2); background: var(--tier2-bg); color: var(--ink); font-size: 13px; border-radius: 4px; }

.note-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.note-tools input { flex: 1 1 220px; }
.note-tools select { flex: 0 0 auto; }

.photos { margin-top: 14px; }
.photos h3 { margin: 0 0 6px; }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-row figure { position: relative; margin: 0; }
.photo-row .thumb { display: block; width: 112px; height: 112px; padding: 0; border: 1px solid var(--line, #ccc); border-radius: 8px; overflow: hidden; cursor: zoom-in; background: none; }
.photo-row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.photo-row .photo-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 16px; line-height: 24px; cursor: pointer; }
.photo-add { display: flex; align-items: center; justify-content: center; width: 112px; height: 112px; box-sizing: border-box; border: 1px dashed var(--ink-2, #888); border-radius: 8px; color: var(--ink-2, #666); font-size: 13px; cursor: pointer; }
.photo-add:hover { border-style: solid; }
#photo-viewer { border: 0; border-radius: 10px; padding: 12px; max-width: 94vw; max-height: 94vh; }
#photo-viewer::backdrop { background: rgba(0, 0, 0, 0.7); }
#photo-viewer img { display: block; max-width: 88vw; max-height: 80vh; margin: 0 auto 10px; }
#photo-viewer form { text-align: right; }

.export-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.export-groups p { margin: 2px 0 8px; }

details.note summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
details.note .note-title { font-weight: 600; margin-right: auto; }
details.note .grid2 { margin-bottom: 0; }
.fields { display: flex; flex-direction: column; gap: 8px; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--ink-2); }
.fields input, .fields textarea, .fields select { width: 100%; flex: none; }
input[type="date"] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
button.btn.danger { color: var(--bad); border-color: var(--bad); }
button.btn:disabled { opacity: 0.5; cursor: default; }
label.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 8px 14px; }
tr.water td { border-top: 1px solid var(--line); color: var(--water); }
tr.water .note { font-size: 13px; }
tr.water select { padding: 2px 6px; font-size: 13px; }
th select { padding: 2px 6px; font-size: 13px; }
#print-sheet .big { white-space: nowrap; }
.position { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.umf-chart { width: 100%; max-width: 420px; height: auto; display: block; }
.umf-chart .frame { fill: var(--bg); stroke: var(--line); }
.umf-chart .ratio { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.6; }
.umf-chart .zone { fill: var(--ink-2); font-size: 12px; }
.umf-chart .tick { fill: var(--ink-2); font-size: 10px; }
.umf-chart .axis { fill: var(--ink); font-size: 12px; }
.umf-chart .orig { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.umf-chart .res { fill: var(--accent); stroke: var(--card); stroke-width: 1.5; }
.legend { margin: 4px 0 0; display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.orig { border: 2px solid var(--ink); background: var(--card); }
.dot.res { background: var(--accent); margin-left: 10px; }
.traits { margin: 0; padding-left: 18px; font-size: 14px; }
.traits li { margin-bottom: 4px; }
label.keep { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
label.keep input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.scroll { overflow-x: auto; }
table.contrib { min-width: 520px; }
table.contrib td, table.contrib th { padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.contrib tr.sum td { border-top: 0; border-bottom: 0; color: var(--ink); }
table.contrib th.ox-flux { color: var(--water); }
table.contrib th.ox-mid { color: var(--warn); }
table.contrib th.ox-si { color: var(--accent); }
.suggest { border-top: 1px solid var(--line); padding: 10px 0 2px; margin-top: 8px; }
input.amt { width: 76px; padding: 4px 6px; text-align: right; }
.badge.tier { background: var(--line); color: var(--ink-2); }
/* 치환 등급: 주재료는 초록(good), 보조 재료는 파랑, 비주류는 보라. */
.badge.tier2 { background: var(--tier2-bg); color: var(--tier2); }
.badge.tier3 { background: var(--tier3-bg); color: var(--tier3); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 5px 14px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.badge.plain { background: var(--accent-bg); color: var(--accent); }
.diff.good { color: var(--good); }
.diff.warn { color: var(--warn); }
.diff.bad { color: var(--bad); }

.notice { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice ul { margin: 0; padding-left: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.stat.res { background: var(--accent-bg); }
.stat.res .muted, .stat.res b { color: var(--accent); }
.stat b { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2);
  border-radius: 99px; padding: 3px 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

details.send { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
details.send summary { cursor: pointer; color: var(--accent); font-size: 14px; }
details.send ol { padding-left: 20px; margin: 8px 0; }
details.send li { margin-bottom: 6px; }
a.btn.drag { display: inline-block; text-decoration: none; cursor: grab; padding: 3px 12px;
  border: 1px dashed var(--accent); border-radius: 8px; color: var(--accent); background: var(--accent-bg); font-weight: 600; }

.mat { display: grid; grid-template-columns: 24px 1fr; gap: 4px 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.mat:first-of-type { border-top: 0; }
.mat input { margin-top: 5px; width: 16px; height: 16px; accent-color: var(--accent); }
.mat .ox { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.mat .ox span b { font-weight: 400; color: var(--ink-2); margin-right: 3px; }
.mat.off { opacity: 0.6; }
.mat-actions { gap: 14px; margin-top: 2px; font-size: 13px; }
.mat-edit { border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px; margin: 10px 0; background: var(--bg); }
.mat-edit p { margin: 6px 0; }
.mat-edit label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--ink-2); }
.mat-edit input, .mat-edit select { background: var(--card); width: 100%; flex: none; }
.ox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px 8px; margin: 8px 0; }
.mat-edit h3 { margin-bottom: 8px; }
.mat-edit label > span { color: var(--ink); font-size: 13px; white-space: nowrap; height: 20px; line-height: 20px; }
.mat-edit label > span sub { line-height: 0; }
.mat-edit select { max-width: 160px; }
.mat-edit .row { align-items: flex-end; gap: 10px; }
.mat-edit .row label { flex: 1 1 160px; max-width: 260px; }
.mat-edit input[type="number"] { padding: 6px 8px; }
.group-title { margin: 26px 0 6px; padding: 8px 12px; background: var(--ink); color: var(--card); border-radius: 8px; font-size: 18px; font-weight: 700; }
.group-title .muted { font-size: 14px; font-weight: 500; margin-left: 4px; color: inherit; opacity: 0.75; }
.empty { text-align: center; color: var(--ink-2); padding: 28px 12px; }
