:root {
  color-scheme: light dark;
  --paper: #e9eaec;
  --surface: #f8f8f9;
  --ink: #15171a;
  --mid: #5b6066;
  --line: #c6c9cd;
  --soft: #dcdee1;
  --alert: #b3261e;
  --radius: 10px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #17181a; --surface: #202225; --ink: #f1f2f3; --mid: #a1a6ac; --line: #44484d; --soft: #2c2f33; --alert: #ff8a80; }
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.5 var(--font); font-variant-numeric: tabular-nums; word-break: keep-all; }
h1, h2, h3, p, ul { margin: 0; }
[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }
button { min-height: 44px; padding: 0 16px; background: transparent; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; }
button:hover { border-color: var(--ink); }
button:disabled { opacity: .4; cursor: default; border-color: var(--line); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
button.quiet { border-color: transparent; color: var(--mid); }
button.quiet:hover { color: var(--ink); border-color: var(--line); }
button[aria-pressed="true"], button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 3px; }
input[type="text"], input[type="number"], select { min-height: 44px; padding: 0 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
input[type="range"] { accent-color: var(--ink); width: 100%; min-height: 32px; margin: 0; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; padding: 14px 28px; background: var(--paper); border-bottom: 1.5px solid var(--line); }
.bar label { display: block; font-size: .8rem; color: var(--mid); margin-bottom: 2px; }
.bar-name { flex: 1 1 220px; max-width: 360px; }
.bar-name input { width: 100%; font-size: 1.25rem; font-weight: 600; }
.bar-pick select { min-width: 180px; }
.bar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.filepick { display: inline-flex !important; align-items: center; min-height: 44px; padding: 0 16px; margin: 0 !important; font-size: 1rem !important; color: var(--ink) !important; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.filepick:hover { border-color: var(--ink); }
.filepick input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.status { min-height: 1.5rem; padding: 8px 28px 0; font-size: .9rem; color: var(--mid); }
.status.error { color: var(--alert); font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 28px 0; }
.tabs button { min-width: 108px; font-weight: 600; }
main { padding: 14px 28px 64px; }
.panel { background: var(--surface); border-radius: 14px; padding: 24px 26px 30px; }
.hint { font-size: .88rem; color: var(--mid); }

.row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 18px; }
.ctl > span { display: block; font-size: .8rem; color: var(--mid); margin-bottom: 2px; }
.ctl input[type="number"] { width: 92px; }
.segment { display: inline-flex; max-width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segment button { border: 0; border-radius: 0; flex: 1 1 auto; min-width: 0; padding: 0 16px; white-space: nowrap; }
.segment button + button { border-left: 1.5px solid var(--line); }
.block { margin-top: 26px; padding-top: 20px; border-top: 1.5px solid var(--soft); }
.block > h2 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.block > h2 small { font-weight: 400; color: var(--mid); margin-left: 8px; }

/* 엔진·모델 고르기 */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.choices button { min-height: 56px; padding: 8px 12px; text-align: left; line-height: 1.25; }
.choices button small { display: block; font-size: .76rem; opacity: .7; }
.bank + .bank { margin-top: 16px; }
.bank h3 { font-size: .88rem; font-weight: 600; color: var(--mid); margin-bottom: 8px; }

/* 큰 노브 세 개 */
.macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 28px; }
.macro { display: grid; justify-items: center; gap: 8px; text-align: center; }
.macro h3 { font-size: 1.05rem; letter-spacing: -.01em; }
.macro p { font-size: .88rem; color: var(--mid); max-width: 30ch; min-height: 3.9em; }
.knob { width: min(168px, 100%); aspect-ratio: 1; touch-action: none; cursor: ns-resize; border-radius: 50%; }
.knob svg { width: 100%; height: 100%; display: block; }
.knob .track { fill: none; stroke: var(--soft); stroke-width: 6; stroke-linecap: round; }
.knob .value { fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: round; }
.knob .cap { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.knob .pointer { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.knob-read { font-size: 1.15rem; font-weight: 600; }
.knob-read small { font-weight: 400; color: var(--mid); margin-left: 6px; font-size: .85rem; }
.knob.small { width: 96px; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 28px; }
.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; }
.field > span { font-size: .92rem; }
.field > span small { color: var(--mid); margin-left: 6px; font-size: .78rem; }
.field output { font-weight: 600; min-width: 3ch; text-align: right; }
.field input[type="range"] { grid-column: 1 / -1; }

.parts { display: flex; flex-wrap: wrap; gap: 8px; }
.parts button { min-height: 52px; text-align: left; line-height: 1.25; }
.parts button small { display: block; font-size: .76rem; opacity: .7; }

.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table th, .sheet-table td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1.5px solid var(--soft); }
.sheet-table th { font-size: .82rem; color: var(--mid); font-weight: 600; }
.sheet-table td ul { list-style: none; padding: 0; }
.sheet-table td li + li { margin-top: 2px; }
.sheet-table td b { font-weight: 600; }
.cc-list { columns: 3 180px; column-gap: 28px; list-style: none; padding: 0; font-size: .92rem; }
.cc-list li { break-inside: avoid; display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid var(--soft); }

@media (max-width: 760px) {
  .bar, .tabs, main { padding-left: 16px; padding-right: 16px; }
  .status { padding-left: 16px; padding-right: 16px; }
  .panel { padding: 18px 16px 24px; }
  .macros { grid-template-columns: 1fr; }
  .macro p { min-height: 0; }
  .segment button { padding: 0 10px; }
  .tabs button { min-width: 0; flex: 1 1 auto; }
}
@media print {
  .bar, .tabs, .status, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { padding: 0; background: #fff; }
  main { padding: 0; }
}
