:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #21252e;
  --border: #2c313c;
  --text: #e8eaef;
  --muted: #9aa1ad;
  --accent: #7dd3fc;
  --primary: #38bdf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f3; --border: #dde1e7;
    --text: #14171c; --muted: #5d6573; --accent: #0369a1; --primary: #0284c7;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--safe-bottom);
  overscroll-behavior-y: contain;
}
#root { max-width: 720px; margin: 0 auto; min-height: 100vh; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
}
textarea { resize: vertical; }
.btn {
  border: 1px solid var(--border); background: var(--surface-2);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #001018; font-weight: 600; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-sm { padding: 5px 10px; font-size: 14px; }

/* navbar */
.navbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 10px) 12px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.navbar h1 { flex: 1; font-size: 19px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-back { font-size: 30px; line-height: 1; text-decoration: none; color: var(--accent); background: none; border: 0; padding: 0 6px; cursor: pointer; }
.nav-actions { display: flex; gap: 6px; }

/* generic content */
.content { padding: 12px 14px 80px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px 0; scrollbar-width: none; }
.tabs button { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tabs button.active { background: var(--primary); color: #001018; border-color: var(--primary); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--safe-bottom) + 18px); width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--primary); color: #001018; font-size: 30px; box-shadow: 0 6px 20px #0006; cursor: pointer;
}
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar.over > span { background: var(--danger); }
.stale { font-size: 12px; color: var(--warn); padding: 6px 14px 0; }
a.tag, a.wikilink { text-decoration: none; }
a.tag { color: var(--warn); }

/* home */
.home { padding: calc(var(--safe-top) + 24px) 18px 40px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.home-head h1 { margin: 0; font-size: 30px; }
.home-date { margin: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.tile-icon { width: 62px; height: 62px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; color: #fff; font-weight: 700; }
.tile-name { font-size: 13px; }
.queue-badge { font-size: 12px; color: var(--warn); }
.logout { margin-top: 40px; }

/* login */
.login { display: flex; flex-direction: column; gap: 12px; max-width: 320px; margin: 0 auto; padding: 22vh 20px 0; text-align: center; }
.login h1 { margin: 0 0 8px; }
.login-logo { font-size: 46px; color: var(--accent); }
.login-msg { color: var(--danger); min-height: 1.4em; }

/* sheets & toasts */
.sheet-wrap { position: fixed; inset: 0; background: #0008; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(var(--safe-bottom) + 16px); animation: up .18s ease-out;
}
.sheet h3 { margin: 0 0 12px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translate(-50%, 20px); opacity: 0;
  background: var(--surface-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 12px; z-index: 200; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { border-color: var(--danger); }
