:root {
  --bg: #0b1220;
  --surface: #121b2e;
  --surface-2: #19243b;
  --line: #24314d;
  --text: #e8edf6;
  --muted: #94a3bf;
  --accent: #39d0c8;
  --accent-ink: #062523;
  --red: #ff6b6b;
  --yellow: #f2c14e;
  --green: #4cc38a;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --line: #dbe2ec;
    --text: #0f1a2b;
    --muted: #5b6b85;
    --accent: #0f9d95;
    --accent-ink: #ffffff;
    --red: #d64545;
    --yellow: #b8860b;
    --green: #2f9e6a;
    --shadow: 0 6px 18px rgba(15, 26, 43, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 0.18em; font-weight: 700; }
.sub { margin: 0; font-size: 13px; color: var(--muted); }

.iris {
  width: 34px; height: 34px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--bg) 0 22%, transparent 23%),
    radial-gradient(circle at 50% 50%, var(--accent) 0 46%, color-mix(in srgb, var(--accent) 35%, transparent) 47% 70%, transparent 71%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: box-shadow 0.4s, filter 0.4s;
}
.iris.alert { --accent: var(--red); animation: pulse 2.2s ease-in-out infinite; }
.iris.offline { filter: grayscale(1) opacity(0.5); box-shadow: none; }
@keyframes pulse { 50% { box-shadow: 0 0 28px color-mix(in srgb, var(--red) 70%, transparent); } }
@media (prefers-reduced-motion: reduce) { .iris.alert { animation: none; } }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.96); }

.banner {
  margin: 4px 16px 0; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--yellow) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--yellow) 40%, var(--line));
  font-size: 14px;
}
.banner button { margin-left: 8px; }

.lanes {
  display: flex; gap: 8px; padding: 10px 16px 6px; overflow-x: auto;
  position: sticky; top: calc(66px + env(safe-area-inset-top)); z-index: 4; background: var(--bg);
}
.lanes button {
  flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 15px;
}
.lanes button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.count {
  display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--surface-2); color: var(--text);
  font-size: 13px; text-align: center;
}
.lanes button[aria-selected="true"] .count { background: var(--accent); color: var(--accent-ink); }

.list { display: grid; gap: 12px; padding: 8px 16px 16px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.card {
  position: relative; padding: 14px 14px 14px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--green); }
.card.tier-yellow::before { background: var(--yellow); }
.card.tier-red::before { background: var(--red); }
.meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.pill { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); }
.card h2 { margin: 0 0 4px; font-size: 17px; line-height: 1.3; }
.card .body { margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; color: color-mix(in srgb, var(--text) 85%, var(--muted)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.other { display: grid; gap: 8px; margin-top: 10px; }
.other textarea, .compose textarea {
  width: 100%; resize: none; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); padding: 10px 12px; min-height: 44px; max-height: 40vh;
}
.answered { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.answered b { color: var(--accent); }
.wake { display: block; margin-top: 4px; color: var(--muted); font-size: 12.5px; }

.compose {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.compose textarea { flex: 1; }
.send { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.mic.listening { color: var(--red); border-color: var(--red); }

.sheet { border: 0; padding: 0; background: transparent; width: min(560px, 100vw); max-width: 100vw; margin: auto auto 0; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.5); }
.sheet-inner { background: var(--surface); color: var(--text); border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.sheet h3 { margin: 16px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.muted { color: var(--muted); margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 10;
  font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
