/* ─── Design Tokens ─────────────────────────────────────────── */
:root {
  --bg:        #f5f1eb;
  --surface:   rgba(245, 241, 235, 0.97);
  --line:      #a09890;
  --line-soft: rgba(60, 50, 40, 0.11);
  --text:      #1a1816;
  --muted:     #7a6e65;
  --green:     #5d8a35;

  --stage-h:    148px;
  --max-w:      680px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; min-width: 0; }

html {
  zoom: 1.5;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

button, input, textarea { font: inherit; }

/* ─── Stage ──────────────────────────────────────────────────── */
.stage {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  backdrop-filter: blur(12px);
  max-width: 100%;
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 6px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}

.stage-top-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2.4s ease-in-out infinite;
}

.live-dot.offline { background: var(--line); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.live-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
}

.live-label.offline { color: var(--muted); }

/* Stage body: show info + play button */
.stage-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px 10px;
}

.stage-info { flex: 1; overflow: hidden; }

.stage-show {
  font-size: 17px;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  font-weight: 500;
}

.stage-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.stage-host { overflow: hidden; text-overflow: ellipsis; }
.stage-sep  { flex: 0 0 auto; opacity: 0.5; }
.stage-time { flex: 0 0 auto; }

/* Play button */
.play-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  position: relative;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s;
}

.play-btn:hover { border-color: var(--text); }

.play-btn::before {
  content: "";
  position: absolute;
  left: 12px; top: 10px;
  width: 0; height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid var(--text);
}

.play-btn.playing::before {
  border: 0;
  left: 10px; top: 9px;
  width: 14px; height: 18px;
  background: linear-gradient(to right,
    var(--text) 4px, transparent 4px,
    transparent 10px, var(--text) 10px);
}

.play-btn.loading::before {
  border: 2px solid var(--line-soft);
  border-top-color: var(--text);
  border-radius: 50%;
  width: 16px; height: 16px;
  left: 9px; top: 9px;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Stage tabs */
.stage-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-top: 1px solid var(--line-soft);
}

.tab-btn {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 14px 6px;
  transition: color 0.12s, border-color 0.12s;
}

.tab-btn:first-child { padding-left: 0; }

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--text); }

/* ─── Info Panel (drops below stage) ────────────────────────── */
.info-panel {
  flex: 0 0 auto;
  display: none;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  backdrop-filter: blur(14px);
  max-width: 100%;
}

.info-panel.open { display: block; }

.info-body {
  display: grid;
  gap: 0;
  padding: 4px 20px 14px;
  max-width: var(--max-w);
  margin: 0 auto;
}

.panel-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.panel-section:last-child { border-bottom: 0; }

.panel-title {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.panel-copy { font-size: 13px; line-height: 1.45; }
.panel-copy.small { font-size: 11px; color: var(--muted); }

/* ─── Chat ───────────────────────────────────────────────────── */
.chat-main {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px 9px;
  border-bottom: 1px solid var(--line-soft);
}

.channel-name {
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  color: var(--muted);
}

.online-count {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-feed {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 4px 0 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-loading {
  padding: 18px 20px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── Messages ───────────────────────────────────────────────── */
.msg {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 0 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  line-height: 1.6;
}

.msg:last-child { border-bottom: 0; }

.msg-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 2px;
  gap: 3px;
}

.msg-time {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.msg-user {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58px;
}

.msg-body { min-width: 0; }
.msg-text { word-break: break-word; color: var(--text); }

.msg-actions { display: none; margin-top: 4px; }
body.is-admin .msg-actions { display: block; }

.msg-delete {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}

.msg-delete:hover { color: var(--text); }

/* ─── Composer ───────────────────────────────────────────────── */
.composer {
  flex: 0 0 auto;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
}

.chatbox {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
  transition: border-color 0.15s;
  overflow: hidden;
}

.chatbox:focus-within { border-color: var(--text); }

.chatbox-input {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 14px 4px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 110px;
  overflow-y: auto;
}

.chatbox-input::placeholder { color: var(--muted); }

.chatbox-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 10px 8px;
}

.chatbox-send {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--text);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 3px 0;
  transition: opacity 0.15s;
}

.chatbox-send:hover   { opacity: 0.5; }
.chatbox-send:disabled { opacity: 0.3; cursor: not-allowed; }

.join-box {
  flex-direction: row;
  align-items: center;
  padding: 0 14px 0 0;
}

.join-box .chatbox-input {
  flex: 1;
  padding: 12px 10px 12px 14px;
  min-height: unset;
  max-height: unset;
}

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  html { zoom: 1; }

  :root { --stage-h: 136px; }

  .stage-top  { padding: 8px 14px 5px; }
  .stage-body { padding: 10px 14px 8px; }
  .stage-tabs { padding: 0 14px; }
  .stage-show { font-size: 15px; }

  .info-body  { padding: 4px 14px 12px; }

  .chat-header { padding: 9px 14px 7px; }
  .channel-name { font-size: 12px; }

  .msg { grid-template-columns: 50px minmax(0, 1fr); gap: 0 10px; padding: 10px 14px; font-size: 13px; }
  .msg-time { font-size: 9px; }
  .msg-user { font-size: 9px; max-width: 50px; }

  .composer { padding: 10px 14px 16px; }
  .chatbox-input { font-size: 14px; }
}
