/*
 * rooms.css — episode rooms (studio.stingofsweden.com).
 * Same language as web/guest/guest-theme.css and the iPad app: the show's studio
 * palette behind everything, frosted glass, capsule buttons, SF system fonts.
 * The tokens mirror guest-theme.css; keep them in step when the look changes.
 */

:root {
  --show-base1: #2b4a70;
  --show-base2: #17263b;
  --show-key: #9cc2ff;
  --show-fill: #7a5cff;
  --show-accent: #d8392f;

  --glass: rgba(255, 255, 255, 0.10);
  --glass-strong: rgba(255, 255, 255, 0.16);
  --glass-edge: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --text: #f5f6fa;
  --text-dim: rgba(245, 246, 250, 0.66);
  --text-faint: rgba(245, 246, 250, 0.44);
  --ok: #30d158;
  --warn: #ff9f0a;
  --danger: #ff453a;
  --radius-s: 12px;
  --radius-m: 14px;
  --radius-l: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--show-base2);
  background-image:
    radial-gradient(60% 55% at 30% 20%, color-mix(in srgb, var(--show-key) 32%, transparent) 0%, transparent 70%),
    radial-gradient(55% 50% at 85% 90%, color-mix(in srgb, var(--show-fill) 22%, transparent) 0%, transparent 70%),
    linear-gradient(135deg, var(--show-base1), var(--show-base2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--show-key); }
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
h1 { font-size: 22px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 700; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-l);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
}

/* ---------- Page frame ---------- */

.page { max-width: 760px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
.center-card { max-width: 440px; margin: 12vh auto 0; padding: 28px 24px; text-align: center; }
.center-card p { margin: 10px 0 0; }

.eyebrow { font: 700 11px/1 var(--font); letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); }

/* ---------- Buttons and fields ---------- */

.btn {
  appearance: none; border: 0;
  font: 600 14px/1 var(--font); color: var(--text);
  background: var(--glass-strong);
  border-radius: 999px; min-height: 40px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--show-accent); color: #fff; }
.btn.plain { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.icon { width: 44px; min-height: 44px; padding: 0; }
.btn svg { width: 20px; height: 20px; flex: none; }

.field, textarea, input[type=text], input[type=email], input[type=date], input[type=password], select {
  width: 100%;
  font: 15px/1.4 var(--font); color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  outline: none;
}
textarea:focus, input:focus, select:focus { border-color: color-mix(in srgb, var(--show-key) 70%, transparent); }
label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }

/* ---------- Episode list ---------- */

.episodes { display: grid; gap: 10px; margin-top: 18px; }
.episode {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; color: var(--text); text-decoration: none;
}
.episode .date { min-width: 52px; text-align: center; }
.episode .date b { display: block; font: 700 22px/1 var(--font-display); }
.episode .date span { font-size: 12px; color: var(--text-dim); text-transform: uppercase; }
.episode .what { flex: 1; min-width: 0; }
.episode .what div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { font: 600 11px/1 var(--font); padding: 4px 8px; border-radius: 999px; background: var(--glass-strong); color: var(--text-dim); }
.badge.cohost, .badge.host { background: color-mix(in srgb, var(--show-accent) 70%, transparent); color: #fff; }

/* ---------- Room ---------- */

.room { display: flex; flex-direction: column; height: 100dvh; max-width: 860px; margin: 0 auto; }
.room-head { margin: calc(10px + var(--safe-top)) 12px 0; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.room-head .titles { flex: 1; min-width: 0; }
.room-head .titles div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-head h1 { font-size: 18px; }

.tabs { display: flex; justify-content: center; margin: 10px 12px 0; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.24); gap: 2px; }
.segmented button {
  appearance: none; border: 0; background: transparent; color: var(--text-dim);
  font: 600 13px/1 var(--font); padding: 9px 16px; border-radius: 999px; cursor: pointer;
}
.segmented button.active { background: var(--glass-strong); color: var(--text); }

.pane { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 8px; }

.notice { margin: 10px 12px 0; padding: 10px 14px; font-size: 13px; color: var(--text-dim); text-align: center; }

/* Chat */
.messages { display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; margin: 12px 0 4px; font: 600 12px/1 var(--font); color: var(--text-faint); }
.msg { max-width: min(78%, 560px); align-self: flex-start; }
.msg.mine { align-self: flex-end; }
.msg .who { font-size: 12px; color: var(--text-dim); margin: 6px 12px 3px; }
.msg.mine .who { text-align: right; }
.bubble {
  padding: 9px 13px; border-radius: 18px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mine .bubble { background: color-mix(in srgb, var(--show-accent) 82%, transparent); border-color: transparent; color: #fff; }
.msg.mine .bubble a { color: #fff; }
.bubble .meta { display: block; margin-top: 4px; font-size: 11px; opacity: 0.7; text-align: right; }
.bubble .quote { display: block; font-size: 12px; opacity: 0.8; border-left: 2px solid currentColor; padding-left: 8px; margin-bottom: 6px; }
.bubble.deleted { font-style: italic; opacity: 0.6; }
.msg .actions { display: none; gap: 2px; margin: 2px 6px 0; }
.msg.mine .actions { justify-content: flex-end; }
.msg:hover .actions, .msg.show-actions .actions { display: flex; }
.msg .actions button { appearance: none; border: 0; background: none; color: var(--text-dim); font: 600 12px/1 var(--font); padding: 6px; cursor: pointer; }
.system { align-self: center; font-size: 12px; color: var(--text-dim); text-align: center; padding: 2px 12px; }

.file-card { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.file-card .thumb { width: 54px; height: 54px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; overflow: hidden; flex: none; }
.file-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-card .thumb svg { width: 26px; height: 26px; }
.file-card .name { font-weight: 600; overflow-wrap: anywhere; }

.composer { margin: 0 12px calc(12px + var(--safe-bottom)); padding: 8px; display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { resize: none; max-height: 160px; border: 0; background: transparent; padding: 11px 6px; }
.composer .replying { font-size: 12px; color: var(--text-dim); padding: 0 8px 6px; display: flex; gap: 8px; align-items: center; }
.composer-wrap { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.uploads { margin: 0 12px 8px; display: grid; gap: 6px; }
.upload { padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.upload .bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.upload .bar i { display: block; height: 100%; width: 0; background: var(--show-key); transition: width 0.2s ease; }
.upload.failed { color: var(--danger); }

/* Files */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.file { padding: 10px; display: flex; flex-direction: column; gap: 8px; color: var(--text); text-decoration: none; }
.file .preview { aspect-ratio: 16 / 10; border-radius: 10px; background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; overflow: hidden; }
.file .preview img { width: 100%; height: 100%; object-fit: cover; }
.file .preview svg { width: 34px; height: 34px; opacity: 0.8; }
.file .name { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.file .by { font-size: 12px; color: var(--text-dim); }
.file .row { display: flex; gap: 4px; }

/* People */
.people { display: grid; gap: 8px; }
.person { padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--glass-strong); position: relative; flex: none; }
.avatar.here::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--show-base2); }
.person .who { flex: 1; min-width: 0; }

.empty { text-align: center; color: var(--text-dim); padding: 40px 16px; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(12px + var(--safe-top));
  transform: translate(-50%, -160%); transition: transform 0.3s ease;
  padding: 10px 16px; border-radius: 999px; z-index: 50; font: 600 14px/1.2 var(--font);
  max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- Admin ---------- */

.card { padding: 16px; margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.guest-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; }
.rows { display: grid; gap: 6px; margin-top: 10px; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--glass-edge); flex-wrap: wrap; }
.row-item:first-child { border-top: 0; }
.row-item .grow { flex: 1; min-width: 160px; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
code.link { display: block; font-size: 12px; word-break: break-all; padding: 8px 10px; background: rgba(0, 0, 0, 0.25); border-radius: 8px; margin-top: 6px; }

@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .guest-row { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
}
