:root,
:root[data-theme="dark"] {
  --bg: #121418;
  --card: #1b1e24;
  --card-2: #23272f;
  --line: #2f343d;
  --text: #eef0f3;
  --muted: #9aa1ad;
  --accent: #ffb547;
  --accent-ink: #1d1404;
  --accent-soft: rgba(255, 181, 71, 0.16);
  --warn: #ff8a7a;
  --ok: #6fd69a;
  --avatar-body: #e9e6df;
  --avatar-head: #f6f4ef;
  --avatar-line: #2a2d33;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f2ee;
  --card: #ffffff;
  --card-2: #f6f4f0;
  --line: #e2ded6;
  --text: #1c1d21;
  --muted: #6b6f78;
  --accent: #f29d14;
  --accent-ink: #1d1404;
  --accent-soft: rgba(242, 157, 20, 0.14);
  --warn: #c8432f;
  --ok: #1f8a4c;
  --avatar-body: #d9d4c8;
  --avatar-head: #ffffff;
  --avatar-line: #2a2d33;
  --shadow: 0 1px 2px rgba(30, 25, 10, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#root { min-height: 100vh; }

h1, h2, p { margin: 0; }
h1 { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

kbd {
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 5px;
  margin-left: 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--muted);
}

.app { max-width: 1240px; margin: 0 auto; padding: 16px; }

.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand p { font-size: 13px; }

.pill {
  font-size: 12.5px; font-weight: 600;
  padding: 5px 10px 5px 22px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  position: relative;
}
.pill::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px;
  margin-top: -3.5px; border-radius: 50%; background: var(--ok);
}
.pill.off::before { background: var(--warn); }

.banner {
  margin-bottom: 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  font-size: 14px;
}

.grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 14px; align-items: start; }
.col { display: grid; gap: 14px; }

@media (max-width: 1000px) { .grid { grid-template-columns: 1fr 1fr; } .grid > .col:first-child { grid-column: 1 / -1; } }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } .app { padding: 12px; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}

/* Camera */
.camera { padding: 10px; }
.camera-frame {
  position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden;
  background: #0b0c0e; display: grid; place-items: center;
}
:root[data-theme="light"] .camera-frame { background: #e9e5dc; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.video-note { position: absolute; color: #c9ced6; font-size: 14px; padding: 12px; text-align: center; }
.video-note:empty { display: none; }
.camera-meta { display: flex; justify-content: space-between; padding: 8px 4px 0; font-size: 13px; }

.avatar { width: 100%; height: 100%; }
.av-body { fill: var(--avatar-body); stroke: var(--avatar-line); stroke-width: 3; }
.av-body-mark { fill: var(--accent); }
.av-head { fill: var(--avatar-head); stroke: var(--avatar-line); stroke-width: 3; }
.av-eye { fill: #1c1d21; }
.av-pupil { fill: #f6f4ef; opacity: 0.9; }
.av-ant-r line, .av-ant-l line { stroke: var(--avatar-line); stroke-width: 4; stroke-linecap: round; }
:root[data-theme="dark"] .av-ant-r line, :root[data-theme="dark"] .av-ant-l line { stroke: #cfd3da; }
.av-ant-r circle, .av-ant-l circle { fill: var(--accent); }

/* Head pad */
.pad {
  position: relative; aspect-ratio: 1; border-radius: 14px; margin-bottom: 14px;
  background:
    radial-gradient(circle at center, var(--accent-soft), transparent 70%),
    var(--card-2);
  border: 1px solid var(--line);
  touch-action: none; cursor: crosshair; user-select: none;
}
.pad:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pad-cross::before, .pad-cross::after { content: ""; position: absolute; background: var(--line); }
.pad-cross::before { left: 50%; top: 10%; bottom: 10%; width: 1px; }
.pad-cross::after { top: 50%; left: 10%; right: 10%; height: 1px; }
.pad-label { position: absolute; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pad-label.top { top: 8px; left: 50%; transform: translateX(-50%); }
.pad-label.bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.pad-label.left { left: 10px; top: 50%; transform: translateY(-50%); }
.pad-label.right { right: 10px; top: 50%; transform: translateY(-50%); }
.pad-dot {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); transition: transform 0.12s; pointer-events: none;
}
.pad.active .pad-dot { transform: scale(1.15); }

/* Sliders */
.slider + .slider { margin-top: 12px; }
.slider-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-bottom: 4px; }
.slider output { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 26px; margin: 0; }

.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Buttons */
button {
  font: inherit; font-size: 14px; font-weight: 550; color: var(--text);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.wide { width: 100%; margin-top: 10px; }
button.toggle.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.toggle.on kbd { color: var(--accent-ink); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

.emotes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.emote { justify-content: flex-start; }
.emote kbd { margin-left: auto; }
.emote-icon {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
}
.emote.playing { border-color: var(--accent); background: var(--accent-soft); }

/* Activity log */
.log { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; min-height: 60px; }
.log li { font-size: 13.5px; display: flex; gap: 10px; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.log li.warn { color: var(--warn); }

/* Fatal error */
.fatal { max-width: 440px; margin: 15vh auto; padding: 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.fatal p { color: var(--muted); }

/* Phones: one column, activity log last, no keyboard hints. */
@media (max-width: 640px) {
  .col { display: contents; }
  .log-card { order: 10; }
}
@media (hover: none) {
  kbd, .log-card .small { display: none; }
}
.emote { white-space: nowrap; }
