/* Water Desk — test console. Brand colours are placeholders until Rasel's branding lands. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #0e1726;
  --muted: #586476;
  --line: #e0e5ec;
  --accent: #1a6faf;
  --accent-ink: #ffffff;
  --accent-soft: #e3eef8;
  --danger: #c2362f;
  --danger-soft: #fbeceb;
  --ok: #1e8e5a;
  --warn: #a8661a;
  --stage: #0d131b;
  --stage-ink: #e9eef5;
  --tap: 44px;        /* minimum touch target for every control */
  --tap-small: 32px;  /* text-only ghost buttons */
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(14, 23, 38, .06), 0 8px 24px rgba(14, 23, 38, .06);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e14;
    --surface: #121922;
    --surface-2: #19222e;
    --text: #e8edf3;
    --muted: #97a3b4;
    --line: #243041;
    --accent: #1a6faf;
    --accent-ink: #ffffff;
    --accent-soft: #15283b;
    --danger: #f0716a;
    --danger-soft: #2a1717;
    --ok: #4cc38a;
    --warn: #e0a458;
    --stage: #05080c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 0.9375rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
code { font: 0.8125rem var(--mono); background: var(--surface-2); padding: 0.0625rem 0.3125rem; border-radius: 0.375rem;  white-space: nowrap;}
h1 { font-size: 1.375rem; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 0.375rem; }
h2 { font-size: 0.8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.bar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 650; font-size: 1.0625rem; }
.drop { color: var(--accent); }
.brand-tag { font-weight: 500; color: var(--muted); }
.env { margin: 0 0 0 auto; font-size: 0.8125rem; color: var(--muted); display: flex; align-items: center; gap: 0.5rem; }
.env-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
/* Provider switch: one page per provider, so these are plain links */
.providers { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.providers a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 16px; border-radius: 999px; color: var(--muted); font-size: 0.875rem; font-weight: 550; text-decoration: none; transition: background-color .15s var(--ease), color .15s var(--ease); }
.providers a:hover { color: var(--text); }
.providers a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.providers a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

main { flex: 1; display: flex; padding: 28px 24px; min-height: 0; }
.center { margin: auto; width: 100%; max-width: 440px; }

/* Buttons */
button { font: inherit; cursor: pointer; border: 0; }
button, input, .segmented label { min-height: var(--tap-small); }
.primary, .round, input[type="password"], input:not([type]) { min-height: var(--tap); }
button:focus-visible, input:focus-visible, .segmented input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.primary { width: 100%; height: 48px; border-radius: var(--radius-s); background: var(--accent); color: var(--accent-ink); font-weight: 600; margin-top: 18px; transition: transform .15s var(--ease), filter .15s; }
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: scale(.985); }
.primary[aria-busy="true"] { pointer-events: none; opacity: .8; }
.primary[aria-busy="true"] .btn-label::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.secondary { height: 40px; padding: 0 16px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: var(--stage-ink); font-weight: 550; border: 1px solid rgba(255, 255, 255, .2); }
.secondary:hover { background: rgba(255, 255, 255, .18); }
.ghost { background: transparent; color: var(--muted); padding: 0.375rem 0.625rem; border-radius: 0.5rem; font-size: 0.8125rem; font-weight: 550; }
.ghost:hover { background: var(--surface-2); color: var(--text); }
.bar .ghost { margin-left: 4px; }

/* Cards and forms */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.lede { color: var(--muted); margin: 0 0 18px; }
label { display: block; font-size: 0.8125rem; font-weight: 600; margin: 0.875rem 0 0.375rem; }
input[type="text"], input:not([type]), input[type="password"] {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 0.9375rem var(--font); transition: border-color .15s;
}
input:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 0.7812rem; color: var(--muted); margin: 0.375rem 0 0; }
.form-error { margin: 1rem 0 0; padding: 0.75rem 0.875rem; border-radius: 0.625rem; background: var(--danger-soft); color: var(--danger); font-size: 0.875rem; }
.form-error strong { display: block; color: var(--text); margin-bottom: 2px; }
.form-error code { background: transparent; padding: 0; color: inherit; }
.summary { margin: 0.875rem 0 0; text-align: center; font-size: 0.8125rem; color: var(--muted); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 18px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; text-align: center; padding: 8px 0; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 550; transition: background .2s var(--ease), color .2s; }
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(14, 23, 38, .12); }

/* Lobby */
.lobby { margin: auto; width: 100%; max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 24px; align-items: stretch; }
.tile { position: relative; border-radius: var(--radius); background: var(--stage); color: var(--stage-ink); overflow: hidden; aspect-ratio: 16 / 10; }
/* In the lobby the tile takes its size from its COLUMN width (16:10), never from the row height:
   a stretched row plus aspect-ratio made it wider than its column and it covered the join panel. */
.lobby > .tile { width: 100%; height: auto; align-self: center; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s var(--ease); }
.tile video.live { opacity: 1; }
#previewVideo, #selfVideo { transform: scaleX(-1); }
.tile-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; }
.tile-empty svg { opacity: .55; }
.tile-empty p { margin: 0; }
.empty-title { font-size: 1.1875rem; font-weight: 600; }
.empty-sub { color: color-mix(in srgb, var(--stage-ink) 70%, transparent); max-width: 34ch; }
.meter { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 3px; align-items: flex-end; height: 22px; padding: 6px 8px; border-radius: 10px; background: rgba(0, 0, 0, .45); backdrop-filter: blur(8px); }
.meter span { width: 4px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); transition: height .08s linear, background .08s; }
.meter span.lit { background: #6fd3a0; }

/* Skeletons */
.skeleton, .skel-line { background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in srgb, var(--surface-2) 55%, var(--surface)) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.tile.skeleton { background-color: var(--surface-2); }
.skel-line { height: 14px; border-radius: 7px; margin: 14px 0; }
.skel-line.tall { height: 48px; border-radius: var(--radius-s); margin-top: 32px; }
.w40 { width: 40%; } .w60 { width: 60%; } .w90 { width: 90%; }
.tile.joining::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .06) 50%, transparent 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Call */
.call { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto; gap: 16px; width: 100%; max-width: 1400px; margin: 0 auto; min-height: 0; }
.stage { position: relative; min-height: 0; display: flex; }
.tile.remote { flex: 1; aspect-ratio: auto; min-height: 320px; }
.tile.remote video { object-fit: contain; background: var(--stage); }
.tile.self { position: absolute; right: 16px; bottom: 16px; width: clamp(140px, 20%, 260px); aspect-ratio: 16 / 10; border: 2px solid rgba(255, 255, 255, .14); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.self-off { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.8125rem; color: color-mix(in srgb, var(--stage-ink) 70%, transparent); }
.nameplate { position: absolute; left: 1rem; bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.625rem; border-radius: 0.625rem; background: rgba(0, 0, 0, .5); backdrop-filter: blur(0.5rem); font-size: 0.875rem; font-weight: 550; }
.mic-off { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.bars i { width: 3px; border-radius: 1px; background: rgba(255, 255, 255, .3); }
.bars i:nth-child(1) { height: 5px; } .bars i:nth-child(2) { height: 8px; } .bars i:nth-child(3) { height: 12px; }
.bars[data-q="excellent"] i { background: #6fd3a0; }
.bars[data-q="good"] i:nth-child(-n+2) { background: #6fd3a0; }
.bars[data-q="poor"] i:nth-child(1) { background: #f0a35e; }
.bars[data-q="bad"] i:nth-child(1), .bars[data-q="lost"] i:nth-child(1) { background: #f0716a; }
.pulse { width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle, rgba(111, 177, 230, .5) 0%, rgba(111, 177, 230, 0) 70%); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.8); opacity: .5; } 50% { transform: scale(1.15); opacity: 1; } }
.banner { position: absolute; top: 1rem; left: 50%; transform: translateX(-50%); padding: 0.625rem 1rem; border-radius: 62.4375rem; font-size: 0.875rem; font-weight: 550; background: rgba(168, 102, 26, .92); color: #fff; box-shadow: 0 0.375rem 1.25rem rgba(0, 0, 0, .25); }
.banner.bad { background: rgba(194, 54, 47, .94); }
.sound-btn { position: absolute; top: 16px; right: 16px; height: 36px; padding: 0 14px; border-radius: 999px; background: #fff; color: #0e1726; font-weight: 600; }

.dock { grid-column: 1; display: flex; align-items: center; justify-content: center; gap: 12px; position: relative; }
.round { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); transition: background .2s var(--ease), color .2s, transform .12s var(--ease); }
.round:active { transform: scale(.94); }
.round .off { display: none; }
.round[aria-pressed="false"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.round[aria-pressed="false"] .on { display: none; }
.round[aria-pressed="false"] .off { display: block; }
.round.leave { width: 64px; border-radius: 26px; background: var(--danger); color: #fff; border-color: transparent; }
.round.leave:hover { filter: brightness(1.08); }
.round:disabled { opacity: .4; cursor: not-allowed; }
.timer { position: absolute; left: 0.25rem; font: 600 0.875rem var(--mono); color: var(--muted); }
.details-btn { position: absolute; right: 0; }

.details { grid-column: 2; grid-row: 1 / span 2; width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; min-height: 0; }
.facts { margin: 0 0 18px; display: grid; gap: 10px; }
.facts div { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.8438rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.log-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.log { list-style: none; margin: 0; padding: 0; overflow: auto; font: 0.75rem/1.5 var(--mono); flex: 1; min-height: 7.5rem; }
.log li { padding: 4px 0; border-top: 1px solid var(--line); color: var(--muted); }
.log li time { color: var(--text); margin-right: 8px; }
.log li.bad { color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 550; box-shadow: var(--shadow); animation: rise .3s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 860px) {
  main { padding: 16px; }
  .bar { padding: 12px 16px; }
  .env { display: none; }
  .bar .ghost { margin-left: auto; }
  .lobby { grid-template-columns: 1fr; }
  .call { grid-template-columns: 1fr; }
  .details { grid-column: 1; grid-row: auto; width: auto; max-height: 50vh; }
  .card, .panel { padding: 22px; }
}

@media (max-width: 600px) {
  .bar { flex-wrap: wrap; row-gap: 10px; }
  .providers { order: 3; flex-basis: 100%; }
  .providers a { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
