:root {
  --bg: #070b17;
  --bg2: #0b1224;
  --surface: #0f1730;
  --surface2: #141e3d;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9edf9;
  --muted: #9aa8cc;
  --cyan: #6ee7ff;
  --violet: #a78bfa;
  --gold: #fbbf24;
  --rose: #fb7185;
  --green: #34d399;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
section { scroll-margin-top: 72px; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(167, 139, 250, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 10%, rgba(110, 231, 255, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--cyan); color: #000; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  backdrop-filter: blur(14px); background: rgba(7, 11, 23, 0.7); border-bottom: 1px solid var(--line);
}
.brand { white-space: nowrap; font-weight: 800; letter-spacing: 0.02em; display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--cyan) 35%, var(--violet));
  box-shadow: 0 0 14px var(--cyan);
}
.topbar nav { display: flex; align-items: center; gap: 14px; }

/* buttons */
.btn {
  white-space: nowrap;
  appearance: none; border: 0; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font: inherit; font-weight: 700; color: #06101f;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 8px 28px rgba(110, 231, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 34px rgba(167, 139, 250, 0.35); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn.big { padding: 16px 28px; font-size: 1.08rem; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(110, 231, 255, 0.12); }
.link { white-space: nowrap; background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 6px; }
.link:hover { color: var(--text); }

/* intro */
.intro { max-width: 760px; margin: 0 auto; padding: 64px 16px 8px; text-align: center; }
.sub { color: #c6d0ee; font-size: 1.1rem; margin: 0 auto 26px; max-width: 54ch; }
.pulse { display: flex; justify-content: center; align-items: center; gap: 8px 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.95rem; }
.pulse-text b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 1.05rem; }
#agenda-toggle { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
#agenda-toggle:hover { border-color: var(--cyan); }
#agenda-toggle .chev { display: inline-block; margin: 0; transition: transform 0.2s; }
#agenda-toggle.open .chev { transform: rotate(180deg); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); animation: ping 1.8s infinite; }
.live.offline { color: var(--muted); }
.live.offline i { background: var(--muted); animation: none; }
h1 { font-size: clamp(2.2rem, 6.5vw, 3.8rem); line-height: 1.06; margin: 0 0 18px; letter-spacing: -0.03em; }
h1 em { font-style: normal; background: linear-gradient(120deg, var(--cyan), var(--violet) 60%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fine { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

/* panels */
.panel { background: linear-gradient(180deg, var(--surface), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.agenda-panel { margin-top: 22px; padding: 22px; text-align: left; animation: rise 0.3s ease both; }
.agenda-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.agenda-head h2 { margin: 0 0 6px; font-size: clamp(1.3rem, 3.2vw, 1.9rem); letter-spacing: -0.02em; }
.narrative { color: #c6d0ee; margin: 0; max-width: 70ch; }
.merging { display: inline-flex; align-items: center; gap: 10px; color: var(--gold); font-size: 0.9rem; background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.25); padding: 6px 12px; border-radius: 999px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(251, 191, 36, 0.3); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }

.agenda-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 12px; }
.item { background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; position: relative; overflow: hidden; animation: rise 0.45s ease both; }
.item-top { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; padding: 0; }
.rank { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: rgba(110, 231, 255, 0.1); color: var(--cyan); border: 1px solid rgba(110, 231, 255, 0.3); }
.item:nth-child(1) .rank { background: linear-gradient(135deg, var(--gold), #f59e0b); color: #241500; border-color: transparent; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 700; font-size: 1.05rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.chev { color: var(--muted); transition: transform 0.2s; flex: none; margin-top: 6px; }
.item.open .chev { transform: rotate(180deg); }
.item-body { display: none; margin: 12px 0 2px 52px; color: #c6d0ee; font-size: 0.95rem; }
.item.open .item-body { display: block; }
.item-body p { margin: 6px 0; }
.tag { display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-right: 6px; }
.tag.action { color: var(--green); }
.tag.tension { color: var(--gold); }
.writing { color: var(--muted); font-style: italic; }
.shimmer { background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.12), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; display: inline-block; min-width: 140px; height: 1em; vertical-align: middle; }

.blocked { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); }
.blocked h3 { margin: 0; font-size: 1rem; color: var(--rose); }
.blocked ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.blocked li { font-size: 0.9rem; color: #f3c4cc; background: rgba(251, 113, 133, 0.07); border: 1px solid rgba(251, 113, 133, 0.2); padding: 8px 12px; border-radius: 10px; }
.blocked li small { display: block; color: var(--muted); }

/* talk */
.talk { max-width: 760px; margin: 0 auto; padding: 28px 16px 72px; }

.chat { overflow: hidden; }
.messages { padding: 18px; display: flex; flex-direction: column; gap: 12px; max-height: min(58vh, 560px); min-height: 160px; overflow-y: auto; scroll-behavior: smooth; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; animation: pop 0.25s ease both; }
.msg.ai { align-self: flex-start; background: var(--surface2); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.ai::before { content: "AI President"; display: block; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan); margin-bottom: 4px; font-weight: 700; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, rgba(110, 231, 255, 0.2), rgba(167, 139, 250, 0.25)); border: 1px solid rgba(167, 139, 250, 0.35); border-top-right-radius: 4px; }
.msg.err { align-self: center; background: rgba(251, 113, 133, 0.1); border: 1px solid rgba(251, 113, 133, 0.3); color: #ffd0d7; font-size: 0.92rem; max-width: 100%; text-align: center; }
.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); opacity: 0.4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

.ts-slot { padding: 0 18px; }
.composer { border-top: 1px solid var(--line); padding: 14px 18px 18px; }
textarea { width: 100%; resize: vertical; min-height: 84px; max-height: 320px; background: rgba(255, 255, 255, 0.04); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font: inherit; font-size: 1rem; }
textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(110, 231, 255, 0.12); }
textarea:disabled { opacity: 0.6; }
.composer-row { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.count { margin-right: auto; }
.count { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

/* result */
.result { margin-top: 22px; padding: 24px; animation: rise 0.5s ease both; }
.result h3 { margin: 0 0 6px; font-size: 1.5rem; letter-spacing: -0.02em; }
.result .block { margin: 16px 0; padding: 14px 16px; border-radius: 14px; background: var(--surface2); border: 1px solid var(--line); }
.result .block h4 { margin: 0 0 6px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--cyan); }
.result .block p { margin: 0; white-space: pre-wrap; }
.result .ai-block { border-color: rgba(167, 139, 250, 0.4); background: linear-gradient(180deg, rgba(167, 139, 250, 0.12), rgba(167, 139, 250, 0.04)); }
.impact { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.impact li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.impact .move { font-weight: 800; white-space: nowrap; color: var(--green); }
.impact .move.new { color: var(--gold); }
.poslist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.poslist li { font-size: 0.95rem; }
.poslist b { color: var(--text); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* dialog */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); max-width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 24px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
dialog h2 { margin-top: 0; }
dialog ol { padding-left: 20px; display: grid; gap: 10px; }
dialog li b { color: var(--cyan); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 820px) {
  .intro { padding-top: 40px; }
  .item-body { margin-left: 0; }
  .msg { max-width: 94%; }
  .composer-row .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
