/* Layout: full-height 3D desk on the left, a narrow "bench panel" on the right (stacks under the scene on phones) */
:root {
  --bg: #15171b;        /* night desk */
  --panel: #1d2026;
  --line: #2c3038;
  --fg: #e8e4dc;        /* PLA off-white */
  --muted: #8e939c;
  --accent: #f2a33a;    /* orange PLA, Maylo's arms */
  --screen: #7df9d0;    /* face screen glow */
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--display); overflow: hidden; }
.app { display: grid; grid-template-columns: minmax(0, 1fr) 330px; height: 100%; }
.stage { position: relative; min-width: 0; min-height: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene.on-robot { cursor: pointer; }
.ask { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); right: 16px; bottom: 14px;
  display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.ask input { flex: 1; min-width: 0; font: 15px var(--display); color: var(--fg); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.ask input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask input:disabled { opacity: .6; }
.ask button { background: var(--panel); padding: 9px 14px; white-space: nowrap; }
.ask #askSend { background: var(--accent); color: #1b1407; border-color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.bubble { position: absolute; transform: translate(-50%, -100%); max-width: min(340px, 80%); pointer-events: none;
  background: var(--fg); color: var(--bg); font-size: 15px; line-height: 1.45; padding: 10px 14px; border-radius: 14px; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
  border: 7px solid transparent; border-bottom: 0; border-top-color: var(--fg); }
.hint { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: 72px; margin: 0;
  font-size: 13px; color: var(--muted); background: color-mix(in srgb, var(--bg) 80%, transparent);
  padding: 6px 10px; border-radius: 8px; pointer-events: none; }
.hint b { color: var(--fg); font-weight: 600; }

.panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto;
  padding-block: 20px 28px; padding-left: 20px; padding-right: max(20px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 22px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.chip { font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--screen); white-space: nowrap; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 10px; }

.servo { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 10px; margin-bottom: 10px;
  font-family: var(--mono); font-size: 13px; }
.servo .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg); }
.servo .name { color: var(--muted); }
.track { position: relative; height: 8px; border-radius: 4px; background: var(--line); }
.track .tgt, .track .cur { position: absolute; top: -4px; width: 3px; height: 16px; border-radius: 2px; transform: translateX(-50%); }
.track .tgt { background: var(--muted); opacity: .6; }
.track .cur { background: var(--accent); }
.range { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 0; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
button { font: 600 14px var(--display); color: var(--fg); background: transparent; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 6px; cursor: pointer; transition: border-color .15s, background .15s; }
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:active { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.grid.two { grid-template-columns: 1fr 1fr; }
input[type=range] { width: 100%; accent-color: var(--accent); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.log { list-style: none; margin: 0; padding: 10px 12px; border-radius: 10px; background: #0f1114;
  font-family: var(--mono); font-size: 12px; line-height: 1.7; min-height: 120px; }
.log li { display: grid; grid-template-columns: 58px 48px 1fr; color: var(--muted); }
.log li:first-child { color: var(--screen); }
.log .empty { display: block; }
.note { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; max-width: 60ch; }
code { font-family: var(--mono); color: var(--fg); }

@media (max-width: 760px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: 62vh auto; height: auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible;
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}

/* Shown only when the config files can't load (page opened from disk) */
.load-error { position: absolute; inset: 16px; margin: auto; height: fit-content; max-width: 520px; z-index: 5;
  background: var(--panel); border: 1px solid #ff5c5c; border-radius: 12px; padding: 16px; line-height: 1.5; }

/* Visitor color picker: one row of round swatches per part */
.swatch-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.swatch-label { width: 100px; flex: none; font-size: 13px; color: var(--muted); }
.swatch { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.swatch[aria-pressed="true"] { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg) inset; }

/* Admin page: the admin panel takes the side column, wider than the visitor panel */
body[data-page="admin"] .app { grid-template-columns: minmax(0, 1fr) 460px; }
.admin-panel { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.admin-top { padding-block: 16px 8px; padding-left: 20px; padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.admin-top .head h1 { font-size: 24px; }
.live { margin-top: 12px; }
.live summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.live[open] summary { margin-bottom: 10px; }
.live .log { min-height: 0; max-height: 130px; overflow: hidden; }
.live .grid.two { margin-top: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding-inline: 20px; }
.tabs button { padding: 6px 12px; font-size: 13px; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #1b1407; border-color: var(--accent); }
.tabs button.edited::after { content: " •"; color: var(--accent); }
.tabs button[aria-selected="true"].edited::after { color: #1b1407; }
.admin-file { margin: 10px 20px 0; font: 12px var(--mono); color: var(--muted); }
.admin-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 20px; }
.admin-foot { padding: 12px 20px; border-top: 1px solid var(--line); }
.admin-foot .buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-foot button { flex: 1; font-size: 13px; }
#adminSave { background: var(--accent); color: #1b1407; border-color: var(--accent); }
#adminSave:disabled { background: transparent; color: var(--muted); border-color: var(--line); cursor: default; }
.admin-msg { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; min-height: 1.4em; }
.admin-msg.bad { color: #ff8a8a; }
.admin-panel fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0 0; padding: 4px 12px 10px; min-width: 0; }
.admin-panel legend { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 4px; }
.admin-panel .help { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 8px 0; }
.admin-panel .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 10px; align-items: center; margin-top: 8px; font-size: 14px; }
.admin-panel .row.wide { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.admin-panel input[type=text], .admin-panel input[type=number], .admin-panel select, .admin-panel textarea {
  width: 100%; box-sizing: border-box; font: 13px var(--mono); color: var(--fg); background: #0f1114;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.admin-panel textarea { resize: vertical; line-height: 1.45; }
.admin-panel input:focus-visible, .admin-panel select:focus-visible, .admin-panel textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.admin-panel .bad { border-color: #ff5c5c; }
.admin-panel .err { color: #ff8a8a; font-size: 12px; margin: 2px 0 0; }
.admin-panel .color { display: flex; gap: 8px; align-items: center; }
.admin-panel input[type=color] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.admin-panel .hex { flex: 1; min-width: 0; }
.admin-panel .icon { padding: 4px 9px; font-size: 12px; }
.admin-panel .tools { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.admin-panel .tools button { padding: 4px 10px; font-size: 12px; }
.admin-panel .danger:hover { border-color: #ff5c5c; color: #ff8a8a; }
.admin-panel .newmove { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 760px) {
  body[data-page="admin"] .app { grid-template-columns: 1fr; }
  .admin-panel { border-left: 0; border-top: 1px solid var(--line); }
  .admin-body { overflow: visible; }
}
.btnlink { display: flex; align-items: center; justify-content: center; font: 600 14px var(--display); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 6px; text-decoration: none; }
.btnlink:hover { border-color: var(--accent); }
