:root {
  --bg: #0a0a0a;
  --card: #131210;
  --card-2: #1b1915;
  --line: #2a2620;
  --gold: #d9b24c;
  --gold-hi: #f1cf6b;
  --gold-soft: rgba(217, 178, 76, 0.12);
  --red: #d24b3e;
  --grey: #5d5a55;
  --text: #f3eee2;
  --muted: #8f887a;
  --wake: #d9b24c;
  --fixed: #4fb8a6;
  --night: #9a86d6;
  --cell: clamp(34px, 9.4vw, 54px);
  --name: minmax(0, 1fr);
  --head: "Oswald", "Bebas Neue", "Roboto Condensed", "Arial Narrow", "Helvetica Neue Condensed", Impact, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.wrap { max-width: 860px; margin: 0 auto; padding: 18px 14px 40px; }

/* ---------- header ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.brand h1 {
  margin: 0; font-family: var(--head); font-weight: 800; font-stretch: condensed;
  font-size: clamp(30px, 8vw, 46px); line-height: 0.95; letter-spacing: 0.05em; color: var(--gold);
  text-transform: uppercase;
}
.brand .rule { height: 3px; width: 64px; background: linear-gradient(90deg, var(--gold), transparent); margin: 8px 0 0; border-radius: 2px; }
.nav { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.nav a {
  text-decoration: none; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; padding: 7px 13px;
  border-radius: 999px; color: var(--muted);
}
.nav a.on { background: var(--gold); color: #17130a; }

.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 12px; }
.weekbar .range { font-family: var(--head); font-size: 19px; letter-spacing: 0.06em; text-transform: uppercase; }
.weekbar .range small { display: block; font-family: var(--body); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); margin-top: 2px; }
.arrows { display: flex; gap: 6px; align-items: center; }
.arrow {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; font-size: 18px; color: var(--gold);
}
.arrow:disabled { opacity: 0.25; cursor: default; }
.thisweek {
  border: 1px solid var(--gold); background: transparent; color: var(--gold); border-radius: 999px;
  padding: 8px 12px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; cursor: pointer;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px 7px 8px; font-size: 13px;
}
.chip b { color: var(--gold-hi); font-weight: 700; }
.chip .ico { width: 24px; height: 24px; border-radius: 50%; background: var(--gold-soft); display: grid; place-items: center; font-size: 13px; }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(217, 178, 76, 0.5); }
.meter i.on { background: var(--gold); border-color: var(--gold); }

/* ---------- grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px 8px 6px; }
.grid { display: grid; grid-template-columns: var(--name) repeat(7, var(--cell)); align-items: stretch; }
.grid > div { min-height: calc(var(--cell) * 0.95); display: flex; align-items: center; justify-content: center; }
.grid .hd { flex-direction: column; min-height: 50px; gap: 1px; padding-top: 6px; }
.grid .hd .dn { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); }
.grid .hd .dd { font-family: var(--head); font-size: 17px; }
.grid .hd .tag { font-size: 8.5px; font-weight: 800; letter-spacing: 0.1em; margin-top: 2px; color: var(--muted); height: 11px; }
.grid .today { background: var(--gold-soft); }
.grid .hd.today { border-radius: 12px 12px 0 0; }
.grid .hd.today .dn, .grid .hd.today .dd, .grid .hd.today .tag { color: var(--gold-hi); }
.grid .score.today { border-radius: 0 0 12px 12px; }
.grid .yday { background: rgba(255, 255, 255, 0.025); }
.grid .hd.yday { border-radius: 12px 12px 0 0; }
.grid .score.yday { border-radius: 0 0 12px 12px; }
.grid .name {
  justify-content: flex-start; gap: 8px; padding: 0 6px 0 4px; font-size: 13.5px; line-height: 1.15;
  border-top: 1px solid var(--line); min-width: 0;
}
.grid .cell { border-top: 1px solid var(--line); }
.grid .name .em { width: 26px; flex: 0 0 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--card-2); font-size: 14px; position: relative; }
.grid .name .em::after { content: ""; position: absolute; left: -4px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--k, var(--wake)); }
.grid .name .tx { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.grid .name .sub { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.grid .name.off .tx { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(255,255,255,.25); }
.k-wake { --k: var(--wake); } .k-fixed { --k: var(--fixed); } .k-night { --k: var(--night); }
.grid .sect {
  grid-column: 1 / -1; justify-content: flex-start; min-height: 26px; padding: 10px 4px 2px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.16em; color: var(--k); text-transform: uppercase;
}
.grid .score { font-family: var(--head); font-size: 14px; letter-spacing: 0.02em; border-top: 1px solid var(--gold); min-height: 44px; color: var(--text); flex-direction: column; }
.grid .score b { font-weight: 700; font-size: 1.25em; line-height: 1; }
.grid .score small { font-family: var(--body); font-size: 9.5px; color: var(--muted); letter-spacing: .04em; margin-top: 2px; }
.grid .score.lbl { justify-content: flex-start; flex-direction: row; font-size: 12px; letter-spacing: 0.14em; color: var(--gold); text-transform: uppercase; padding-left: 4px; }

/* ---------- circles ---------- */
.dot {
  width: calc(var(--cell) * 0.6); height: calc(var(--cell) * 0.6); border-radius: 50%;
  border: 2px solid rgba(217, 178, 76, 0.32); background: transparent; padding: 0; display: grid; place-items: center;
  font-size: calc(var(--cell) * 0.3); line-height: 1; transition: transform 0.12s;
}
button.dot { cursor: pointer; }
button.dot:active { transform: scale(0.9); }
.dot.s-done, .dot.s-walk { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px rgba(217, 178, 76, 0.35); }
.dot.s-started { border-color: var(--gold); background: radial-gradient(circle, var(--gold) 0 26%, transparent 29%); }
.dot.s-missed { background: var(--red); border-color: var(--red); }
.dot.s-skipped { background: var(--grey); border-color: var(--grey); }
.dot.s-not_today, .dot.s-rest { border: 0; }
.dot.s-not_today::before, .dot.s-rest::before { content: ""; width: 42%; height: 3px; border-radius: 2px; background: var(--muted); }
.dot.s-na, .dot.s-none { border: 0; }
.dot.s-na::before, .dot.s-none::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #34302a; }
.dot svg { width: 58%; height: 58%; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; padding: 0 4px; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { --cell: 26px; }

/* ---------- panels and dialogs ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: none; z-index: 10; }
.scrim.open { display: block; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 105%); width: min(520px, 100%);
  background: var(--card-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 18px 20px 28px; z-index: 11; transition: transform 0.22s ease;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 14px; }
.sheet h3 { margin: 0; font-family: var(--head); font-size: 22px; letter-spacing: 0.04em; display: flex; align-items: center; gap: 10px; }
.sheet .meta { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.taps { list-style: none; margin: 0; padding: 0; }
.taps li { display: flex; justify-content: space-between; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; }
.taps li b { color: var(--gold-hi); font-weight: 600; }
.taps .none { color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; background: var(--gold-soft); color: var(--gold-hi); }
.pill.missed { background: rgba(210, 75, 62, 0.18); color: #f08a7f; }
.pill.skipped, .pill.na, .pill.not_today, .pill.rest { background: rgba(255,255,255,.07); color: var(--muted); }

.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -46%); width: min(440px, calc(100% - 28px));
  background: var(--card-2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; z-index: 11;
  display: none; opacity: 0; transition: opacity 0.15s, transform 0.15s;
}
.modal.open { display: block; opacity: 1; transform: translate(-50%, -50%); }
.modal h3 { margin: 0 0 16px; font-family: var(--head); font-size: 24px; letter-spacing: 0.04em; color: var(--gold); text-transform: uppercase; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; }
.field input, .field select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  padding: 12px; font-size: 16px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.row2 { display: grid; grid-template-columns: 80px 1fr; gap: 10px; }
.row2b { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 10px 4px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--gold); color: #17130a; }
.preview { font-size: 13px; color: var(--gold-hi); margin-top: 8px; min-height: 16px; }
.err { color: #f08a7f; font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.btn { border: 1px solid var(--line); background: transparent; border-radius: 12px; padding: 11px 18px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #17130a; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.confirm p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* ---------- tasks page ---------- */
.list { display: flex; flex-direction: column; gap: 18px; margin-top: 18px; }
.group h2 { margin: 0 0 8px 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.16em; color: var(--k); text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.group h2::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--k); }
.task {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-left: 3px solid var(--k); border-radius: 14px; margin-bottom: 8px;
}
.task .em { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; background: var(--card-2); display: grid; place-items: center; font-size: 19px; }
.task .main { flex: 1; min-width: 0; }
.task .nm { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task .wh { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--gold-hi); margin-top: 3px; flex-wrap: wrap; }
.task.off .nm, .task.off .wh span { color: var(--muted); }
.task.off .em { filter: grayscale(1); opacity: 0.5; }
.icon { width: 28px; height: 28px; border: 0; background: transparent; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon:hover, .icon:focus-visible { background: var(--card-2); color: var(--text); }
.icon.del:hover { color: #f08a7f; }
.icon svg { width: 15px; height: 15px; }
.switch { position: relative; width: 46px; height: 27px; flex: 0 0 46px; border-radius: 999px; background: #2d2a25; border: 0; cursor: pointer; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #8a8478; transition: transform 0.15s, background 0.15s; }
.switch.on { background: var(--gold); }
.switch.on::after { transform: translateX(19px); background: #17130a; }
.add {
  position: fixed; right: max(16px, calc(50% - 414px)); bottom: 22px; z-index: 5; border: 0; border-radius: 999px;
  background: var(--gold); color: #17130a; font-weight: 800; letter-spacing: 0.05em; padding: 15px 22px;
  box-shadow: 0 8px 26px rgba(217, 178, 76, 0.3); cursor: pointer; font-size: 15px;
}
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--card-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; display: none; }
.toast.show { display: block; }

/* ---------- login / denied ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(360px, 100%); text-align: center; }
.login .brand h1 { font-size: 44px; }
.login .brand .rule { margin: 10px auto 26px; }
.login input { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px; color: var(--text); font-size: 16px; text-align: center; outline: none; }
.login input:focus { border-color: var(--gold); }
.login .btn { width: 100%; margin-top: 12px; padding: 15px; }
.login .err { margin-top: 12px; }

/* ---------- wall ---------- */
body.wall { --cell: clamp(40px, 6.6vw, 120px); }
body.wall .wrap { max-width: none; padding: 3vh 3.5vw; }
body.wall .brand h1 { font-size: clamp(40px, 5.4vw, 110px); }
body.wall .brand .rule { width: 7vw; height: 4px; }
body.wall .clock { text-align: right; }
body.wall .clock .t { font-family: var(--head); font-size: clamp(36px, 5vw, 104px); line-height: 0.95; color: var(--text); letter-spacing: 0.03em; }
body.wall .clock .d { font-size: clamp(14px, 1.5vw, 30px); color: var(--gold); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 6px; }
body.wall .chips { margin: 2.2vh 0 1.6vh; gap: 1vw; }
body.wall .chip { font-size: clamp(13px, 1.3vw, 28px); padding: 0.6vh 1.2vw 0.6vh 0.6vw; }
body.wall .chip .ico { width: 2vw; height: 2vw; min-width: 24px; min-height: 24px; font-size: 1.1vw; }
body.wall .meter i { width: 1vw; height: 1vw; min-width: 9px; min-height: 9px; }
body.wall .card { padding: 1vh 1vw; border-radius: 1.6vw; }
body.wall .grid .name { font-size: clamp(13px, 1.45vw, 30px); gap: 0.8vw; }
body.wall .grid .name .em { width: 2.4vw; height: 2.4vw; flex-basis: 2.4vw; min-width: 26px; min-height: 26px; font-size: 1.3vw; border-radius: 0.7vw; }
body.wall .grid .hd { min-height: 7vh; }
body.wall .grid .hd .dn { font-size: clamp(10px, 1vw, 20px); }
body.wall .grid .hd .dd { font-size: clamp(17px, 1.9vw, 40px); }
body.wall .grid .hd .tag { font-size: clamp(8px, 0.75vw, 16px); height: auto; }
body.wall .grid .sect { font-size: clamp(10px, 0.9vw, 18px); min-height: 3.4vh; }
body.wall .grid .score { font-size: clamp(14px, 1.7vw, 36px); min-height: 7vh; }
body.wall .grid .score small { font-size: clamp(9px, .7vw, 15px); }
body.wall .grid .score.lbl { font-size: clamp(12px, 1.1vw, 22px); }
body.wall .legend { font-size: clamp(11px, 1vw, 20px); gap: 0.6vh 1.6vw; }
body.wall .legend .dot { --cell: clamp(22px, 2.2vw, 44px); }
body.wall .weekbar { display: none; }
@media (orientation: landscape) and (min-width: 1100px) {
  body.wall .layout { display: grid; grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  :root { --cell: 33px; }
  .grid .name { font-size: 12px; gap: 6px; }
  .grid .name .em { width: 22px; flex-basis: 22px; height: 22px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.nil { color: var(--muted); }

@media (max-width: 480px) { .chip { font-size: 12px; gap: 6px; padding: 6px 10px 6px 6px; } .chip .ico { width: 22px; height: 22px; font-size: 12px; } .meter i { width: 7px; height: 7px; } }
.list { padding-bottom: 84px; }

/* wall: whole week fits one screen */
body.wall .grid { --rowh: calc(66vh / var(--rows, 20)); }
body.wall .grid > div { min-height: 0; height: var(--rowh); }
body.wall .grid .hd { height: calc(var(--rowh) * 1.5); min-height: 0; padding-top: 0; }
body.wall .grid .sect { height: calc(var(--rowh) * 0.7); min-height: 0; padding-top: 0; align-items: flex-end; }
body.wall .grid .score { height: calc(var(--rowh) * 1.1); min-height: 0; }
body.wall .dot { width: min(calc(var(--cell) * 0.6), calc(var(--rowh) * 0.78)); height: min(calc(var(--cell) * 0.6), calc(var(--rowh) * 0.78)); font-size: min(calc(var(--cell) * 0.3), calc(var(--rowh) * 0.4)); }
body.wall .legend .dot { width: 1.6vw; height: 1.6vw; min-width: 16px; min-height: 16px; }
body.wall .grid .name { font-size: min(1.6vw, calc(var(--rowh) * 0.52)); }
body.wall .grid .name .em { width: calc(var(--rowh) * 0.72); height: calc(var(--rowh) * 0.72); flex-basis: calc(var(--rowh) * 0.72); min-width: 0; min-height: 0; font-size: calc(var(--rowh) * 0.4); }
body.wall .grid .name .sub { font-size: 0.7em; }
.task .wh .cb { color: var(--muted); font-size: 11.5px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
