/*
VOICE  차분한 측정 도구. 숫자가 주인공, 꾸밈은 최소.
IDEA   측정 노트 한 장: 따뜻한 종이 바탕 위에 곡선과 판정만 또렷하게.
PICTURE 첫 화면은 FR 그래프 그 자체, 헤드룸은 큰 판정 + 최대 음압 숫자.
COLOUR 마스코트에서 온 세이지 그린(강조), 코트 베이지(보조), 종이색 바탕. 밤엔 같은 구성을 어둡게.
TYPE   시스템 글꼴(오프라인·DAP 호환). 숫자는 tabular-nums.
LAYOUT 한 열, 최대 720px. 아래 탭바, 시트는 아래에서 올라옴. 360px(DX260)부터 430px(15 Pro Max)까지.
*/
:root {
  --bg: #F4F3EE; --card: #FFFFFF; --ink: #1B1E1D; --muted: #676C69; --line: #E2E1DA; --grid: #E7E6E0;
  --accent: #2C8A66; --accent-ink: #FFFFFF; --accent-soft: #E3F1EA; --beige: #EFE6D8;
  --target: #8D928E; --ok: #B7791F; --low: #C2413A; --eq: #2C8A66; --warnbg: #FBF1DE;
  --shadow: 0 1px 2px rgba(20, 24, 22, .06), 0 4px 14px rgba(20, 24, 22, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #121514; --card: #1B1F1E; --ink: #ECEDEA; --muted: #9AA09C; --line: #2B312F; --grid: #272D2B;
    --accent: #4DB88B; --accent-ink: #0D1512; --accent-soft: #1D3229; --beige: #2D2822;
    --target: #9AA09C; --ok: #E0A84A; --low: #EF6E66; --eq: #4DB88B; --warnbg: #2E2617;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #121514; --card: #1B1F1E; --ink: #ECEDEA; --muted: #9AA09C; --line: #2B312F; --grid: #272D2B;
  --accent: #4DB88B; --accent-ink: #0D1512; --accent-soft: #1D3229; --beige: #2D2822;
  --target: #9AA09C; --ok: #E0A84A; --low: #EF6E66; --eq: #4DB88B; --warnbg: #2E2617;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
  padding: 0 max(12px, env(safe-area-inset-right)) calc(76px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
body.noscroll { overflow: hidden; }
main, .top { max-width: 720px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 4px 10px; }
.top h1 { font-size: 22px; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
.mascot { border-radius: 9px; background: #fff; box-shadow: 0 0 0 1px var(--line); }

.card { background: var(--card); border-radius: 16px; padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-h h2, h2 { font-size: 17px; margin: 0; line-height: 1.3; }
.count { color: var(--muted); font-weight: 500; font-size: 15px; }
h3.opt-h { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }

/* 그래프 */
.graph-card { padding: 10px 8px 12px; }
.fig { position: relative; height: clamp(250px, 64vw, 380px); }
.fig > svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; display: block; }
.readout { position: absolute; top: 6px; right: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; font-size: 13px; line-height: 1.45; max-width: 70%; pointer-events: none; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.readout i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }
.readout b { float: right; margin-left: 10px; }
.ro-f { font-weight: 700; margin-bottom: 2px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; padding: 0 4px; }
.legend { list-style: none; margin: 8px 0 0; padding: 0 4px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.legend .nm { flex: 1; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.legend .nm small { display: block; color: var(--muted); font-size: 12px; }
.lib-filter { flex-wrap: nowrap; margin: 2px 0 0; }
.lib-filter input { flex: 1; width: auto; }
.lib-filter select { flex: none; max-width: 44%; }
.bulk { margin-top: 8px; }
.bulk .btn { flex: 0 1 auto; }
.sw { width: 18px; height: 4px; border-radius: 2px; flex: none; }
.sw.dash { background: repeating-linear-gradient(90deg, var(--target) 0 6px, transparent 6px 10px); }

/* 컨트롤 */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg.full { display: flex; width: 100%; margin-bottom: 10px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; min-height: 36px; white-space: nowrap; cursor: pointer; }
.seg.wrap button { flex: 1 1 30%; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 650; color: var(--accent); }
select, input, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; min-height: 44px; width: 100%; }
select { width: auto; max-width: 100%; padding-right: 28px; -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.tools select { min-height: 38px; padding: 6px 28px 6px 10px; font-size: 14px; }
input[type=range] { padding: 0; border: 0; background: transparent; min-height: 36px; accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); flex: none; margin: 0; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=search] { margin-top: 2px; }
.field { display: block; margin: 0 0 10px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.field-row > select { flex: 1; width: 100%; }
.field-row.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field-row.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-row .field { margin: 0; }
.field-row .unit { color: var(--muted); }
.field-row > input[type=number] { flex: 1 1 90px; width: auto; }
.field-row .field input, .field-row .field select { width: 100%; }
.field .field-row { flex-wrap: nowrap; margin: 0; }
#ed-unit, .unit-sel { flex: none; width: 104px; }
.manual { background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 10px; margin: -2px 0 12px; }
.pt.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.manual [data-savem] { margin-top: 8px; }
.manual .pt.head { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field .field-row > input { flex: 1; width: 100%; }
.btn { font: inherit; font-size: 15px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 11px; padding: 10px 14px; min-height: 44px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; }
.btn.small { min-height: 36px; padding: 6px 11px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.danger { color: var(--low); border-color: var(--low); }
.btn.ghost { background: transparent; }
.btn:active, .row-btn:active, .chip:active { transform: scale(.98); }
.file-btn { position: relative; overflow: hidden; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-btns .btn { flex: 1 1 auto; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 16px; min-width: 40px; min-height: 40px; border-radius: 10px; cursor: pointer; }
.icon-btn.star { font-size: 22px; color: var(--muted); border: 1px solid var(--line); background: var(--bg); min-height: 44px; min-width: 44px; }
.icon-btn.star.on { color: #D9A520; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 5px 11px; min-height: 32px; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 650; }
.chip.saved { border-color: var(--accent); }
.chip.mini { font-size: 12px; padding: 4px 8px; min-height: 28px; color: var(--muted); }
.chip-group { display: inline-flex; gap: 3px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.link { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; padding: 8px 0; cursor: pointer; }
.tag { font-style: normal; font-size: 12px; color: var(--ok); border: 1px solid currentColor; border-radius: 6px; padding: 0 5px; margin-left: 4px; white-space: nowrap; vertical-align: 1px; }

/* 목록 */
.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding: 4px 0; }
.list li:first-child { border-top: 0; }
.list li.empty { color: var(--muted); font-size: 14px; padding: 10px 2px; display: block; }
.list .grow { flex: 1; padding: 6px 2px; }
.list small, .row-btn small, .chk small { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; font-weight: 400; overflow-wrap: anywhere; }
.row-btn { flex: 1; display: block; text-align: left; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 8px 2px; min-height: 44px; cursor: pointer; border-radius: 8px; }
.row-btn b { font-weight: 650; }
.chk { display: flex; align-items: center; gap: 10px; flex: 1; padding: 6px 2px; min-height: 44px; cursor: pointer; }
.chk.inline { flex: none; margin: 4px 0 10px; }
.chk span { flex: 1; overflow-wrap: anywhere; }
.miss { color: var(--ok); }
.status { color: var(--muted); font-size: 14px; margin: 8px 2px 0; min-height: 0; }
.status:empty { display: none; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; line-height: 1.5; }
.warn { white-space: pre-line; background: var(--warnbg); color: var(--ink); border-radius: 10px; padding: 8px 11px; font-size: 13px; margin: 10px 4px 0; line-height: 1.5; }
.targets summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 10px 2px 4px; min-height: 40px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 10px 0; }
.stack-form { display: grid; gap: 8px; }
.ai-row { display: flex; gap: 8px; }
.ai-row input { flex: 1; }
.srcs { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; margin-top: 12px; }
.srcs span { color: var(--muted); width: 100%; }
.srcs a { color: var(--accent); overflow-wrap: anywhere; }
.acct b { display: block; font-size: 16px; }
.acct small { color: var(--muted); font-size: 13px; }

/* 헤드룸 */
.pick .field-row { margin: 0; flex-wrap: nowrap; }
.pick select { flex: 1; width: 100%; }
.pick .seg { margin: 4px 0 0; }
.verdict { border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.verdict b { display: block; font-size: 24px; line-height: 1.15; margin-bottom: 4px; text-wrap: balance; }
.verdict span { font-size: 15px; }
.verdict.eq { background: var(--accent-soft); } .verdict.eq b { color: var(--eq); }
.verdict.ok { background: var(--warnbg); } .verdict.ok b { color: var(--ok); }
.verdict.low { background: rgba(194, 65, 58, .1); } .verdict.low b { color: var(--low); }
.verdict.none { background: var(--bg); } .verdict.none b { font-size: 18px; }
.big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 2px 10px; }
.big .lbl { color: var(--muted); font-size: 14px; width: 100%; }
.big .val { font-size: clamp(40px, 13vw, 52px); font-weight: 750; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.big .val small { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 7px 8px 7px 0; vertical-align: top; width: 38%; }
table.kv td { padding: 7px 0; text-align: right; overflow-wrap: anywhere; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid var(--line); }

/* 기기 편집 */
.outbox { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 0 0 12px; }
.outbox legend { font-weight: 650; font-size: 15px; padding: 0 6px; }
.outbox [data-a=addpt] { margin: 2px 0 12px; }
.pt { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 6px; margin-bottom: 6px; align-items: center; }
.pt.head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pt input { padding: 8px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.opt span { flex: 1; }
.opt small { display: block; color: var(--muted); font-size: 13px; }
.opt .custom { flex: 1; }
.custom-unit { width: 100%; margin-top: 6px; }
.devs .chip { flex: none; }

/* 톤 */
.tone-hero { display: flex; align-items: center; gap: 14px; }
.tone-read { flex: 1; }
#tn-freq-big { display: block; font-size: clamp(34px, 11vw, 48px); font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.bar { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.play { flex: none; width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 18px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 16px rgba(44, 138, 102, .35); }
.play.playing { background: var(--low); box-shadow: 0 4px 16px rgba(194, 65, 58, .35); }
#tn-fbox.dim { opacity: .4; }
.field b { color: var(--ink); font-weight: 650; }

/* 아래 탭바 */
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 2px;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)); }
#nav button { flex: 1; max-width: 140px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 48px; cursor: pointer; border-radius: 10px; }
#nav svg { width: 24px; height: 24px; }
#nav button.on { color: var(--accent); font-weight: 650; }

/* 시트 */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0); transition: background .2s; display: flex; align-items: flex-end; justify-content: center; }
.sheet.open { background: rgba(0, 0, 0, .38); }
.sheet-panel { width: 100%; max-width: 720px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 4px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .22s ease-out; }
.sheet.open .sheet-panel { transform: none; }
.sheet-head { position: sticky; top: 0; background: var(--card); display: flex; align-items: center; justify-content: space-between; padding: 10px 0 8px; z-index: 1; }
.sheet-msg { font-size: 16px; margin: 4px 0 8px; white-space: pre-line; }

.toast { position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); opacity: 0; z-index: 50;
  background: #1D2120; color: #F2F3F0; border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { border: 0; background: transparent; color: #7FD8AF; font: inherit; font-weight: 700; padding: 4px 2px; min-height: 32px; cursor: pointer; }
.fatal { background: var(--low); color: #fff; padding: 12px; border-radius: 10px; }

@media (min-width: 700px) {
  body { padding-left: 20px; padding-right: 20px; }
  .fig { height: 400px; }
}
/* PC: 넓은 화면에서는 폭을 넓히고 카드를 두 줄로 */
@media (min-width: 1100px) {
  main, .top { max-width: 1180px; }
  .tab:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
  .tab > .card { margin: 0; }
  #tab-fr > .graph-card { grid-column: 1 / -1; }
  .fig { height: min(56vh, 520px); }
  #nav { justify-content: center; }
  #nav button { flex: 0 1 140px; }
  .sheet { align-items: center; }
  .sheet-panel { max-width: 620px; border-radius: 18px; max-height: 86vh; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .row-btn:hover, .chip:hover, .btn:hover { filter: brightness(.97); }
}
@media (max-width: 380px) {
  .seg button { padding: 7px 7px; font-size: 13px; }
  .card { padding: 12px; }
  .tone-hero .play { width: 72px; height: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-panel, .toast { transition: none; }
}

/* 일괄 삭제 · 사이트 목록 버튼 */
.danger-text { color: var(--low) !important; }
.lib-tools { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.lib-tools .btn.on { border-color: var(--accent); color: var(--accent); }
.site-li { flex-wrap: wrap; }
.site-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.note { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin: 10px 0 0; }

#fr-results .grp { font-size: 12px; font-weight: 650; color: var(--muted); padding: 10px 2px 4px; border-bottom: none; }
.legend li.pend .nm { opacity: .7; }

#fr-lib .grp { font-size: 12px; font-weight: 650; color: var(--muted); padding: 10px 2px 4px; border-bottom: none; }
#fr-lib li[data-tname] .chip.mini { flex: none; }
.legend .nm.link-like { cursor: pointer; }
.legend .nm.link-like:hover b, .legend .nm.link-like:hover { text-decoration: underline; text-decoration-color: var(--line); }

#hr-out button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.15; padding: 6px 8px; }
#hr-out button b { font-weight: inherit; }
#hr-out button small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; opacity: .75; }
