:root {
  --bg: #f6f5f2; --card: #fff; --text: #1d1d1b; --muted: #77756f; --line: #e4e2dc;
  --accent: #2f6f4f; --accent-text: #fff; --good: #2f7d4a; --bad: #b8432f; --warn: #c98a12;
  --ok-bg: #dff1e5; --err-bg: #f7dcd6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161715; --card: #20211f; --text: #ecebe7; --muted: #9a988f; --line: #33342f;
    --accent: #4f9d73; --good: #6cc48d; --bad: #e57a64; --ok-bg: #22402e; --err-bg: #4a2a23;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 32px 0 8px; }
.muted { color: var(--muted); } .small { font-size: .85rem; font-weight: normal; }
.good { color: var(--good); } .bad { color: var(--bad); }
.top { max-width: 1100px; margin: 0 auto; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-weight: 700; text-decoration: none; }
.pager a { margin-left: 14px; text-decoration: none; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.test { padding: 0; overflow: hidden; text-decoration: none; display: flex; flex-direction: column; }
.test img { width: 100%; height: 120px; object-fit: cover; object-position: top; border-bottom: 1px solid var(--line); }
.test-body { padding: 12px 14px; }
.test-title { font-weight: 650; font-size: 1.05rem; }
.pill { font-size: .72rem; background: var(--warn); color: #fff; border-radius: 10px; padding: 1px 8px; vertical-align: middle; }
.cycles { display: flex; gap: 4px; margin: 8px 0; }
.cycles i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.cycles i.on { background: var(--accent); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: .9rem; }
dt { color: var(--muted); } dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.matrix td, .matrix th { text-align: center; padding: 6px 8px; }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

.panel { position: sticky; top: 0; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.panel.paused .timer { color: var(--warn); }
.timer-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.timer { font-size: clamp(2.6rem, 11vw, 4.2rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.timer.over { color: var(--bad); }
.small-timer { font-size: 2rem; margin: 4px 0; }
.target { text-align: right; } .target #target { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--line); border-radius: 3px; margin: 12px 0; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 12px; padding: 10px 18px; cursor: pointer; }
.btn.big { flex: 1; min-width: 110px; font-size: 1.25rem; font-weight: 650; padding: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
#puzzles-wrap { margin-top: 12px; }
.puzzles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 8px 0; }
.pz { font: inherit; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 8px 0 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; min-height: 54px; }
.pz b { font-size: 1.15rem; } .pz small { font-size: .72rem; color: var(--muted); min-height: 1em; font-variant-numeric: tabular-nums; }
.pz.ok { background: var(--ok-bg); border-color: var(--good); }
.pz.err { background: var(--err-bg); border-color: var(--bad); }
.row-end { display: flex; justify-content: space-between; align-items: center; }

.photos { display: grid; gap: 16px; margin-top: 16px; }
.photos figure { margin: 0; }
.photos img { width: 100%; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; background: #fff; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; overflow: auto; display: flex; cursor: zoom-in; }
.lightbox[hidden] { display: none; }
.lightbox img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox.zoomed { display: block; cursor: zoom-out; }
.lightbox.zoomed img { max-width: none; max-height: none; width: 250%; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 20px; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; }
dialog label { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; }
input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 110px; }
.login { max-width: 340px; margin: 60px auto; display: grid; gap: 12px; } .login input { width: 100%; }

@media (min-width: 900px) { .photos { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .puzzles { grid-template-columns: repeat(4, 1fr); } .btn.big { min-width: 90px; padding: 14px 8px; } }
.top-right { display: flex; align-items: center; gap: 4px; }
.visits { margin-left: 14px; text-decoration: none; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: 10px; padding: 2px 10px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.days a { text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: .85rem; background: var(--card); }
.days a.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
td.ua { white-space: normal; max-width: 360px; font-size: .8rem; color: var(--muted); }
