:root {
  color-scheme: light;
  font-family: system-ui, "Microsoft JhengHei", sans-serif;
  color: #172027;
  background: #edf0ee;
  --muted: #53616a;
  --line: #dbe2df;
  --accent: #006a5c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.frame { width: min(1320px, calc(100% - 72px)); margin: auto; }
.top { color: #f6fbf8; background: #192525; border-bottom: 3px solid #50c5ad; }
.top-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.account-controls { justify-content: flex-end; flex-wrap: wrap; min-height: 42px; padding-block: 5px; font-size: .85rem; }
.account-controls a { color: inherit; }
.account-controls button { min-height: 34px; padding-inline: 12px; color: #172027; font-weight: 700; }
.top strong { letter-spacing: .06em; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: block; width: 64px; height: 42px; padding: 3px 5px; border-radius: 4px; background: #fff; flex: none; }
.phase { border: 1px solid #59706c; border-radius: 4px; padding: 6px 9px; font: 700 .74rem ui-monospace, monospace; white-space: nowrap; }
main { padding-block: 42px; }
.intro { margin-bottom: 27px; }
.eyebrow { margin: 0; color: var(--accent); font: 700 .76rem ui-monospace, monospace; letter-spacing: .14em; }
.eyebrow span { color: #6b7e79; }
h1 { font-size: clamp(1.95rem, 5vw, 3rem); letter-spacing: -.025em; margin: 8px 0 5px; }
.intro > p:last-child { margin: 0; color: var(--muted); line-height: 1.6; }
.workspace { display: grid; grid-template-columns: 278px minmax(0, 1fr); align-items: start; gap: 18px; }
aside { display: grid; gap: 14px; min-width: 0; }
.card { border: 1px solid var(--line); background: white; border-radius: 10px; box-shadow: 0 2px 5px #233e3410; }
.settings { padding: 20px; }
.settings h2 { font-size: 1rem; margin: 0 0 16px; }
.settings h2 span { color: var(--accent); font: 700 .78rem ui-monospace, monospace; margin-right: 6px; }
.file-button, select, button { width: 100%; border-radius: 6px; font: inherit; min-height: 42px; }
.file-button { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.file-button:hover { background: #005548; }
:focus-visible, .settings:has(#csv-file:focus-visible) .file-button { outline: 3px solid #178a77; outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.file-name { font-size: .86rem; overflow-wrap: anywhere; margin: 12px 0 6px; }
.note { color: var(--muted); font-size: .82rem; line-height: 1.55; margin: 0; }
.settings label:not(.file-button) { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; font-weight: 700; margin-bottom: 6px; }
.settings label span { color: var(--muted); font-weight: 400; }
select, button { border: 1px solid #bac8c4; background: #f9fbfa; color: inherit; font-size: .88rem; padding: 0 9px; }
select { margin-bottom: 14px; }
button:not(:disabled), select:not(:disabled) { cursor: pointer; }
button:disabled, select:disabled { color: #5f6b70; opacity: .68; }
button:not(:disabled):hover { background: #e6f2ef; }
.chart-card { padding: 24px; min-width: 0; }
.chart-head h2 { margin: 6px 0; font-size: 1.38rem; overflow-wrap: anywhere; }
.chart-head > p:last-child { margin: 0 0 16px; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.range-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 7px; background: #f8faf9; }
.range-controls label { display: block; margin-bottom: 4px; font-size: .8rem; font-weight: 650; }
.range-controls select { min-width: 124px; margin: 0; }
.range-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 6px; align-items: end; flex: 1 1 240px; max-width: 340px; }
.range-form input { width: 100%; min-height: 42px; padding: 0 7px; border: 1px solid #bac8c4; border-radius: 6px; color: inherit; font: inherit; font-size: .88rem; }
.range-error { grid-column: 1 / -1; color: #a12822; }
#range-hint { flex-basis: 100%; }
#range-status { margin-bottom: 4px; }
.analysis { margin-bottom: 12px; }
.analysis-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
#analyze { width: auto; padding-inline: 14px; font-weight: 700; }
#analyze:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
#analyze:not(:disabled):hover { background: #005548; }
.analysis-controls .note { flex: 1 1 195px; }
.analysis-results { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 8px 0 5px; padding: 0; }
.analysis-results li { display: flex; align-items: center; gap: 6px; border: 1px solid #edc8c7; background: #fff8f7; border-radius: 5px; padding: 5px 8px; font-size: .81rem; }
.analysis-results li::before { content: ''; width: 8px; height: 8px; border: 2px solid #bc272b; border-radius: 1px; flex: none; }
.analysis-results li:not([data-kind="trend"]) { border-color: #e6d5a7; background: #fffbef; }
.analysis-results li:not([data-kind="trend"])::before { border: 0; border-radius: 50%; background: #c88d00; }
.plot { position: relative; height: clamp(290px, 49vh, 520px); background: #f8faf9; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; }
.plot-hover-dot, .plot-tooltip { position: absolute; pointer-events: none; }
.plot-hover-dot { width: 11px; height: 11px; border: 2px solid #005548; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px #fff; }
.plot-tooltip { max-width: calc(100% - 12px); padding: 7px 10px; border-radius: 6px; background: #192525; color: #fff; box-shadow: 0 2px 6px #19252535; font-size: .82rem; line-height: 1.55; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.empty { height: 100%; display: grid; align-content: center; justify-items: center; gap: 9px; text-align: center; padding: 18px; background-image: linear-gradient(#dfe8e480 1px, transparent 1px), linear-gradient(90deg, #dfe8e480 1px, transparent 1px); background-size: 28px 28px; }
.empty svg { color: var(--accent); }
.empty p { color: var(--muted); font-size: .89rem; margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 14px 0 10px; }
.metrics div { border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; overflow-wrap: anywhere; }
.metrics dt { color: var(--muted); font-size: .79rem; }
.metrics dd { margin: 4px 0 0; font-size: .94rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.status[data-error] { color: #a12822; }
@media (max-width: 790px) {
  .frame { width: calc(100% - 32px); }
  main { padding-block: 24px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  aside { grid-template-columns: minmax(0, 1fr); }
  .chart-card, .settings { padding: 13px; }
  .metrics div { padding-inline: 6px; }
}
