/* TinySpeak — a small mixing console for a private voice chat.
   One bold element: the LED level meters. Everything else stays quiet. */

@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(fonts/golos-text-cyrillic-wght-normal.woff2) format("woff2-variations"), url(fonts/golos-text-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(fonts/golos-text-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/golos-text-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --face: #34414e;     /* console face */
  --face-hi: #3e4c5b;  /* raised parts: strips, keys */
  --face-lo: #2c3742;  /* side panels */
  --well: #1f2730;     /* recessed: meters, inputs, chat */
  --rule: #4a5967;
  --ink: #edf1f4;
  --ink-2: #b0bcc7;
  --ink-3: #8696a4;
  --led-off: #2b3540;
  --led-g: #4fe07a;
  --led-a: #ffc53d;
  --led-r: #ff5a3c;
  --lamp-off: #1b2229;
  --focus: #ffd166;
  --link: #8fd3ff;
  --cap-plastic: linear-gradient(#e7ebef 0 44%, #27313a 44% 56%, #c7cfd6 56%);

  color-scheme: dark;
  font-family: "Golos Text", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--face);
  color: var(--ink);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--link); }
h1, h2 { margin: 0; font-weight: 650; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.i {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- shared controls */

.lamp {
  width: 8px; height: 8px; flex: none; border-radius: 50%;
  background: var(--lamp-off);
  box-shadow: inset 0 1px 1px rgb(0 0 0 / .7);
  transition: background-color .12s, box-shadow .12s;
}
.lamp.on-g { background: var(--led-g); box-shadow: 0 0 8px rgb(79 224 122 / .7); }
.lamp.on-a { background: var(--led-a); box-shadow: 0 0 8px rgb(255 197 61 / .7); }
.lamp.on-r { background: var(--led-r); box-shadow: 0 0 8px rgb(255 90 60 / .75); }
.lamp.blink { animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { background: var(--lamp-off); box-shadow: inset 0 1px 1px rgb(0 0 0 / .7); } }

.btn-primary {
  height: 44px; padding: 0 20px;
  border: 0; border-radius: 9px;
  background: linear-gradient(#e9edf1, #c6ced6);
  color: #1d252d; font-weight: 650;
  box-shadow: 0 2px 0 rgb(0 0 0 / .35), inset 0 1px 0 rgb(255 255 255 / .6);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 rgb(0 0 0 / .35); }
.btn-quiet {
  height: 36px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: transparent; color: var(--ink);
}
.btn-quiet:hover:not(:disabled) { background: var(--face-hi); }

.field { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field input, .field select, .chat-form input {
  height: 42px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--well); color: var(--ink); font-size: 15px;
}
.field select { padding-right: 8px; }
.note { margin: 0; font-size: 13px; color: var(--ink-2); }
.form-error { margin: 0; min-height: 1.45em; color: #ff9b85; font-size: 14px; }

/* ---------- the meter: the one loud thing */

.meter {
  display: flex; gap: 3px; align-items: stretch;
  height: 18px; padding: 4px;
  border-radius: 5px;
  background: var(--well);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / .6), 0 1px 0 rgb(255 255 255 / .04);
}
.meter i { flex: 1; min-width: 3px; border-radius: 1.5px; background: var(--led-off); }
.meter i.on { background: var(--led-g); box-shadow: 0 0 6px rgb(79 224 122 / .55); }
.meter i:nth-child(n+15).on { background: var(--led-a); box-shadow: 0 0 6px rgb(255 197 61 / .55); }
.meter i:nth-child(n+19).on { background: var(--led-r); box-shadow: 0 0 6px rgb(255 90 60 / .6); }

/* ---------- login */

.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%);
  display: grid; gap: 16px;
  padding: 28px 26px 22px;
  border: 1px solid var(--rule); border-radius: 14px;
  background: var(--face-lo);
  box-shadow: 0 18px 40px rgb(0 0 0 / .25);
}
.login-card h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.login-sub { margin: -10px 0 4px; color: var(--ink-2); }
.login-hint { margin: 0; font-size: 13px; color: var(--ink-2); }
.login-leds { --led-off: var(--well); display: flex; gap: 4px; height: 10px; }
.login-leds i { flex: 1; border-radius: 2px; background: var(--led-off); animation: selftest 1.3s ease-out both; }
.login-leds i:nth-child(n+9) { --lit: var(--led-a); }
.login-leds i:nth-child(n+11) { --lit: var(--led-r); }
.login-leds i:nth-child(1) { animation-delay: .00s; } .login-leds i:nth-child(2) { animation-delay: .04s; }
.login-leds i:nth-child(3) { animation-delay: .08s; } .login-leds i:nth-child(4) { animation-delay: .12s; }
.login-leds i:nth-child(5) { animation-delay: .16s; } .login-leds i:nth-child(6) { animation-delay: .20s; }
.login-leds i:nth-child(7) { animation-delay: .24s; } .login-leds i:nth-child(8) { animation-delay: .28s; }
.login-leds i:nth-child(9) { animation-delay: .32s; } .login-leds i:nth-child(10) { animation-delay: .36s; }
.login-leds i:nth-child(11) { animation-delay: .40s; } .login-leds i:nth-child(12) { animation-delay: .44s; }
@keyframes selftest {
  0% { background: var(--led-off); }
  25%, 45% { background: var(--lit, var(--led-g)); box-shadow: 0 0 6px var(--lit, var(--led-g)); }
  100% { background: var(--led-off); }
}

/* ---------- app frame */

.app {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "chan room" "deck deck";
}

.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 16px;
  min-height: 46px; padding: 0 18px;
  background: var(--face-lo);
  border-bottom: 1px solid var(--rule);
}
.server-name { font-size: 17px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* ---------- channel list */

.channels {
  grid-area: chan;
  overflow-y: auto;
  padding: 12px 8px 16px;
  background: var(--face-lo);
  border-right: 1px solid var(--rule);
}
.channel-list, .ch-people { list-style: none; margin: 0; padding: 0; }
.ch {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border: 0; border-radius: 8px;
  background: transparent; text-align: left;
}
.ch:hover { background: var(--face-hi); }
.ch.current { background: var(--face-hi); box-shadow: inset 3px 0 0 var(--led-g); }
.ch .i { color: var(--ink-2); }
.ch-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.ch-count { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ch-people { margin: 2px 0 8px 27px; }
.person {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 8px;
  font-size: 14px; color: var(--ink-2);
}
.person-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.me .person-name { color: var(--ink); }
.dot {
  width: 9px; height: 9px; flex: none; border-radius: 50%;
  background: var(--cap); opacity: .45;
  transition: opacity .1s, box-shadow .1s;
}
.speaking > .dot { opacity: 1; box-shadow: 0 0 0 2px rgb(255 255 255 / .12), 0 0 10px var(--cap); }
.state-icons { display: inline-flex; gap: 3px; margin-left: auto; }
.state-icons .i { width: 15px; height: 15px; color: #ff8a73; }
.state-icons .i.share { color: var(--led-g); }

/* ---------- room */

.room {
  grid-area: room;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0;
  padding: 18px 22px 16px;
}
.room-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.room-head h2 { font-size: 22px; line-height: 1.2; }
.room-quality { font-size: 13px; color: var(--ink-2); }

.room-empty { max-width: 560px; }
.room-empty p { margin: 0 0 14px; color: var(--ink-2); }
.quick-join { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.qj {
  display: grid; gap: 2px; justify-items: start;
  padding: 12px 14px;
  border: 1px solid var(--rule); border-radius: 10px;
  background: var(--face-hi); text-align: left;
  box-shadow: 0 2px 0 rgb(0 0 0 / .2), inset 0 1px 0 rgb(255 255 255 / .05);
}
.qj:hover { border-color: var(--ink-3); }
.qj-name { font-weight: 600; }
.qj-who { font-size: 13px; color: var(--ink-2); }

/* channel strips: one per person, like a console */
.strips { display: grid; gap: 6px; }
.strip {
  position: relative;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 260px) 168px 118px;
  grid-template-areas: "who meter fader act";
  align-items: center; gap: 16px;
  padding: 10px 14px 10px 20px;
  border-radius: 10px;
  background: var(--face-hi);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .05), 0 1px 0 rgb(0 0 0 / .3);
}
.strip::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  border-radius: 10px 0 0 10px; background: var(--cap);
  transition: box-shadow .1s;
}
.strip.speaking::before { box-shadow: 0 0 12px var(--cap); }
.strip-who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; }
.strip-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { padding: 0 6px; border: 1px solid var(--rule); border-radius: 5px; font-size: 12px; color: var(--ink-2); }
.strip .meter { grid-area: meter; }
.strip-self { grid-column: 3 / 5; font-size: 13px; color: var(--ink-2); }
.strip .state-icons { margin-left: 2px; }

.q { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; margin-left: 2px; }
.q i { width: 3px; border-radius: 1px; background: var(--led-off); }
.q i:nth-child(1) { height: 5px; } .q i:nth-child(2) { height: 8px; } .q i:nth-child(3) { height: 12px; }
.q[data-q="3"] i, .q[data-q="2"] i:nth-child(-n+2), .q[data-q="1"] i:nth-child(1) { background: var(--ink-2); }
.q[data-q="1"] i:nth-child(1) { background: var(--led-a); }
.q[data-q="0"] i:nth-child(1) { background: var(--led-r); }

.fader { grid-area: fader; display: flex; align-items: center; gap: 10px; }
.fader input { flex: 1; min-width: 0; height: 26px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.fader input::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--well); box-shadow: inset 0 1px 2px rgb(0 0 0 / .7); }
.fader input::-moz-range-track { height: 6px; border-radius: 3px; background: var(--well); box-shadow: inset 0 1px 2px rgb(0 0 0 / .7); }
.fader input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 24px; margin-top: -9px;
  border: 0; border-radius: 3px;
  background: var(--cap-plastic);
  box-shadow: 0 2px 3px rgb(0 0 0 / .55);
}
.fader input::-moz-range-thumb {
  width: 14px; height: 24px; border: 0; border-radius: 3px;
  background: var(--cap-plastic); box-shadow: 0 2px 3px rgb(0 0 0 / .55);
}
.fader output { width: 3.3em; text-align: right; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.mini-key {
  grid-area: act;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: 7px;
  background: var(--face); font-size: 13px; font-weight: 550;
  box-shadow: 0 1px 0 rgb(0 0 0 / .3);
}
.mini-key[aria-pressed="true"] .lamp { background: var(--led-r); box-shadow: 0 0 8px rgb(255 90 60 / .75); }
.strip.silenced .meter { opacity: .45; }

/* screen shares */
.stage { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; flex: none; max-height: 52%; min-height: 0; overflow: auto; }
.tile { margin: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; border-radius: 10px; overflow: hidden; background: #000; border: 1px solid var(--rule); }
.tile video { width: 100%; height: 100%; max-height: 46vh; object-fit: contain; background: #000; }
.tile:fullscreen video { max-height: none; }
.tile figcaption { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; background: var(--face-lo); font-size: 13px; color: var(--ink-2); }
.tile figcaption button { margin-left: auto; height: 30px; display: inline-flex; align-items: center; gap: 6px; }

/* chat */
.chat {
  flex: 1; min-height: 140px;
  display: flex; flex-direction: column;
  border-radius: 10px;
  background: var(--well);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / .45);
}
.chat-log { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 12px 14px 4px; list-style: none; }
.msg { padding: 3px 0 7px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.who { font-weight: 600; font-size: 14px; color: var(--cap); }
.msg time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.msg p { margin: 1px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.sys { padding: 3px 0 7px; font-size: 13px; color: var(--ink-2); }
.chat-form { display: flex; gap: 8px; padding: 8px; border-top: 1px solid #2c3640; }
.chat-form input { flex: 1; min-width: 0; height: 38px; background: var(--face-lo); }
.chat-form button { height: 38px; }

/* ---------- deck: your own controls */

.deck {
  grid-area: deck;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--face-lo);
  border-top: 1px solid var(--rule);
}
.deck-me { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 220px; }
.cap { width: 12px; height: 26px; flex: none; border-radius: 3px; background: var(--cap, var(--ink-3)); }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-keys { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.key {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 9px;
  background: var(--face-hi); font-weight: 550; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .06), 0 2px 0 rgb(0 0 0 / .3);
}
.key:hover:not(:disabled) { border-color: var(--ink-3); }
.key:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 rgb(255 255 255 / .04), 0 1px 0 rgb(0 0 0 / .3); }
#btn-mic[aria-pressed="true"] .lamp, #btn-deaf[aria-pressed="true"] .lamp { background: var(--led-r); box-shadow: 0 0 8px rgb(255 90 60 / .75); }
#btn-mic[data-problem] .lamp { background: var(--led-a); box-shadow: 0 0 8px rgb(255 197 61 / .7); }
#btn-screen[aria-pressed="true"] .lamp { background: var(--led-g); box-shadow: 0 0 8px rgb(79 224 122 / .7); }
.key-leave { margin-left: auto; }
.key-leave:hover:not(:disabled) { border-color: var(--led-r); color: #ffb3a3; }
.key-talk { border-style: dashed; }
.key-talk[data-active] { border-style: solid; border-color: var(--led-g); color: var(--led-g); }

.mode { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--well); }
.mode button {
  height: 36px; padding: 0 12px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-2); font-weight: 550; white-space: nowrap;
}
.mode button[aria-checked="true"] { background: var(--face-hi); color: var(--ink); box-shadow: 0 1px 0 rgb(0 0 0 / .35), inset 0 1px 0 rgb(255 255 255 / .06); }
kbd {
  display: inline-block; min-width: 1.6em; margin-left: 4px; padding: 0 5px;
  border: 1px solid var(--rule); border-radius: 4px;
  font: 600 12px/18px "Golos Text", system-ui, sans-serif; text-align: center;
}

/* ---------- settings */

.settings {
  width: min(520px, calc(100% - 32px)); max-height: calc(100% - 32px);
  padding: 0;
  border: 1px solid var(--rule); border-radius: 14px;
  background: var(--face-lo); color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / .45);
}
.settings::backdrop { background: rgb(14 19 24 / .62); }
.settings-body { display: grid; gap: 18px; padding: 22px 22px 18px; }
.settings h2 { font-size: 20px; }
.settings fieldset { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.settings legend { margin-bottom: 8px; padding: 0; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--led-g); }
.meter-test { height: 16px; }
.bind-row { display: flex; align-items: center; gap: 12px; }
.bind { min-width: 120px; font-weight: 600; }
.bind[data-waiting] { border-color: var(--focus); color: var(--focus); }
.settings-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--rule); }
.settings-foot .note { flex: 1 1 100%; padding-top: 10px; }
.settings-foot .btn-primary { margin-left: auto; height: 40px; }

/* ---------- misc */

.audio-sink { position: absolute; width: 0; height: 0; overflow: hidden; }
.unlock {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 10px 16px;
  border: 0; border-radius: 9px;
  background: var(--led-a); color: #241a00; font-weight: 650;
  box-shadow: 0 8px 24px rgb(0 0 0 / .35);
}
.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 30;
  max-width: min(560px, calc(100% - 32px));
  padding: 10px 16px;
  border: 1px solid var(--rule); border-radius: 9px;
  background: var(--well); color: var(--ink);
  box-shadow: 0 10px 30px rgb(0 0 0 / .4);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- narrow windows: a game on one half, voice on the other */

@media (max-width: 1100px) {
  .strip {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 220px) 118px;
    grid-template-areas: "who meter act" "fader fader fader";
    row-gap: 6px;
  }
  .strip-self { grid-column: 1 / -1; }
  .fader { max-width: 340px; }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "chan" "room" "deck";
  }
  .channels { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--rule); padding: 8px; }
  .room { padding: 14px 16px 12px; }
  .strip {
    grid-template-columns: minmax(0, 1fr) 118px;
    grid-template-areas: "who act" "meter meter" "fader fader";
    padding-left: 18px;
  }
  .deck { gap: 10px; padding: 8px 16px; }
  .deck-me { display: none; }
  .deck-keys { gap: 6px; }
  .key { padding: 0 11px; }
  .key .lamp { display: none; }
  #btn-mic[aria-pressed="true"], #btn-deaf[aria-pressed="true"] { border-color: var(--led-r); color: #ffb3a3; }
  #btn-mic[data-problem] { border-color: var(--led-a); color: var(--led-a); }
  #btn-screen[aria-pressed="true"] { border-color: var(--led-g); color: var(--led-g); }
  .mode button { padding: 0 10px; }
  .key .key-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .key-talk .key-label { position: static; width: auto; height: auto; clip-path: none; }
  .toast { bottom: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
