:root {
  --bg: #0f1115; --card: #181b21; --card2: #1f232b; --line: #2a2f38;
  --text: #eceff4; --mute: #9aa3b2; --acc: #ff7a1a; --acc-text: #1a0e02;
  --ok: #3ecf8e; --bad: #ff6b6b;
  --r: 14px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7; --card: #ffffff; --card2: #f0f2f5; --line: #e0e4ea;
    --text: #14171c; --mute: #566070; --acc: #e0600a; --acc-text: #ffffff;
    --ok: #12905e; --bad: #d23c3c;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
#app { max-width: 640px; margin: 0 auto; padding: 14px 16px 24px; padding-top: calc(14px + env(safe-area-inset-top)); }
h1 { font-size: 1.35rem; margin: 4px 0 14px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin: 18px 0 8px; font-weight: 600; }
p { margin: 6px 0; }
.mute { color: var(--mute); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.done { border-color: var(--ok); }
.card.suggest { border-color: var(--acc); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600; min-height: 46px; cursor: pointer;
}
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-text); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.block { display: block; width: 100%; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); color: var(--mute); vertical-align: middle; }
.badge.deload { color: var(--ok); border-color: var(--ok); }
.badge.acc { color: var(--acc); border-color: var(--acc); }

.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--acc); border-radius: 99px; }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
label { display: block; font-size: .8rem; color: var(--mute); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.exlist { list-style: none; margin: 8px 0 12px; padding: 0; }
.exlist li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.exlist li:last-child { border-bottom: 0; }
.exlist .t { color: var(--mute); text-align: right; }

.sets { list-style: none; margin: 8px 0; padding: 0; }
.sets li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sets li:last-child { border-bottom: 0; }
.sets button { appearance: none; border: 0; background: none; color: var(--mute); font-size: 1.1rem; padding: 6px 10px; min-height: 36px; }
.setform { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 8px; align-items: end; margin-top: 10px; }
.setform .btn { min-height: 44px; padding: 8px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { font-size: .8rem; padding: 3px 9px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); color: var(--mute); }
.hint { font-size: .82rem; color: var(--mute); margin: 4px 0; }

details.wu { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 14px; margin-bottom: 12px; }
details.wu summary { padding: 10px 0; font-weight: 600; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: .95rem; }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 1px; accent-color: var(--acc); }
.check.on span { color: var(--mute); text-decoration: line-through; }

.hist { display: block; color: inherit; text-decoration: none; }
.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { flex: 1; appearance: none; border: 0; background: none; color: var(--mute); font: inherit; font-weight: 600; padding: 9px; border-radius: 9px; min-height: 40px; }
.seg button.on { background: var(--acc); color: var(--acc-text); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--mute); font-weight: 600; font-size: .78rem; }
td.r, th.r { text-align: right; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--mute); font-size: 10px; }
.chart .ln { stroke: var(--acc); fill: none; stroke-width: 2; }
.chart .pt { fill: var(--acc); }
.chart .gr { stroke: var(--line); stroke-width: 1; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
#tabs[hidden], #timer[hidden], #toast[hidden] { display: none; }
#tabs a { flex: 1; text-align: center; padding: 8px 0 7px; color: var(--mute); text-decoration: none; font-size: .72rem; }
#tabs a span { display: block; font-size: 1.25rem; line-height: 1.2; }
#tabs a.on { color: var(--acc); font-weight: 700; }

#timer {
  position: fixed; left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 6;
  background: var(--acc); color: var(--acc-text); border-radius: 14px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
#timer .time { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; flex: 1; }
#timer button { appearance: none; border: 0; border-radius: 10px; background: rgba(0,0,0,.18); color: inherit; font: inherit; font-weight: 700; padding: 8px 12px; min-height: 40px; }
#timer.ready { background: var(--ok); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 9;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .92rem; max-width: 90vw;
}
.login { max-width: 340px; margin: 12vh auto 0; }
.empty { text-align: center; color: var(--mute); padding: 28px 8px; }
