/* cozynation palette (matches the existing cozynation.io frontend) */
:root {
  --bg:        #fbf6ee;
  --surface:   #ffffff;
  --surface-2: #f3ead8;
  --text:      #2c2218;
  --text-2:    #6b5a44;
  --accent:    #ff6900;
  --accent-2:  #d65500;
  --border:    #e7dcc6;
  --danger:    #cf2e2e;
  --success:   #00a85a;
  --radius:    12px;
  --radius-sm: 8px;
  --gap:       12px;
  --font:      "Ubuntu", ui-rounded, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #1a1411;
    --surface:   #251c17;
    --surface-2: #2f241d;
    --text:      #f0e3cf;
    --text-2:    #b6a78f;
    --accent:    #ff8533;
    --accent-2:  #ffa05c;
    --border:    #3b2f25;
    --danger:    #e87c75;
    --success:   #6acc8a;
  }
}

* { box-sizing: border-box; }
html, body, #app {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 16px; line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

/* ─── shell ──────────────────────────────────────────────────────────── */
.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}
.header {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.header .home-link {
  display: flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  transition: background .12s;
}
.header .home-link:hover { background: var(--surface-2); text-decoration: none; }
.header img { width: 36px; height: 36px; display: block; }
.header .about-link {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
}
.header .about-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.header .brand {
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.01em;
}
.header .brand-sub {
  color: var(--text-2);
  font-size: 13px;
  margin-left: 4px;
}
.header .spacer { flex: 1; }
.header .name {
  color: var(--text-2);
  font-size: 14px;
}

/* ─── cards / primitives ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer;
  transition: background .12s, transform .04s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger:hover { filter: brightness(0.95); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input[type="text"], input[type="checkbox"] {
  font: inherit;
}
input[type="text"] {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  min-width: 0;
  flex: 1;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
label.check {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2);
}

/* ─── name screen ────────────────────────────────────────────────────── */
.name-screen {
  max-width: 440px;
  margin: 80px auto;
  text-align: center;
}
.name-screen img { width: 80px; height: 80px; }
.name-screen h1 {
  margin: 12px 0 6px;
  font-size: 32px;
}
.name-screen p {
  color: var(--text-2);
  margin: 0 0 20px;
}
.name-screen form {
  display: flex;
  gap: 8px;
}

/* ─── home / list ────────────────────────────────────────────────────── */
.create-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.stream-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .1s;
}
.stream-card:hover { background: var(--surface-2); }
.stream-card .name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-card .meta { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.live-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(207,46,46,.18);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
.pager {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  margin-top: 14px;
  color: var(--text-2);
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-2);
}

/* ─── stream page ────────────────────────────────────────────────────── */
/* One-screen layout: video + chat fit in the viewport without scrolling
   the whole page. Each column is independently constrained; chat scrolls
   its own messages. */
.stream-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: stretch;
  /* minus header + shell padding; dvh accounts for the mobile address bar. */
  height: calc(100vh - 120px);
  height: calc(100dvh - 120px);
  min-height: 360px;
}
@media (max-width: 860px) {
  .stream-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 45vh) 1fr;
    height: calc(100vh - 100px);
    height: calc(100dvh - 100px);
  }
}

.stage {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 0; min-width: 0;
}
.stage .video-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.stage video {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* Overlay button for broadcaster: switch front/back camera. */
.cam-switch-btn {
  position: absolute;
  right: 10px; bottom: 10px;
  z-index: 2;
  display: none;
  padding: 8px 12px;
  border-radius: 99px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  font: inherit; font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cam-switch-btn:hover { background: rgba(0,0,0,.75); }
.cam-switch-btn.visible { display: inline-flex; align-items: center; gap: 6px; }

/* Broadcaster overlay button bar — mute audio / mute video / switch camera */
.overlay-bar {
  position: absolute;
  right: 10px; bottom: 10px;
  display: flex; gap: 6px;
  z-index: 2;
}
.overlay-btn {
  font: inherit;
  font-size: 18px;
  line-height: 1;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .12s, transform .04s;
}
.overlay-btn:hover { background: rgba(0, 0, 0, .75); }
.overlay-btn:active { transform: translateY(1px); }
.overlay-btn.on {
  background: var(--danger);
  border-color: var(--danger);
}
.stage .video-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff;
  background: rgba(0,0,0,.55);
  font-size: 15px;
  text-align: center;
  padding: 20px;
  gap: 4px;
}
.stage .video-overlay .overlay-action { margin-top: 8px; }
.stage .title-row {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.stage .title-row h2 {
  margin: 0;
  font-size: 22px;
  flex: 1;
}
.stage .badges {
  display: flex; gap: 8px; align-items: center;
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  border: 1px solid var(--border);
}
.badge.live {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.badge.private {
  background: var(--surface);
  color: var(--text-2);
}

/* ─── chat ───────────────────────────────────────────────────────────── */
.chat {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  height: 100%;
}
.chat .hdr {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--text-2);
  font-size: 14px;
}
.chat .messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 14px;
  min-height: 0;
}
.msg .from { font-weight: 500; color: var(--accent); margin-right: 6px; }
.msg .text { color: var(--text); word-break: break-word; }
.msg .ts { color: var(--text-2); font-size: 11px; margin-left: 6px; }
.chat .typing-row {
  padding: 4px 14px 0;
  min-height: 18px;
  color: var(--text-2);
  font-size: 12px;
  font-style: italic;
  line-height: 1.3;
}
.chat form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.chat form input { flex: 1; }

/* ─── home extras: rename + create bar ─────────────────────────────── */
.rename-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rename-bar .rename-label { color: var(--text-2); font-size: 14px; }
.rename-bar input[type="text"] { max-width: 280px; flex: 0 1 280px; }
.rename-bar .name-saved {
  color: var(--success);
  font-size: 13px;
  transition: opacity .4s;
}
.rename-bar .name-err { color: var(--danger); font-size: 13px; }

/* ─── about page ──────────────────────────────────────────────────── */
.about-card h1 { margin: 0 0 6px; font-size: 28px; }
.about-card h3 { margin: 18px 0 8px; font-size: 15px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.about-card ul { margin: 0; padding-left: 20px; }
.about-card p { margin: 4px 0; }
.tech-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  font-size: 14px;
  padding: 8px 0;
}
.tech-row { display: contents; }
.tech-k { color: var(--text-2); }
.tech-v { color: var(--text); word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.muted { color: var(--text-2); font-size: 13px; }
.error {
  color: #fff;
  background: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
