:root {
  color-scheme: dark;
  --bg: #111916;
  --panel: #19221e;
  --surface: #202c26;
  --stroke: #34443b;
  --text: #eef4f0;
  --muted: #a4b4aa;
  --accent: #83e3b4;
  --accent-ink: #132d20;
  --tint: #254637;
  --warn: #efc791;
  --alert: #ffb7a5;
  --grid: #37473e;
  font: 16px/1.48 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f2;
  --panel: #ffffff;
  --surface: #f3f7f4;
  --stroke: #d7e3db;
  --text: #15291e;
  --muted: #52695a;
  --accent: #0b6b46;
  --accent-ink: #ffffff;
  --tint: #dff3e8;
  --warn: #815115;
  --alert: #a63825;
  --grid: #dce8df;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100dvh; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
button, input, select, summary, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.15rem, 5vw, 3.2rem); line-height: 1.05; letter-spacing: -.055em; }
h2 { font-size: 1.45rem; line-height: 1.2; letter-spacing: -.035em; }

.top { border-bottom: 1px solid var(--stroke); padding-top: env(safe-area-inset-top, 0); }
.top-inner {
  max-width: 1152px; margin: auto; padding: 18px 26px; display: flex;
  align-items: center; justify-content: space-between;
}
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font-weight: 780; letter-spacing: .16em; font-size: .92rem; }
.mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: flex; align-items: end; justify-content: center; gap: 3px; padding-bottom: 7px; }
.mark i { width: 3px; height: 7px; border-radius: 2px; background: var(--accent-ink); }
.mark i:nth-child(2) { height: 12px; }
.mark i:last-child { height: 16px; }
.shell { max-width: 1152px; margin: auto; padding: 34px 26px calc(38px + env(safe-area-inset-bottom, 0px)); }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin-bottom: 24px; }
.tabs { border: 1px solid var(--stroke); background: var(--panel); border-radius: 13px; padding: 4px; display: inline-flex; gap: 3px; }
.tabs button { border: 0; color: var(--muted); background: transparent; border-radius: 9px; padding: 8px 18px; font-size: .93rem; font-weight: 680; white-space: nowrap; }
.tabs button[aria-pressed="true"] { color: var(--accent); background: var(--tint); }
.tabs.small button { font-size: .8rem; padding: 7px 10px; }
.notice, .empty { color: var(--muted); padding: 18px 0; }
.notice.error, .error { color: var(--alert); }
.panel { background: var(--panel); border: 1px solid var(--stroke); border-radius: 22px; min-width: 0; }
.layout { display: grid; grid-template-columns: minmax(210px, 250px) minmax(0, 1fr); align-items: start; gap: 22px; }
.workspace { min-width: 0; }
.history { padding: 22px 14px 14px; }
.history h2 { font-size: 1.02rem; margin: 0 8px 13px; letter-spacing: -.02em; }
.report-list { display: flex; flex-direction: column; gap: 4px; max-height: 36rem; overflow: auto; }
.report-list button {
  padding: 12px 10px; border: 1px solid transparent; border-radius: 12px; text-align: left;
  background: transparent; color: var(--text); width: 100%; display: grid; gap: 2px;
}
.report-list button[aria-current="true"] { border-color: var(--stroke); background: var(--tint); }
.report-list button:hover { border-color: var(--stroke); }
.report-list .date { font-weight: 690; }
.report-list .meta { font-size: .82rem; }
.report, .trend { padding: 26px; }
.report-heading, .chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.meta { color: var(--muted); font-size: .92rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.badge { border-radius: 99px; padding: 4px 10px; background: var(--tint); color: var(--accent); font-size: .74rem; font-weight: 670; white-space: nowrap; }
.badge.draft { background: var(--surface); color: var(--warn); }
.badge.demo { background: var(--surface); color: var(--muted); }
.search { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 12px; padding: 0 12px; margin: 18px 0 12px; }
.search:focus-within { border-color: var(--accent); }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); padding: 11px 0; }
.search input:focus-visible { outline: none; }
.search input::placeholder { color: var(--muted); }
.search-icon { width: 13px; height: 13px; border: 1.5px solid var(--muted); border-radius: 50%; position: relative; flex: 0 0 13px; }
.search-icon::after { content: ""; height: 1.5px; width: 5px; background: var(--muted); position: absolute; transform: rotate(45deg); right: -3px; bottom: -1px; border-radius: 1px; }
.table-head { display: grid; grid-template-columns: minmax(0, 1fr) max-content; color: var(--muted); font-weight: 650; font-size: .75rem; letter-spacing: .04em; padding: 9px 3px 8px; }
.result {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(70px, max-content); width: 100%;
  align-items: center; gap: 12px; border: 0; border-top: 1px solid var(--stroke);
  background: transparent; color: var(--text); text-align: left; padding: 13px 3px;
}
button.result:hover { background: var(--surface); }
.result .label { font-weight: 590; overflow-wrap: anywhere; min-width: 0; }
.reading { display: flex; align-items: baseline; justify-content: end; gap: 5px; flex-wrap: wrap; text-align: right; max-width: 245px; min-width: 0; overflow-wrap: anywhere; }
.reading strong { font-weight: 730; font-size: 1.14rem; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.unit { font-size: .84rem; color: var(--muted); }
.arrow { color: var(--accent); margin-left: 4px; font-size: 1.1rem; }
.time { display: block; color: var(--muted); font-size: .8rem; font-weight: 500; margin-top: 3px; }
.scheme { padding: 14px 18px; margin-top: 15px; }
.scheme summary { cursor: pointer; font-weight: 635; }
#scheme-content { padding: 9px 0 4px; color: var(--muted); overflow-wrap: anywhere; }
#scheme-content p + p { margin-top: 6px; }
.picker { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: .84rem; }
.picker input, .picker select {
  padding: 10px 11px; border-radius: 11px; background: var(--surface); border: 1px solid var(--stroke);
  font-size: 1rem; width: 100%; min-width: 0; color: var(--text);
}
.mobile-picker { display: none; }
.tools, .trend-tools { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.tools { padding-bottom: 6px; }
.trend-tools { margin-bottom: 24px; }
.grow { flex: 1 1 210px; }
.units-picker { flex: 0 1 170px; }
.primary, .secondary { border-radius: 11px; border: 1px solid var(--stroke); padding: 10px 13px; font-weight: 670; font-size: .9rem; }
.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.secondary { color: var(--text); background: var(--surface); }
.latest { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.latest strong { font-size: 2.5rem; letter-spacing: -.05em; font-weight: 740; line-height: 1; font-variant-numeric: tabular-nums; }
.latest > span { color: var(--muted); font-size: .94rem; }
.latest .change { color: var(--accent); font-weight: 640; }
#chart { width: 100%; height: 236px; display: block; margin: 16px 0 10px; }

dialog { padding: 22px; border-radius: 22px; color: var(--text); background: var(--panel); border: 1px solid var(--stroke); max-width: min(460px, calc(100vw - 28px)); width: 100%; }
dialog::backdrop { background: rgb(0 0 0 / .62); }
.dialog-caption { color: var(--muted); font-size: .86rem; }
dialog h2 { margin-top: 4px; overflow-wrap: anywhere; }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.dialog-actions { margin-top: 18px; display: flex; justify-content: end; gap: 9px; }
dialog .error { margin-top: 9px; font-size: .9rem; }

@media (max-width: 670px) {
  .top-inner { padding: 13px 16px; }
  .shell { padding: 20px 14px calc(28px + env(safe-area-inset-bottom, 0px)); }
  .heading { align-items: stretch; flex-direction: column; gap: 16px; margin-bottom: 16px; }
  .heading .tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .history { display: none; }
  .mobile-picker { display: grid; margin: 0 0 12px; }
  .report, .trend { padding: 16px 13px; border-radius: 17px; }
  .report-heading { gap: 8px; }
  .report-heading h2 { font-size: 1.3rem; }
  .reading { max-width: 143px; }
  .reading strong { font-size: 1rem; }
  .unit { font-size: .79rem; }
  .result { gap: 9px; padding-block: 11px; }
  .result .label { font-size: .93rem; }
  .chart-heading { flex-wrap: wrap; }
  #chart { height: 206px; }
}
