:root {
  --bg: #0a0f1a;
  --bg-elev: #121a2a;
  --bg-elev-2: #1a2436;
  --line: #223049;
  --text: #e8eef8;
  --muted: #8494ad;
  --accent: #4d8dff;
  --accent-soft: rgba(77, 141, 255, 0.14);
  --good: #35d07f;
  --good-soft: rgba(53, 208, 127, 0.15);
  --warn: #f5b942;
  --warn-soft: rgba(245, 185, 66, 0.15);
  --bad: #ff5f6d;
  --bad-soft: rgba(255, 95, 109, 0.14);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Bez tohoto by display z tříd níž přebil atribut hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* Gradient jako samostatná fixní vrstva — background-attachment: fixed dělá
   na mobilech artefakty při scrollu a iOS Safari ho stejně ignoruje. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 60% at 50% 0%, #142138 0%, var(--bg) 55%);
  pointer-events: none;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.3rem; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center-text { text-align: center; }
.hint { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.error {
  color: var(--bad);
  font-size: 0.86rem;
  background: var(--bad-soft);
  border: 1px solid rgba(255, 95, 109, 0.3);
  padding: 10px 12px;
  border-radius: 12px;
}

/* ── Layout ─────────────────────────────── */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.screen { min-height: 100dvh; }
.screen.center { display: grid; place-items: center; padding: 24px; }

.pad { padding: 16px 16px 120px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
.narrow { width: 108px; flex-shrink: 0; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-top) + 14px) 16px 12px;
  background: rgba(10, 15, 26, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title { font-size: 0.95rem; color: var(--text); }

/* ── Formuláře ──────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.8rem; color: var(--muted); font-weight: 550; }

input[type=text], input[type=password], input[type=date], input[type=number], textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem; /* pod 16px iOS při fokusu zoomuje stránku */
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  resize: vertical;
  -webkit-appearance: none;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=date] { min-height: 48px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04101f; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn.danger { color: var(--bad); border-color: rgba(255, 95, 109, 0.3); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ── Login ──────────────────────────────── */
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 4px; }
.brand-ring {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  font-weight: 700; font-size: 1.15rem; color: var(--accent);
  margin-bottom: 6px;
}

/* ── Dnešek ─────────────────────────────── */
.hero { display: flex; flex-direction: column; gap: 14px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-day { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.hero-day small { font-size: 0.95rem; font-weight: 550; color: var(--muted); }

.ring { position: relative; width: 74px; height: 74px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-bg { stroke: var(--bg-elev-2); }
.ring-fg { stroke: var(--good); stroke-dasharray: 264; stroke-dashoffset: 264; transition: stroke-dashoffset 0.5s ease; }
.ring span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.85rem; font-weight: 700;
}

.progress { height: 8px; border-radius: 99px; background: var(--bg-elev-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--good)); transition: width 0.4s ease; }

.activity {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  font: inherit; color: var(--text);
}
.activity:active { transform: scale(0.99); }
.activity .check {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  font-size: 0.9rem; color: transparent;
  transition: all 0.18s ease;
}
.activity .label { font-weight: 550; line-height: 1.3; }
.activity.on { border-color: rgba(53, 208, 127, 0.5); background: var(--good-soft); }
.activity.on .check { background: var(--good); border-color: var(--good); color: #04101f; }
.activity[disabled] { opacity: 0.45; cursor: default; }

.banner-off { border-color: rgba(245, 185, 66, 0.35); background: var(--warn-soft); display: flex; flex-direction: column; gap: 4px; }

.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 99px; margin-bottom: 6px; }
.tag-good { background: var(--good-soft); color: var(--good); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }

.save-state { font-size: 0.75rem; color: var(--muted); min-width: 62px; text-align: right; transition: opacity 0.3s ease; }
.save-state.saved { color: var(--good); }

/* ── Statistiky ─────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); padding: 1px; }
.stat {
  background: var(--bg-elev);
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 0.75rem; color: var(--muted); line-height: 1.25; }
.stat.wide { grid-column: 1 / -1; }
.stat.wide .stat-value { font-size: 2.2rem; }
.stat-value.good { color: var(--good); }
.stat-value.bad { color: var(--bad); }
.stat-value.warn { color: var(--warn); }

.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; }
.bar-head .name { font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-head .val { color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 99px; background: var(--bg-elev-2); overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.4s ease; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 0.75rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot-done { background: var(--good); }
.dot-partial { background: var(--warn); }
.dot-missed { background: var(--bad); }
.dot-off { background: var(--muted); }
.dot-future { background: var(--bg-elev-2); border: 1px solid var(--line); }

.grid90 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cell {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.cell.done { background: var(--good); border-color: var(--good); color: #04101f; }
.cell.partial { background: var(--warn); border-color: var(--warn); color: #1a1200; }
.cell.missed { background: var(--bad); border-color: var(--bad); color: #22060a; }
.cell.off { background: transparent; border-style: dashed; border-color: var(--muted); color: var(--muted); }
.cell.today { box-shadow: 0 0 0 2px var(--accent); }
.cell.future { opacity: 0.55; }

.deflist { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 0.88rem; }
.deflist dt { color: var(--muted); }
.deflist dd { margin: 0; }

.archive-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }

/* ── Tabbar ─────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 8px calc(var(--safe-bottom) + 8px);
  background: rgba(10, 15, 26, 0.9);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  background: none; border: none; border-radius: 12px;
  color: var(--muted); font: inherit; font-size: 0.72rem; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tab-icon { font-size: 1.1rem; line-height: 1.1; }
.tab.active { color: var(--accent); }

/* ── Bottom sheet ───────────────────────── */
.backdrop { position: fixed; inset: 0; background: rgba(4, 8, 15, 0.65); z-index: 40; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 88dvh; overflow-y: auto;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(var(--safe-bottom) + 24px);
  animation: rise 0.24s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 10px; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; }
.sheet-body { padding-bottom: 8px; }
.sheet .activity { background: var(--bg-elev-2); }

/* ── Toast ──────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); z-index: 60;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 0.85rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  animation: rise 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.bad { border-color: rgba(255, 95, 109, 0.4); color: var(--bad); }

@media (min-width: 640px) {
  .screen { max-width: 560px; margin: 0 auto; }
  .tabbar { max-width: 560px; left: 50%; transform: translateX(-50%); }
  .sheet { max-width: 560px; left: 50%; transform: translateX(-50%); border-radius: 20px 20px 0 0; }
}
