:root {
  --graphite-950: #14171A;
  --panel-900: #1B1F24;
  --panel-850: #20242A;
  --hairline: #2A2F36;
  --ink-100: #E8EAED;
  --ink-400: #8B939C;
  --ink-600: #5C636C;
  --rec-red: #FF4D4F;
  --rec-red-dim: #7A2426;
  --tape-amber: #E8B94D;
  --tape-amber-dim: #6B5A2C;

  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--graphite-950);
  color: var(--ink-100);
  font-family: var(--font-body);
}

.hidden { display: none !important; }
.muted { color: var(--ink-400); }
.small { font-size: 0.82rem; }
.error { color: var(--rec-red); }

h1, h2, h3 {
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  margin: 0;
}

/* --- reel signature element --- */
.reel {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--tape-amber);
  position: relative;
  flex-shrink: 0;
  background:
    radial-gradient(circle at center, var(--panel-900) 0 30%, transparent 31%),
    conic-gradient(var(--hairline) 0 25%, var(--panel-850) 0 50%, var(--hairline) 0 75%, var(--panel-850) 0 100%);
}
.reel.small { width: 28px; height: 28px; border-width: 2px; }

/* --- gate / login screen --- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, #1c2127 0%, var(--graphite-950) 60%);
}
.gate-card {
  background: var(--panel-900);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 40px;
  width: min(360px, 90vw);
  text-align: center;
}
.gate-card .reel { margin: 0 auto 20px; }
.gate-card h1 { font-size: 1.6rem; color: var(--ink-100); margin-bottom: 8px; }
.gate-card p { margin: 4px 0 20px; }
#gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#gate-error { margin-top: 12px; }

input, textarea, select {
  background: var(--panel-850);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--ink-100);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--tape-amber);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-size: 0.9rem;
}
button:focus-visible { outline: 2px solid var(--tape-amber); outline-offset: 2px; }

.btn-amber {
  background: var(--tape-amber);
  color: #1a1305;
}
.btn-amber:hover { background: #f0c565; }
.btn-amber:disabled { background: var(--tape-amber-dim); color: #a89050; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-100);
  border-color: var(--hairline);
}
.btn-ghost:hover { border-color: var(--ink-400); }

.btn-small { padding: 6px 10px; font-size: 0.8rem; }

/* --- app shell --- */
.app { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel-900);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.15rem; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.rec-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-400);
  padding: 6px 12px;
  border: 1px solid var(--hairline);
  border-radius: 20px;
}
.dot-static, .dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-600);
  display: inline-block;
}
.rec-summary.active .dot-static { background: var(--rec-red); }

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  padding: 24px 28px 60px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel-900);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
}
.panel-header h2 { font-size: 0.95rem; color: var(--ink-100); }

/* --- guild sections --- */
.guild-block { border-bottom: 1px solid var(--hairline); }
.guild-block:last-child { border-bottom: none; }
.guild-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  background: var(--panel-850);
}
.guild-title:hover { background: #23282f; }
.guild-title .chev { transition: transform 0.15s ease; color: var(--ink-400); font-size: 0.75rem; }
.guild-block.collapsed .chev { transform: rotate(-90deg); }
.guild-title .name { font-weight: 600; }
.guild-title .count { color: var(--ink-400); font-size: 0.8rem; font-family: var(--font-mono); }

.channel-rows { }
.guild-block.collapsed .channel-rows { display: none; }

.channel-row {
  display: grid;
  grid-template-columns: 22px 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 20px 10px 36px;
  border-top: 1px solid var(--hairline);
}
.channel-row .hash { color: var(--ink-600); font-family: var(--font-mono); }
.channel-row .cname { font-family: var(--font-mono); font-size: 0.9rem; }

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-400);
  min-width: 108px;
}
.rec-indicator .dot-live {
  animation: pulse 1.6s ease-in-out infinite;
  background: var(--rec-red);
}
.rec-indicator.off .dot-live {
  animation: none;
  background: var(--ink-600);
}
.rec-indicator .counter { font-variant-numeric: tabular-nums; }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,77,79,0.5); }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px rgba(255,77,79,0); }
}
@media (prefers-reduced-motion: reduce) {
  .rec-indicator .dot-live { animation: none; }
}

/* toggle switch */
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--hairline);
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-100);
  transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--rec-red-dim); }
.switch input:checked + .track .thumb { transform: translateX(18px); background: var(--rec-red); }
.switch input:disabled + .track { opacity: 0.5; cursor: not-allowed; }

.view-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--tape-amber);
  background: none;
  border: none;
  padding: 4px 6px;
  text-decoration: none;
}
.view-link:hover { text-decoration: underline; }
.view-link:disabled { color: var(--ink-600); cursor: not-allowed; text-decoration: none; }

/* --- send panel --- */
.send-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px 20px;
}
.send-form label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 8px;
}
.send-form textarea { font-family: var(--font-mono); resize: vertical; }
.char-count { text-align: right; font-size: 0.75rem; color: var(--ink-600); font-family: var(--font-mono); }
.send-form button { margin-top: 12px; }
#send-status { min-height: 1.2em; }

/* --- transcript drawer --- */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.drawer-panel {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: min(640px, 92vw);
  background: var(--panel-900);
  border-left: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
}
.drawer-header h3 { font-size: 0.95rem; }
.drawer-actions { display: flex; gap: 8px; }
.drawer-content {
  flex: 1;
  margin: 0;
  padding: 18px 20px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-100);
}
