/* Layout + components. Colours/fonts/sizes ONLY from theme.css tokens. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
svg.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shell: phone first ---------- */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--space-3);
  padding: calc(env(safe-area-inset-top) + var(--space-3)) var(--space-4) var(--space-3);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 600; font-size: var(--text-lg); flex: 1; }

.mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-strong); color: var(--on-accent);
  font-family: var(--font-display); font-size: 17px; letter-spacing: 0.5px;
}

main {
  flex: 1;
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-5));
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar a.on { color: var(--accent-strong); }

/* ---------- Laptop / office screen ---------- */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column; gap: var(--space-1);
    position: sticky; top: 0; height: 100vh;
    padding: var(--space-5) var(--space-4);
    background: var(--sidebar);
  }
  .sidebar .brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2) var(--space-5); }
  .sidebar .brand b { display: block; font-size: var(--text-base); }
  .sidebar .brand span { display: block; font-size: var(--text-sm); color: var(--muted); }
  .sidebar a {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 10px var(--space-3); border-radius: var(--radius-control);
    color: var(--text); text-decoration: none; font-weight: 500;
  }
  .sidebar a:hover { background: var(--card); }
  .sidebar a.on { background: var(--card); color: var(--accent-strong); }
  .sidebar .grow { flex: 1; }
  .sidebar .foot { font-size: var(--text-sm); color: var(--muted); padding: 0 var(--space-3); }
  .page { display: flex; flex-direction: column; min-width: 0; }
  .topbar { padding: var(--space-5) var(--space-6) var(--space-4); border-bottom: 0; }
  .topbar .mark { display: none; }
  .topbar .title { font-size: var(--text-xl); font-family: var(--font-display); font-weight: 400; }
  main { margin: 0; padding: 0 var(--space-6) var(--space-6); }
  .tabbar { display: none; }
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 900px) { .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: var(--space-5);
}
.card h2 { margin: 0 0 var(--space-1); font-size: var(--text-lg); font-weight: 600; }
.card p { margin: 0; color: var(--muted); }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card .head p { font-size: var(--text-sm); }

.welcome { display: flex; flex-direction: column; gap: var(--space-2); }
.welcome .hello { font-family: var(--font-display); font-size: var(--text-big); line-height: 1.1; margin: 0; }
.welcome .date { color: var(--muted); }
.welcome .note { margin-top: var(--space-2); }

/* status rows */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; padding-top: 0; }
.row .label { flex: 1; }
.row .label small { display: block; color: var(--muted); font-size: var(--text-sm); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: var(--text-sm); font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-tint); color: var(--good-text); }
.pill.watch { background: var(--watch-tint); color: var(--watch-text); }
.pill.bad { background: var(--bad-tint); color: var(--bad-text); }
.pill.wait { background: var(--track); color: var(--muted); }

/* sync cloud */
.cloud {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card);
  padding: 6px 12px; border-radius: var(--radius-pill);
  font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.cloud.good { color: var(--good-text); }
.cloud.watch { color: var(--watch-text); }
.cloud.off { color: var(--muted); }

/* forms + buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius-control);
  background: var(--accent-strong); color: var(--on-accent);
  font-weight: 600; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent-strong); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }
.field { display: flex; gap: var(--space-2); }
.field input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--bg);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.err { color: var(--bad-text); font-size: var(--text-sm); margin-top: var(--space-2); min-height: 1em; }

.saves { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.saves li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.saves li span.t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saves li time { color: var(--muted); font-size: var(--text-sm); }
.empty { color: var(--muted); font-size: var(--text-sm); margin-top: var(--space-3); }

.soon { text-align: center; padding: var(--space-6) var(--space-5); }
.soon .big { font-family: var(--font-display); font-size: var(--text-xl); margin: 0 0 var(--space-2); }
.hidden { display: none !important; }
