:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: rgba(100, 116, 139, 0.28);
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --danger: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card: #111827;
    --fg: #f1f5f9;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.24);
    --accent: #6366f1;
    --accent-fg: #ffffff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }

.banner {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #f59e0b;
  padding: .5rem .85rem;
  font-size: .84rem;
  font-weight: 600;
  text-align: center;
}

.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card h1 { margin: 0 0 .25rem; font-size: 1.5rem; }

.auth-card .tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  margin: .85rem 0;
}

.auth-card .tabs button {
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: inherit;
  cursor: pointer;
  font-weight: 500;
}

.auth-card .tabs button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.auth-msg {
  margin: .75rem 0 0;
  padding: .6rem .75rem;
  border-radius: 8px;
  font-size: .86rem;
  background: rgba(220, 38, 38, 0.14);
  color: #ef4444;
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.auth-msg.ok {
  background: rgba(22, 163, 74, 0.14);
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.35);
}

.top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

#view {
  max-width: 760px;
  margin: 0 auto;
  padding: .9rem .9rem calc(5.2rem + env(safe-area-inset-bottom));
}

.bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .5rem .25rem;
  text-decoration: none;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 500;
}

.bottom a i { font-style: normal; font-size: 1.15rem; }
.bottom a.on { color: var(--accent); font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .95rem;
}

.stack { display: grid; gap: .7rem; }
.empty { text-align: center; padding: 2rem 1rem; }
.small { font-size: .82rem; }
.muted { color: var(--muted); }

label {
  display: grid;
  gap: .3rem;
  font-size: .88rem;
  font-weight: 500;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
textarea,
select,
.input {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}

input:focus, textarea:focus, select:focus, .input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .52rem .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.ghost { background: transparent; }

.badges { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; }
.badges span {
  font-size: .8rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.14);
  color: var(--accent);
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 420px);
  padding: .6rem .95rem;
  border-radius: 10px;
  background: #1e293b;
  color: #f8fafc;
  font-size: .88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.toast.err { background: #b91c1c; color: #fff; }

dialog {
  background: var(--card);
  color: var(--fg);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
