/* ============================================================
   Milked Live — topography theme
   near-black canvas, off-white "milk" accent, animated contour
   lines behind semi-transparent surfaces.
   ============================================================ */

:root {
  --page: #0a0a0c;
  --surface: rgba(17, 17, 20, 0.82);
  --surface-raised: rgba(26, 26, 31, 0.94);
  --player: #08090a;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.26);
  --text: #eef0f4;
  --muted: #9aa0ad;
  --faint: #5b606b;
  --accent: #f2ece1;
  --accent-strong: #f2ece1;
  --accent-ink: #0a0a0c;
  --live: #6ee07a;
  --danger: #ff6b6b;
  --topo: rgba(242, 236, 225, 0.16);
  --display: "Space Grotesk", sans-serif;
  --body: "DM Sans", sans-serif;
  --mono: "JetBrains Mono", "Courier New", monospace;
  --ease: 200ms ease;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { background: var(--page); color: var(--text); font-family: var(--body); margin: 0; transition: background var(--ease), color var(--ease); }
button, a { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------- App page: fixed one-screen layout, no page scroll ---------------- */
.app-page, .app-page body { height: 100%; overflow: hidden; }
@media (min-width: 901px) {
  .app-page body { display: flex; flex-direction: column; }
  .app-page .topbar, .app-page .site-footer { flex: none; }
  .app-page .stream-shell { flex: 1; margin-bottom: 14px; margin-left: auto; margin-right: auto; min-height: 0; width: 100%; }
  .app-page .stream-column { display: flex; flex-direction: column; min-height: 0; }
  .app-page .player-frame {
    aspect-ratio: auto;
    flex: 1 1 auto;
    min-height: 220px;
    width: 100%;
  }
  .app-page .stream-details { flex: none; }
  .app-page .chat-panel { height: 100%; min-height: 0; }
}

/* ---------------- Animated topography backdrop ---------------- */
.topo {
  color: var(--topo);
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}
.topo svg { display: block; height: 100%; width: 100%; }
.topo-layer { stroke-width: 1.2; }
.topo-a { animation: topoDrift 90s linear infinite; opacity: 0.9; }
.topo-b { animation: topoDrift 140s linear infinite reverse; opacity: 0.55; }
@keyframes topoDrift {
  from { transform: translateX(0); }
  to { transform: translateX(-120px); }
}

/* ---------------- App chrome ---------------- */
.topbar { align-items: center; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; height: 64px; justify-content: space-between; padding: 0 24px; position: relative; z-index: 1; }
.wordmark { align-items: center; display: flex; gap: 11px; }
.wordmark-icon { display: block; height: 30px; width: 30px; }
.wordmark-text { font: 700 18px var(--display); letter-spacing: -.04em; }
.wordmark-text span { color: var(--accent-strong); }
.top-actions, .stream-actions { display: flex; gap: 8px; }
.quiet-button, .outline-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  font-size: 12px;
  padding: 8px 12px;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}
.quiet-button:hover, .outline-button:hover { border-color: var(--accent-strong); color: var(--accent-strong); }
.quiet-button[hidden] { display: none; }

/* ---------------- Stream layout ---------------- */
.stream-shell { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 320px; margin: 12px auto 0; max-width: 1800px; padding: 0 16px; position: relative; z-index: 1; }
.stream-column { min-width: 0; }
.player-frame { aspect-ratio: 16 / 9; background: var(--player); border: 1px solid var(--line); border-radius: 18px; min-height: 420px; overflow: hidden; position: relative; }
.player-frame:fullscreen, .player-frame:-webkit-full-screen {
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  height: 100%;
  width: 100%;
}
.player-frame:fullscreen video, .player-frame:-webkit-full-screen video { height: 100%; }
.player-frame video { display: block; height: 100%; object-fit: contain; width: 100%; }
.player-tools { align-items: center; display: flex; gap: 8px; position: absolute; right: 12px; top: 12px; z-index: 2; }
.player-tool { background: rgba(10, 10, 12, 0.72); border: 1px solid var(--line-strong); border-radius: 3px; color: var(--text); cursor: pointer; font-size: 11px; padding: 6px 10px; transition: color var(--ease), border-color var(--ease), background var(--ease); }
.player-tool:hover { border-color: var(--accent-strong); color: var(--accent-strong); }
.chat-reopen { display: none; }
body.chat-collapsed .chat-reopen { display: inline-flex; }
body.chat-collapsed .chat-panel { display: none; }
@media (min-width: 901px) {
  body.chat-collapsed .stream-shell { grid-template-columns: 1fr; }
}
.offline-state { align-items: center; background: var(--player); display: flex; flex-direction: column; inset: 0; justify-content: center; position: absolute; text-align: center; }
.offline-state[hidden] { display: none; }
.offline-state h1 { font: 600 clamp(28px, 4vw, 42px) var(--display); letter-spacing: -.06em; margin: 0 0 10px; }
.offline-state p:last-child { color: var(--muted); font-size: 14px; margin: 0; }
.eyebrow { color: var(--accent-strong); font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .14em; margin: 0 0 12px; text-transform: uppercase; }
.stream-details { align-items: center; display: flex; justify-content: space-between; padding: 18px 2px 0; }
.stream-title-row { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.stream-title-row h1 { font: 600 24px var(--display); letter-spacing: -.04em; margin: 0; }
.quality-label { border: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; padding: 4px 7px; text-transform: uppercase; }
.stream-subtitle { color: var(--muted); font-size: 13px; margin: 5px 0 0; }

/* ---------------- Chat panel ---------------- */
.chat-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; height: calc(100vh - 96px); min-height: 500px; overflow: hidden; }
.chat-header { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: flex-end; padding: 11px 13px; }
.chat-header h2 { font: 600 16px var(--display); letter-spacing: -.02em; margin: 0 0 3px; }
.chat-header p { color: var(--muted); font-size: 12px; margin: 0; }
.chat-header-actions { align-items: center; display: flex; gap: 10px; }
.chat-hide { background: transparent; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); cursor: pointer; font-size: 10px; letter-spacing: .08em; padding: 5px 10px; text-transform: uppercase; transition: color var(--ease), border-color var(--ease); }
.chat-hide:hover { border-color: var(--accent-strong); color: var(--accent-strong); }
.viewer-count { color: var(--accent-strong); font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.chat-panel iframe { border: 0; flex: 1; min-height: 0; width: 100%; }
.chat-footer { border-top: 1px solid var(--line); padding: 10px 13px; }
.chat-footer p { color: var(--muted); font-size: 11px; margin: 0 0 10px; }
.chat-footer-links { display: flex; gap: 16px; justify-content: space-between; margin-top: 10px; }
.chat-footer-links a { color: var(--muted); font-size: 11px; text-decoration: underline; }
.chat-footer-links a:hover { color: var(--text); }

/* ---------------- Chat iframe page ---------------- */
.chat-doc, .chat-doc body { height: 100%; }
.chat-body { margin: 0; overflow: hidden; }
.chat-app { background: var(--surface); display: flex; flex-direction: column; height: 100%; position: relative; z-index: 1; }
.chat-messages { display: flex; flex: 1; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; padding: 10px 10px 14px; scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-msg { border-radius: 6px; display: flex; flex-direction: column; gap: 3px; padding: 6px 8px; transition: background var(--ease); }
.chat-msg:hover { background: var(--surface-raised); }
.chat-msg-meta { align-items: baseline; display: flex; gap: 8px; }
.chat-username { color: var(--text); font-size: 12px; font-weight: 700; letter-spacing: -.01em; }
.chat-time { color: var(--faint); font-family: var(--mono); font-size: 10px; }
.chat-msg-text { color: var(--text); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-system { border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .06em; margin: 6px auto; padding: 4px 12px; text-align: center; text-transform: uppercase; width: fit-content; }
.chat-guest { align-items: center; color: var(--muted); display: flex; flex: none; flex-direction: column; gap: 6px; justify-content: center; padding: 26px 20px; text-align: center; }
.chat-guest[hidden] { display: none; }
.chat-guest-title { color: var(--accent-strong); font-size: 11px; font-weight: 700; letter-spacing: .1em; margin: 0; text-transform: uppercase; }
.chat-guest-sub { font-size: 12px; margin: 0; }
.chat-locked { align-items: center; border-top: 1px solid var(--line); color: var(--danger); display: flex; font-size: 12px; justify-content: center; padding: 12px 16px; text-align: center; }
.chat-locked[hidden] { display: none; }
.chat-composer { border-top: 1px solid var(--line); padding: 10px 12px; }
.chat-form { display: flex; gap: 8px; }
.chat-input { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 3px; color: var(--text); flex: 1; font: inherit; font-size: 13px; min-width: 0; outline: none; padding: 9px 11px; transition: border-color var(--ease); }
.chat-input:focus { border-color: var(--accent-strong); }
.chat-input::placeholder { color: var(--faint); }
.chat-send { background: var(--accent); border: 0; border-radius: 3px; color: var(--accent-ink); font-size: 12px; font-weight: 700; padding: 9px 16px; transition: background var(--ease), color var(--ease); }
.chat-send:hover { background: var(--accent-strong); }
.chat-send:disabled { cursor: default; opacity: 0.5; }
.chat-note { color: var(--faint); font-size: 10px; margin: 8px 0 0; }

/* ---------------- Footer ---------------- */
.site-footer { align-items: center; color: var(--muted); display: flex; flex-wrap: wrap; font-size: 11px; gap: 14px; justify-content: space-between; margin: 0 auto; max-width: 1600px; padding: 14px 18px 22px; position: relative; z-index: 1; }
.footer-links { display: flex; gap: 16px; }
.site-footer nav:only-child { margin: 0 auto; }
.footer-links a { color: var(--muted); text-decoration: underline; }
.footer-links a:hover { color: var(--text); }

/* ---------------- Legal pages (Terms / Privacy) ---------------- */
.legal-shell { margin: 0 auto; max-width: 760px; padding: 32px 16px 60px; position: relative; z-index: 1; }
.legal-content { background: var(--surface); border: 1px solid var(--line); padding: 36px clamp(20px, 5vw, 48px); }
.legal-content h1 { font: 600 30px var(--display); letter-spacing: -.04em; margin: 0 0 4px; }
.legal-updated { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.legal-lede { color: var(--text); font-size: 14px; line-height: 1.6; margin: 0 0 20px; }
.legal-content h2 { font: 600 18px var(--display); letter-spacing: -.02em; margin: 28px 0 8px; }
.legal-content h3 { font-size: 14px; margin: 20px 0 6px; }
.legal-content p, .legal-content li { color: var(--muted); font-size: 14px; line-height: 1.6; }
.legal-content p { margin: 0 0 14px; }
.legal-content ul, .legal-content ol { margin: 0 0 14px; padding-left: 22px; }
.legal-content li { margin-bottom: 6px; }
.legal-content strong { color: var(--text); }
.legal-content a { color: var(--accent-strong); text-decoration: underline; }
.legal-content code, .admin-content code { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 3px; font-family: var(--mono); font-size: 12px; padding: 1px 5px; }

/* ---------------- Legal doc: summary card, TOC, section numbers, TODO flags ---------------- */
.legal-summary { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 6px; margin: 0 0 22px; padding: 16px 18px; }
.legal-summary p { color: var(--text); font-size: 13px; margin: 0 0 8px; }
.legal-summary ul { margin: 0; padding-left: 18px; }
.legal-summary li { color: var(--text); font-size: 13px; margin-bottom: 5px; }
.legal-summary li:last-child { margin-bottom: 0; }
.legal-toc { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 26px; padding: 14px 18px; }
.legal-toc-title { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; margin: 0 0 10px; text-transform: uppercase; }
.legal-toc ol { display: grid; gap: 4px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); list-style: none; margin: 0; padding: 0; }
.legal-toc li { font-size: 13px; }
.legal-toc a { color: var(--muted); text-decoration: none; }
.legal-toc a:hover { color: var(--accent-strong); text-decoration: underline; }
.legal-num { color: var(--faint); display: inline-block; font-family: var(--display); margin-right: 3px; }
.legal-content h2 { align-items: baseline; display: flex; gap: 10px; scroll-margin-top: 84px; }
.legal-content h3 { scroll-margin-top: 84px; }
.legal-todo { border: 1px solid var(--danger); border-radius: 3px; color: var(--danger); font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 1px 7px; white-space: nowrap; }
.legal-todo-banner { background: var(--surface-raised); border: 1px solid var(--danger); border-radius: 6px; margin: 0 0 22px; padding: 12px 16px; }
.legal-todo-banner p { color: var(--text); font-size: 12px; margin: 0; }
.legal-back-to-top { color: var(--muted); display: inline-block; font-size: 11px; margin-top: 6px; }
.legal-back-to-top:hover { color: var(--accent-strong); }
@media (max-width: 600px) {
  .legal-toc ol { grid-template-columns: 1fr; }
}
.legal-content table { border-collapse: collapse; font-size: 13px; margin: 0 0 16px; width: 100%; }
.legal-content th, .legal-content td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal-content th { background: var(--surface-raised); color: var(--text); font-size: 12px; }
.legal-content td { color: var(--muted); }

/* ---------------- Auth modal ---------------- */
.modal-backdrop { align-items: center; background: rgba(0, 0, 0, 0.68); display: flex; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 10; }
.modal-backdrop[hidden] { display: none; }
.auth-modal { background: var(--surface-raised); border: 1px solid var(--line); max-width: 390px; padding: 30px; position: relative; width: 100%; }
.modal-close { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 0; position: absolute; right: 26px; top: 27px; }
.modal-close:hover { color: var(--text); }
.auth-modal h2 { font: 600 30px var(--display); letter-spacing: -.05em; margin: 0 0 8px; }
.auth-description { color: var(--muted); font-size: 13px; margin: 0 0 25px; }
.auth-modal form { display: grid; gap: 9px; }
.auth-modal label { font-size: 12px; font-weight: 600; margin-top: 6px; }
.auth-modal input[type="text"], .auth-modal input[type="password"] { background: var(--surface); border: 1px solid var(--line); border-radius: 3px; color: var(--text); font: inherit; outline: none; padding: 11px 12px; width: 100%; }
.auth-modal input[type="text"]:focus, .auth-modal input[type="password"]:focus { border-color: var(--accent-strong); }
.auth-check { align-items: flex-start; color: var(--muted); display: flex; font-size: 12px; font-weight: 400; gap: 9px; line-height: 1.45; margin-top: 8px; }
.auth-check[hidden] { display: none; }
.auth-check input { flex: none; height: 15px; margin-top: 2px; width: 15px; }
.auth-check a { color: var(--accent-strong); text-decoration: underline; }
.form-error { color: var(--danger); font-size: 12px; margin: 3px 0 0; min-height: 16px; }
.auth-submit { background: var(--accent); border: 0; border-radius: 3px; color: var(--accent-ink); font-weight: 700; margin-top: 5px; padding: 12px; transition: background var(--ease), color var(--ease); }
.auth-submit:hover { background: var(--accent-strong); }
.auth-switch { color: var(--muted); font-size: 12px; margin: 22px 0 0; text-align: center; }
.auth-switch button { background: none; border: 0; color: var(--accent-strong); font-size: inherit; padding: 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .stream-shell { grid-template-columns: 1fr; }
  .chat-panel { height: 520px; min-height: 0; }
}
@media (max-width: 600px) {
  .topbar { height: 58px; padding: 0 14px; }
  .top-actions .quiet-button:last-child { display: none; }
  .stream-shell { margin-top: 0; padding: 0; }
  .player-frame { min-height: 220px; }
  .stream-details { align-items: flex-start; flex-direction: column; gap: 15px; padding: 15px 14px 18px; }
  .stream-actions { width: 100%; }
  .outline-button { flex: 1; }
  .chat-panel { border-left: 0; border-right: 0; height: 520px; }
  .site-footer { padding: 14px; }
}

/* ---------------- Admin panel ---------------- */
.admin-shell { margin: 0 auto; max-width: 760px; padding: 32px 16px 60px; position: relative; z-index: 1; }
.admin-content { background: var(--surface); border: 1px solid var(--line); padding: 36px clamp(20px, 5vw, 48px); }
.admin-content h1 { font: 600 30px var(--display); letter-spacing: -.04em; margin: 0 0 4px; }
.admin-sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.admin-section { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 24px; }
.admin-section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.admin-section h2 { font: 600 16px var(--display); letter-spacing: -.02em; margin: 0 0 14px; }
.admin-section h3 { font: 600 13px var(--display); letter-spacing: -.01em; margin: 20px 0 8px; }
.admin-section p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 10px; }
.admin-steps { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 10px; padding-left: 20px; }
.admin-steps li { margin-bottom: 5px; }
.admin-form { display: grid; gap: 10px; max-width: 460px; }
.admin-form label { color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 4px; }
.admin-form input { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 3px; color: var(--text); font: inherit; outline: none; padding: 10px 12px; }
.admin-form input:focus { border-color: var(--accent-strong); }
.admin-row { align-items: center; display: flex; gap: 8px; flex-wrap: wrap; }
.admin-row input { flex: 1; min-width: 160px; }
.admin-button { background: transparent; border: 1px solid var(--line); border-radius: 3px; color: var(--text); font-size: 12px; padding: 10px 14px; transition: color var(--ease), border-color var(--ease), background var(--ease); }
.admin-button:hover { border-color: var(--accent-strong); color: var(--accent-strong); }
.admin-button.primary { background: var(--accent); border: 0; color: var(--accent-ink); font-weight: 700; }
.admin-button.primary:hover { background: var(--accent-strong); color: var(--accent-ink); }
.admin-button.danger { border-color: var(--danger); color: var(--danger); }
.admin-button.danger:hover { background: var(--danger); color: var(--accent-ink); }
.admin-msg { color: var(--muted); font-size: 12px; min-height: 16px; margin: 0; }
.admin-msg.ok { color: var(--live); }
.admin-msg.err { color: var(--danger); }
.admin-list { display: flex; flex-direction: column; gap: 8px; list-style: none; margin: 12px 0 0; padding: 0; }
.admin-list li { align-items: center; border: 1px solid var(--line); border-radius: 3px; display: flex; gap: 10px; justify-content: space-between; padding: 9px 12px; }
.admin-list .who { align-items: center; display: flex; gap: 8px; min-width: 0; }
.admin-list .who .name { color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list .who .reason { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { border: 1px solid var(--line); border-radius: 3px; color: var(--muted); flex: none; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; padding: 3px 6px; text-transform: uppercase; }
.role-badge.mod { border-color: var(--accent-strong); color: var(--accent-strong); }
.role-badge.owner { background: var(--accent); border: 0; color: var(--accent-ink); }
.empty-note { color: var(--faint); font-size: 12px; margin: 10px 0 0; }

/* ---------------- Chat moderation controls ---------------- */
.chat-msg { position: relative; }
.chat-msg .msg-actions { align-items: center; display: none; gap: 6px; margin-left: auto; }
.chat-msg:hover .msg-actions { display: flex; }
.chat-msg-meta { align-items: center; display: flex; gap: 8px; }
.chat-mod-btn { background: transparent; border: 1px solid var(--line); border-radius: 3px; color: var(--faint); cursor: pointer; font-size: 10px; line-height: 1; padding: 3px 6px; transition: color var(--ease), border-color var(--ease); }
.chat-mod-btn:hover { border-color: var(--danger); color: var(--danger); }
.chat-mod-btn.kick:hover { border-color: var(--accent-strong); color: var(--accent-strong); }
.chat-msg .msg-delete { background: transparent; border: 0; color: var(--faint); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; position: absolute; right: 0; top: 0; }
.chat-msg .msg-delete:hover { color: var(--danger); }
.chat-msg.removing { opacity: .35; }
.chat-msg .chat-banned-tag, .chat-msg .chat-mod-tag { border: 1px solid var(--line); border-radius: 3px; color: var(--faint); font-size: 9px; letter-spacing: .08em; padding: 1px 5px; text-transform: uppercase; }
.chat-msg .chat-mod-tag { border-color: var(--accent-strong); color: var(--accent-strong); }

/* ---------------- Motion + focus ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .topo-a, .topo-b { animation: none; }
}