:root {
  --bg-0: #0b1020;
  --bg-1: #131a33;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #eef2ff;
  --muted: #9aa4c7;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --ok: #34d399;
  --danger: #fb7185;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --radius: 20px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(124, 92, 255, 0.28), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(34, 211, 238, 0.20), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, rgba(244, 114, 182, 0.16), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 26px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: clamp(18px, 4.5vw, 24px);
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.5);
  font-size: 22px;
}

.brand small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}
.pill:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.28); }

.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
}
.status-dot.online {
  background: var(--ok);
  animation: pulse 2s infinite;
}
.status-dot.offline { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel { padding: clamp(18px, 4vw, 30px); }

h1 { font-size: clamp(22px, 6vw, 34px); margin: 0 0 6px; line-height: 1.15; }
.subtitle { color: var(--muted); margin: 0; font-size: 15px; line-height: 1.5; }

/* ---------- Main display ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.now-playing {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 5vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 180px;
}
.now-playing::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(120deg, transparent, rgba(124,92,255,0.10), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.now-playing.speaking::before { opacity: 1; animation: sweep 2.2s linear infinite; }
@keyframes sweep { 0% { transform: translateX(-40%);} 100% { transform: translateX(40%);} }

.np-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted); font-weight: 700;
}

.equalizer { display: inline-flex; gap: 3px; height: 16px; align-items: flex-end; opacity: 0.35; }
.equalizer span { width: 3px; height: 6px; background: var(--accent-2); border-radius: 2px; }
.now-playing.speaking .equalizer { opacity: 1; }
.now-playing.speaking .equalizer span { animation: eq 0.9s ease-in-out infinite; }
.equalizer span:nth-child(2){ animation-delay: 0.15s; }
.equalizer span:nth-child(3){ animation-delay: 0.30s; }
.equalizer span:nth-child(4){ animation-delay: 0.45s; }
@keyframes eq { 0%,100%{ height:5px;} 50%{ height:16px;} }

.np-text {
  font-size: clamp(20px, 5.2vw, 34px);
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.np-text.empty { color: var(--muted); font-weight: 500; font-size: clamp(16px, 4vw, 20px); }

.np-time { font-size: 13px; color: var(--muted); }

.feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 42vh;
  padding-right: 4px;
}
.feed-title {
  font-size: 13px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin: 4px 2px;
}

.msg {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  animation: pop 0.35s ease;
}
.msg.fresh { border-color: rgba(124,92,255,0.55); box-shadow: 0 0 0 1px rgba(124,92,255,0.25); }
.msg .m-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.msg .m-meta {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; font-size: 12px; color: var(--muted);
}
.msg .replay {
  margin-left: auto; cursor: pointer; border: none; background: transparent;
  color: var(--accent-2); font-weight: 700; font-size: 12px; padding: 2px 6px; border-radius: 8px;
}
.msg .replay:hover { background: rgba(34,211,238,0.12); }
@keyframes pop { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

/* Controls */
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #0b1020;
  box-shadow: 0 12px 26px rgba(124, 92, 255, 0.4);
}
.btn.ghost.active { border-color: var(--ok); color: var(--ok); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.select-wrap { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select {
  background: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  max-width: 200px;
}

/* Overlay to unlock audio */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(6, 9, 20, 0.72);
  backdrop-filter: blur(8px);
  padding: 24px;
  text-align: center;
}
.overlay.hidden { display: none; }
.overlay .card { max-width: 420px; padding: 32px 26px; }
.overlay h2 { margin: 14px 0 8px; font-size: 22px; }
.overlay p { color: var(--muted); margin: 0 0 22px; line-height: 1.55; }
.overlay .big-icon {
  width: 68px; height: 68px; border-radius: 20px; margin: 0 auto;
  display: grid; place-items: center; font-size: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: 0 16px 34px rgba(124,92,255,0.5);
}

/* ---------- Post form ---------- */
.field { display: flex; flex-direction: column; gap: 10px; }
label { font-weight: 700; font-size: 14px; }
textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  color: var(--text);
  padding: 16px;
  font-size: 16px;
  line-height: 1.55;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18);
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.counter { color: var(--muted); font-size: 13px; }

.toast {
  padding: 13px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  display: none; align-items: center; gap: 10px;
}
.toast.show { display: flex; animation: pop 0.3s ease; }
.toast.ok { background: rgba(52,211,153,0.14); border: 1px solid rgba(52,211,153,0.4); color: var(--ok); }
.toast.err { background: rgba(251,113,133,0.14); border: 1px solid rgba(251,113,133,0.4); color: var(--danger); }

.hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
code.inline {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--card-border);
  padding: 2px 7px; border-radius: 7px; font-size: 13px;
  word-break: break-all;
}
.codeblock {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: #cbd5ff;
}

.footer { text-align: center; color: var(--muted); font-size: 12px; padding-top: 6px; }
.footer a { color: var(--accent-2); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 520px) {
  .brand small { display: none; }
  .feed { max-height: 38vh; }
}
