:root {
  font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  --bg: #101722;
  --panel: #1b2635;
  --panel-soft: #202e40;
  --input: #141e2b;
  --line: #354357;
  --text: #f5f8fc;
  --muted: #aab8c9;
  --accent: #79b4ff;
  --accent-deep: #285ca5;
  --selected: #233e61;
  --chip: #29394d;
  --green: #95dfb5;
  --warning: #ffd089;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

body[data-theme="light"] {
  --bg: #eef2f7;
  --panel: #fff;
  --panel-soft: #f4f7fb;
  --input: #fff;
  --line: #d6e0ec;
  --text: #172334;
  --muted: #566779;
  --accent: #1456ab;
  --accent-deep: #dceaff;
  --selected: #e8f2ff;
  --chip: #e8eef6;
  --green: #146b40;
  --warning: #9a5500;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.shell { max-width: 1680px; margin: 0 auto; padding: 0 clamp(16px, 2.5vw, 42px) 36px; }
.top-nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.top-nav a { color: var(--text); text-decoration: none; }
.brand { font-size: 18px; font-weight: 900; letter-spacing: -.03em; }
.brand span { color: var(--muted); font-size: 14px; font-weight: 650; margin-left: 12px; }
.back-link { font-size: 14px; font-weight: 750; }
.back-link:hover, .list-return:hover { color: var(--accent); }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; margin-bottom: 24px; }
.headline { max-width: 810px; }
.eyebrow, .section-kicker { color: var(--accent); letter-spacing: .08em; font-size: 12px; font-weight: 850; margin: 0 0 6px; }
h1 { font-size: clamp(30px, 3vw, 42px); letter-spacing: -.045em; margin: 0; line-height: 1.25; }
.intro { color: var(--text); font-size: 17px; font-weight: 600; margin: 10px 0 0; }
.source-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding-top: 6px; }
.button { border: 1px solid var(--line); border-radius: 10px; min-height: 42px; padding: 9px 14px; color: var(--text); background: var(--panel); font-size: 13px; font-weight: 750; }
.button:hover { border-color: var(--accent); }

.steps { display: flex; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 9px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 700; }
.steps strong { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-deep); color: #fff; font-size: 12px; }
body[data-theme="light"] .steps strong { color: #164783; }
.calculator-grid { display: grid; grid-template-columns: minmax(280px, 320px) minmax(400px, 1fr) minmax(340px, 420px); gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; min-width: 0; box-shadow: 0 8px 30px rgba(0, 0, 0, .05); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
h2 { font-size: 21px; margin: 0; letter-spacing: -.03em; line-height: 1.35; }
.count { color: var(--muted); font-size: 13px; font-weight: 650; margin-left: 4px; white-space: nowrap; }
.unit-pill { white-space: nowrap; border-radius: 999px; background: var(--accent-deep); color: #fff; padding: 5px 9px; font-size: 11px; font-weight: 800; }
body[data-theme="light"] .unit-pill { color: #164783; }
.unit-pill.subtle { background: var(--chip); color: var(--muted); }
.muted { color: var(--muted); }
.compact { font-size: 13px; line-height: 1.55; margin: 0 0 17px; }

.prices-panel { position: sticky; top: 16px; }
.price-group-title { font-size: 13px; font-weight: 850; color: var(--text); margin: 18px 0 8px; }
.price-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 10px; align-items: center; margin: 7px 0; }
.price-row label { min-width: 0; font-size: 13px; font-weight: 700; }
.price-row input { width: 100%; min-height: 42px; padding: 8px 10px; text-align: right; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--input); font-size: 15px; }
.price-row input:hover, .search-input:hover, select:hover { border-color: var(--accent); }
.price-row input::-webkit-inner-spin-button { opacity: .55; }
.extra-prices { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.extra-prices summary { font-weight: 800; cursor: pointer; }
.extra-prices summary span { color: var(--muted); font-size: 11px; font-weight: 600; margin-left: 5px; }
.extra-prices .compact { margin: 8px 0; }
.storage-message { min-height: 18px; color: var(--muted); font-size: 11px; margin: 13px 0 0; }

.search-label { display: block; color: var(--text); font-size: 13px; font-weight: 750; margin-bottom: 6px; }
.search-input, select { width: 100%; min-height: 43px; background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.filter-row { display: flex; gap: 6px; margin: 10px 0; }
.filter-button { flex: 1; min-width: 0; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--chip); color: var(--muted); padding: 7px 5px; font-size: 13px; font-weight: 800; }
.filter-button[aria-pressed="true"] { background: var(--accent-deep); color: #fff; border-color: var(--accent-deep); }
body[data-theme="light"] .filter-button[aria-pressed="true"] { color: #164783; }
.sort-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 750; margin: 0 0 10px; }
.sort-row select { max-width: 210px; padding: 6px 9px; }
.recipe-list { display: flex; flex-direction: column; gap: 8px; min-height: 340px; max-height: calc(100vh - 260px); overflow: auto; padding: 2px 5px 2px 0; scrollbar-color: var(--line) transparent; }
.recipe-card { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; text-align: left; color: var(--text); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px; }
.recipe-card:hover { border-color: var(--accent); }
.recipe-card[aria-pressed="true"] { border-color: var(--accent); background: var(--selected); }
.recipe-identity { min-width: 0; display: block; }
.recipe-category { display: block; font-size: 11px; color: var(--accent); font-weight: 800; margin-bottom: 2px; }
.recipe-name { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.recipe-price { text-align: right; white-space: nowrap; color: var(--accent); font-size: 19px; font-weight: 850; letter-spacing: -.02em; }
.recipe-price small { display: block; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0; }
.recipe-price.missing { color: var(--warning); font-size: 12px; }
.recipe-ratio { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.list-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.empty-state { padding: 35px 12px; text-align: center; color: var(--muted); background: var(--panel-soft); border-radius: 10px; }

.detail-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; scrollbar-color: var(--line) transparent; }
.detail-category { display: inline-flex; background: var(--chip); color: var(--accent); border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 800; }
.detail-title { font-size: clamp(21px, 1.7vw, 25px); letter-spacing: -.03em; line-height: 1.35; margin: 10px 0 14px; }
.cost-hero { background: var(--selected); border: 1px solid var(--line); border-radius: 12px; padding: 17px; margin-bottom: 14px; }
.cost-hero .label { display: block; color: var(--muted); font-size: 12px; font-weight: 750; }
.cost-hero strong { display: block; color: var(--accent); font-size: clamp(26px, 2.2vw, 34px); line-height: 1.3; margin-top: 3px; }
.cost-hero strong small { font-size: 13px; margin-left: 4px; }
.cost-hero p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.detail-total { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.detail-total strong { color: var(--green); text-align: right; }
.detail-total .incomplete { color: var(--warning); }
.detail-subtitle { font-weight: 850; margin: 20px 0 7px; font-size: 15px; }
.material-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 11px 2px; }
.material-row:last-child { border-bottom: 0; }
.material-name { font-size: 14px; font-weight: 750; }
.material-math { color: var(--muted); font-size: 12px; }
.material-cost { text-align: right; font-weight: 800; font-size: 14px; }
.material-cost.missing { color: var(--warning); font-size: 11px; }
.gain-box { margin-top: 20px; border: 1px solid var(--line); background: var(--panel-soft); border-radius: 11px; padding: 16px; }
.gain-box label { display: block; font-weight: 800; margin-bottom: 7px; }
.gain-box select { width: 100%; min-height: 43px; padding: 8px 10px; background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.gain-box p { color: var(--muted); font-size: 11px; margin: 6px 0 0; }
.gain-result { color: var(--green); font-weight: 800; font-size: 14px; margin-top: 9px; }
.page-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 22px; }
.list-return { display: none; color: var(--muted); font-size: 12px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.page-footer a { color: var(--accent); text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }

@media (max-width: 1320px) {
  .calculator-grid { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); }
  .detail-panel { grid-column: 1 / -1; position: static; max-height: none; }
  .recipe-list { max-height: 560px; }
}

@media (max-width: 760px) {
  .shell { padding: 0 14px 28px; }
  .top-nav { min-height: 60px; margin-bottom: 20px; }
  .brand span { display: none; }
  .page-header { display: block; }
  .header-actions { justify-content: flex-start; margin-top: 12px; }
  .steps { gap: 6px; }
  .steps li { flex: 1; justify-content: center; padding: 7px 4px; font-size: 11px; text-align: center; }
  .steps strong { width: 20px; height: 20px; flex: 0 0 20px; }
  .calculator-grid { display: block; }
  .panel { margin-bottom: 14px; padding: 18px; }
  .prices-panel, .detail-panel { position: static; max-height: none; }
  .recipe-list { max-height: 500px; }
  .list-return { display: inline; }
}

@media (max-width: 390px) {
  .steps li { flex-direction: column; gap: 2px; font-size: 10px; }
  .price-row { grid-template-columns: minmax(0, 1fr) 82px; }
  .recipe-card { gap: 8px; padding: 12px 10px; }
  .recipe-price { font-size: 17px; }
}
