:root {
  --bg: #F2EFE9;
  --text: #1B1B1B;
  --muted: #6A675F;
  --line: #D8D3C8;
  --panel: #FBFAF7;
  --accent: #2438D9;
  --on-accent: #fff;
  --outline: #1B1B1B;        /* контур корпуса: как на чертеже, одинаков в обеих темах */
  --plastic-1: #FCFBF8;
  --plastic-2: #EFEDE7;
  --beige: #D2CABB;
  --coral-1: #EC8C70;
  --coral-2: #D8664A;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151517; --text: #ECE9E2; --muted: #9B978E; --line: #2C2C30; --panel: #1E1E21;
    --accent: #8E9BFF; --on-accent: #0B0E2A;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151517; --text: #ECE9E2; --muted: #9B978E; --line: #2C2C30; --panel: #1E1E21;
  --accent: #8E9BFF; --on-accent: #0B0E2A;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  padding-inline: 16px; padding-block: 0 48px;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
kbd { font: 500 12px/1 var(--mono); border: 1.5px solid var(--line); border-radius: 4px; padding: 2px 5px; background: var(--panel); color: var(--text); }

/* ---------- верхняя полоса ---------- */
.top { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding-block: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.mark { width: 26px; height: 26px; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs a { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 15px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--text); color: var(--bg); }
.quiet { background: none; border: 0; padding: 6px 8px; color: var(--muted); border-radius: 4px; font-size: 15px; }
.quiet:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- комната: пульт + панель ---------- */
.room { max-width: 1120px; margin: 0 auto; display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) { .room { grid-template-columns: minmax(0, 1fr) 320px; } }
.unit { display: flex; flex-direction: column; align-items: center; gap: 22px; padding-inline: 0; padding-top: 16px; }

/* ---------- корпус: горизонтальный «диктофон» 128×48 мм, ручка справа ---------- */
.device {
  --w: min(92vw, 720px);
  position: relative; width: var(--w); aspect-ratio: 128 / 52;
  border: 2.5px solid var(--outline); border-radius: 5.5% / 13.5%;
  background: linear-gradient(160deg, var(--plastic-1), var(--plastic-2));
  box-shadow: 0 1px 0 #fff inset, 0 24px 40px -22px rgba(30, 24, 10, .45);
  margin-block: 12px 4px;
}
.face { position: absolute; inset: 0; }
.mic-hole { position: absolute; bottom: 8%; left: 68.7%; width: 4px; height: 4px; border-radius: 50%; background: #55524b; opacity: .7; }

/* вставка вокруг окна: модуль 79 × 36,7, окно 68,4 × 30,6, видимая область 66,9 × 29,1 */
.bezel {
  position: absolute; left: 6.2%; top: 18.5%; width: 58.75%; height: 63.1%;
  background: #141517; border-radius: 3%/6%;
  box-shadow: 0 0 0 1px #000, 0 2px 0 rgba(255, 255, 255, .5);
}
#screen { position: absolute; left: 5.52%; right: 5.52%; top: 5.65%; bottom: 5.65%; width: 88.96%; height: 88.7%; display: block; background: #E1E3DD; }
.glow { position: absolute; left: 5.52%; right: 5.52%; top: 5.65%; bottom: 5.65%; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 244, 205, .5), rgba(255, 244, 205, 0) 70%); mix-blend-mode: soft-light; }
.device.lit .glow { opacity: 1; }
.device.asleep #screen { filter: contrast(.92); }

/* плоская ручка Ø25: крутить, нажать, держать */
.knob {
  position: absolute; left: 73.05%; top: 26%; width: 19.5%; aspect-ratio: 1;
  border-radius: 50%; touch-action: none; cursor: grab; user-select: none;
  background: #DFE2DC; box-shadow: 0 0 0 2.5px var(--outline), 0 6px 10px -4px rgba(30, 24, 10, .4);
  display: grid; place-items: center;
}
.knob::before { content: ""; position: absolute; inset: -12px; border-radius: 50%; }   /* область нажатия больше ручки */
.knob .cap {
  position: absolute; inset: 5%; border-radius: 50%; rotate: var(--rot, 0deg);
  background: radial-gradient(circle at 38% 30%, var(--coral-1), var(--coral-2));
  box-shadow: 0 0 0 2px #A9432B inset, 0 2px 0 rgba(255, 255, 255, .35) inset;
  transition: scale .08s;
}
.knob .cap::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(rgba(120, 40, 20, .35) 0 1.5deg, transparent 1.5deg 7.5deg); -webkit-mask: radial-gradient(circle, transparent 78%, #000 79%); mask: radial-gradient(circle, transparent 78%, #000 79%); }
.knob .cap::after { content: ""; position: absolute; inset: 20%; border-radius: 50%; background: #E8795D; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .35) inset; }
.knob .dot { position: absolute; left: 50%; top: 9%; width: 7%; aspect-ratio: 1; translate: -50% 0; border-radius: 50%; background: #fff; z-index: 1; }
.knob .mic { position: relative; width: 34%; opacity: 0; transition: opacity .12s; pointer-events: none; z-index: 1; }
.knob:active .cap, .knob.down .cap { scale: .965; }
.knob.hold .mic, .device.rec .knob .mic { opacity: 1; }
.knob.hold .dot, .device.rec .knob .dot { opacity: 0; }
.device.rec .knob::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid var(--coral-2);
  animation: pulse 1.1s ease-out infinite; pointer-events: none;
}
@keyframes pulse { from { opacity: .9; transform: scale(.94); } to { opacity: 0; transform: scale(1.18); } }

/* верхняя грань: «Назад» и «Меню» */
.side { position: absolute; border: 2px solid var(--outline); background: var(--beige); padding: 0; }
.side::before { content: ""; position: absolute; inset: -8px; }        /* область нажатия больше кнопки */
.side.back, .side.menu { top: -9px; width: 4.7%; height: 10px; border-radius: 6px 6px 0 0; border-bottom: 0; }
.side.back { left: 66.3%; }
.side.menu { left: 74.9%; }
.side:active, .side.down { filter: brightness(.86); translate: 0 2px; }
.port { position: absolute; left: -1px; width: 5px; height: 4.2%; border-radius: 2px; background: #1B1D20; }
.port.p1 { top: 38%; } .port.p2 { top: 54%; }

.jack { position: absolute; bottom: -1px; left: 85.2%; width: 4.7%; height: 4.2%; border-radius: 2px; background: #1B1D20; }
.jack::after { content: ""; position: absolute; left: 50%; top: 22%; width: 34%; aspect-ratio: 1; translate: -50% 0; border-radius: 50%; background: #55524b; }
.led { position: absolute; left: 3.2%; bottom: 9%; width: 8px; height: 8px; border-radius: 50%; background: #CFCBC0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.device.buzz .led { background: #F08A24; box-shadow: 0 0 8px #F08A24; }
.device.buzz { animation: buzz .07s linear infinite; }
@keyframes buzz { 0% { translate: 0 0; } 25% { translate: -1.5px 1px; } 50% { translate: 1.5px -1px; } 75% { translate: -1px -1px; } 100% { translate: 0 0; } }

/* ---------- клавиши под пультом ---------- */
.pad { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; max-width: 520px; }
.key {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--panel); font-size: 14px; font-weight: 500;
}
.key:hover { border-color: var(--text); }
.key:active { background: var(--text); color: var(--bg); }
.key:active kbd { color: var(--text); }
.key.ok { border-color: var(--text); }
.key small { font-size: 12px; color: var(--muted); font-weight: 400; }
.key:active small { color: inherit; }
.sep { width: 1px; height: 22px; background: var(--line); }
.hint { margin: 0; max-width: 46ch; text-align: center; font-size: 14px; color: var(--muted); }

/* ---------- панель справа ---------- */
.panel { background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h2 { margin: 0; font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat { margin: 0; display: grid; gap: 8px; }
.stat div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.stat dt { color: var(--muted); }
.stat dd { margin: 0; text-align: right; font-weight: 500; }
.stat dd.ok::before, .stat dd.bad::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: #3C9B5B; }
.stat dd.bad::before { background: #C4483B; }
.log { margin: 0; padding: 0; list-style: none; font: 400 12.5px/1.55 var(--mono); color: var(--muted); max-height: 260px; overflow: auto; display: flex; flex-direction: column-reverse; }
.log li { overflow-wrap: anywhere; }
.log li:first-child { color: var(--text); }

/* ---------- вход ---------- */
.login { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); }
.login-card { width: min(100%, 340px); background: var(--panel); border: 1.5px solid var(--text); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.login-card h1 { margin: 0; font-size: 26px; }
.login-card p { margin: 0 0 8px; color: var(--muted); }
.login-card label { font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.login-card input { font: inherit; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.login-card .error { color: #C4483B; margin: 0; font-size: 14px; }
.go { margin-top: 6px; border: 0; border-radius: 8px; padding: 11px 16px; font-weight: 600; background: var(--text); color: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  .device.buzz { animation: none; }
  .device.rec .knob::after { animation: none; opacity: .6; }
}
