:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #14171c;
  --muted: #6b7380;
  --line: #e3e6eb;
  --accent: #1f9d63;
  --accent-soft: #d9f2e5;
  --warn: #d9722b;
  --danger: #c93c3c;
  --field: #f4f5f7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #171b22;
    --text: #eceef2;
    --muted: #8b93a1;
    --line: #262c36;
    --accent: #35c283;
    --accent-soft: #173a2b;
    --warn: #f0934e;
    --danger: #ef6a6a;
    --field: #0e1116;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }

#app {
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom));
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
}
.today-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 820px) {
  .today-grid { grid-template-columns: 380px 1fr; align-items: start; }
}
.col { min-width: 0; }

input {
  width: 100%;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
input:focus { border-color: var(--accent); }
.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { opacity: .75; }
.row { display: flex; gap: 8px; margin-top: 10px; }

/* вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 10px; }
.auth-card p { margin: 0; }

/* таймер */
.timer-card { text-align: center; }
.ring-wrap { position: relative; width: min(100%, 300px); margin: 4px auto 10px; }
.ring { width: 100%; display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; }
.worked { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.state { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 12px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.state.on .dot { background: var(--accent); animation: pulse 1.6s infinite; }
.state.done { color: var(--accent); }
@keyframes pulse { 50% { opacity: .3; } }
.timer-card .btn { width: 100%; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.chips.wide { grid-template-columns: repeat(2, 1fr); margin-top: 0; }
@media (min-width: 640px) { .chips.wide { grid-template-columns: repeat(4, 1fr); } }
.chip { background: var(--field); border-radius: 12px; padding: 10px 6px; display: grid; gap: 2px; text-align: center; }
.chip b { font-size: 20px; font-variant-numeric: tabular-nums; }
.chip span { font-size: 12px; color: var(--muted); }

/* списки */
.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .x {
  border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1;
  padding: 4px 8px; cursor: pointer;
}
.goal input[type=checkbox] { width: 24px; height: 24px; flex: none; accent-color: var(--accent); padding: 0; }
.goal.done .grow { text-decoration: line-through; color: var(--muted); }
.tag { font-size: 12px; font-weight: 600; border-radius: 8px; padding: 3px 8px; flex: none; }
.tag.work { background: var(--accent-soft); color: var(--accent); }
.tag.dist { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* видео */
.player-wrap { position: relative; aspect-ratio: 16 / 9; margin-top: 12px; border-radius: 14px; overflow: hidden; background: #000; }
.player-wrap iframe, .player-wrap > div { position: absolute; inset: 0; width: 100%; height: 100%; }
.notice {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

/* статистика */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 200px; margin-top: 12px; position: relative; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; min-width: 0; }
.bar .val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar .col-fill { width: 100%; max-width: 54px; border-radius: 8px 8px 3px 3px; background: var(--line); min-height: 3px; }
.bar.met .col-fill { background: var(--accent); }
.bar .lbl { font-size: 12px; color: var(--muted); }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0; max-width: 420px; }
.cell {
  aspect-ratio: 1; border-radius: 8px; background: var(--line);
  display: grid; place-items: center; font-size: 12px; color: var(--muted);
  position: relative; overflow: hidden;
}
.cell i { position: absolute; inset: 0; background: var(--accent); }
.cell span { position: relative; }
.cell.has { color: var(--text); }
.cell.met { outline: 2px solid var(--accent); outline-offset: -2px; color: var(--text); }
.cell.empty { background: none; }

/* настройки */
.field { display: grid; gap: 6px; margin: 10px 0; max-width: 320px; }
.field span { font-size: 14px; color: var(--muted); }
.steps { padding-left: 20px; margin: 8px 0 14px; }
.steps li { margin: 4px 0; }
.hook { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.hook > div { display: grid; }
.hook code {
  font: 12px/1.4 ui-monospace, Menlo, monospace; background: var(--field);
  border-radius: 10px; padding: 9px 11px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all;
}
.hook .copy { justify-self: start; padding: 8px 14px; }

/* нижняя панель */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
  background: none; border: 0; padding: 16px 4px; cursor: pointer;
}
.nav button.active { color: var(--accent); }
