:root {
  --bg: #0b0e14;
  --panel: #121722;
  --panel-2: #182030;
  --line: #243044;
  --text: #e6edf7;
  --dim: #8b9ab3;
  --accent: #2ff3d1;
  --warn: #ffb52e;
  --bad: #ff5a4d;
  --orange: #ff6b1a;
  --orange-dark: #d94f08;
  --scale: 2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", "Arial Hebrew", Arial, sans-serif;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.5px; }
.brand .sub { color: var(--dim); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); align-self: center; box-shadow: 0 0 8px currentColor; color: var(--bad); }
.dot.on { background: var(--accent); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 2px 11px; font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.chip.ok { color: var(--accent); border-color: #1b5f55; }
.chip.warn { color: var(--warn); border-color: #6b4f1a; }

.banner { margin: 12px 18px 0; padding: 12px 14px; border: 1px solid #6b4f1a; border-radius: 12px; background: #1d170a; color: #ffe2a8; }
.banner b { color: #fff; }
.banner code { display: block; margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: #0c0a05; color: #ffd98a; direction: ltr; text-align: left; overflow-x: auto; white-space: nowrap; }

.layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 18px; padding: 18px; align-items: start; }
@media (min-width: 761px) { .layout.wide { grid-template-columns: minmax(300px, 560px) minmax(0, 1fr); } } /* the CoreS3's screen is wider */
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } }

/* ---- the device ---- */
.stage { display: flex; flex-direction: column; align-items: center; gap: 10px; position: sticky; top: 12px; }
@media (max-width: 760px) { .stage { position: static; } }

/* which device the simulator stands in for */
.kindpick { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--panel); }
.kindpick button { border: 0; border-radius: 0; background: transparent; color: var(--dim); font: inherit; font-size: 13px; padding: 5px 16px; cursor: pointer; }
.kindpick button.on { background: var(--accent); color: #04211c; font-weight: 600; }
.kindpick button:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.kindnote { margin: -4px 0 4px; color: var(--dim); font-size: 12px; text-align: center; }

.device {
  position: relative;
  width: calc(var(--sw, 135) * 1px * var(--scale) + 36px);
  padding: 22px 18px 20px;
  border-radius: 26px;
  background: linear-gradient(160deg, #ff7e33, var(--orange) 45%, var(--orange-dark));
  box-shadow: 0 18px 40px #0009, inset 0 2px 0 #ffffff55, inset 0 -3px 0 #0003;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.device-grill { display: flex; gap: 5px; height: 4px; }
.device-grill i { width: 4px; height: 4px; border-radius: 50%; background: #7a2c03; box-shadow: inset 0 1px 1px #0006; }

.bezel { padding: 7px; border-radius: 12px; background: #050608; box-shadow: inset 0 0 0 1px #000, 0 1px 0 #ffffff40; line-height: 0; }
#screen { width: calc(var(--sw, 135) * 1px * var(--scale)); height: calc(240px * var(--scale)); image-rendering: pixelated; border-radius: 5px; background: #000; transition: filter 0.4s; }
#screen.asleep { filter: brightness(0.5); } /* while the face sleeps the device turns its light down */

/* the CoreS3: a dark, wider body, and no buttons: its screen is touched */
.device.cores3 { padding: 24px 18px 20px; border-radius: 20px; background: linear-gradient(160deg, #4b5160, #2b2f39 45%, #1a1c22); box-shadow: 0 18px 40px #0009, inset 0 2px 0 #ffffff30, inset 0 -3px 0 #0005; }
.device.cores3 .btn-a, .device.cores3 .btn-b { display: none; }
.device.cores3 .device-grill i { background: #0c0d10; }
.device.cores3 .device-label { color: #8a93a6; }
.device.cores3 #screen { cursor: pointer; touch-action: none; }

.btn-a {
  width: 74px; height: 74px; border-radius: 50%;
  border: 0; cursor: pointer; color: #5a2204;
  background: radial-gradient(circle at 35% 30%, #ffb07a, #ff7a2e 55%, #cf4a06);
  box-shadow: 0 5px 0 #a03a05, 0 9px 14px #0007, inset 0 2px 0 #ffffff66;
  display: grid; place-items: center;
  touch-action: none;
  transition: transform 60ms, box-shadow 60ms;
}
.btn-a.down { transform: translateY(4px); box-shadow: 0 1px 0 #a03a05, 0 3px 6px #0007, inset 0 2px 0 #ffffff44; color: #fff; }
.btn-a:focus-visible, .btn-b:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.btn-b {
  position: absolute; inset-inline-end: -7px; top: 120px;
  width: 9px; height: 54px; border: 0; padding: 0; cursor: pointer;
  border-radius: 0 5px 5px 0;
  background: linear-gradient(90deg, #b84407, #e8601a);
  box-shadow: 2px 2px 5px #0008;
  touch-action: none;
}
[dir="rtl"] .btn-b { inset-inline-end: auto; right: -7px; }
.btn-b.down { transform: translateX(-3px); }

.device-label { font: 600 9px/1 ui-monospace, Menlo, monospace; letter-spacing: 3px; color: #7a2c03; }

.hint { margin: 4px 0 0; color: var(--dim); font-size: 13px; text-align: center; max-width: 320px; }
.state { margin: 0; font-size: 13px; color: var(--accent); min-height: 1.4em; }
.meter { width: 200px; height: 6px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #b6ff3c); transition: width 60ms linear; }

/* ---- the panel ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; min-height: 520px; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }  /* eight tabs: a narrow window gets two rows, none is hidden */
.tab { border: 0; background: none; color: var(--dim); font: inherit; padding: 9px 14px; border-radius: 10px 10px 0 0; cursor: pointer; white-space: nowrap; }
.tab.on { background: var(--panel-2); color: var(--text); }
.pane { display: none; padding: 14px 16px 18px; flex: 1; flex-direction: column; gap: 10px; min-height: 0; }
.pane.on { display: flex; }
.pane h3 { margin: 8px 0 0; font-size: 14px; color: var(--accent); font-weight: 600; }
.note { margin: 0; color: var(--dim); font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

button, select, input { font: inherit; color: var(--text); }
button { background: #1d6f63; border: 1px solid #2a9484; border-radius: 10px; padding: 7px 14px; cursor: pointer; }
button:hover { background: #238576; }
button.ghost { background: var(--panel-2); border-color: var(--line); }
button.ghost:hover, button.ghost.on { border-color: var(--accent); color: var(--accent); }
select, input:not([type="range"]):not([type="color"]) { background: #0c111b; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; min-width: 0; }
label { display: inline-flex; gap: 8px; align-items: center; color: var(--dim); font-size: 13.5px; }

.chat { flex: 1; min-height: 260px; max-height: 58vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.chat .empty { color: var(--dim); margin: auto; text-align: center; max-width: 300px; }
.bubble { max-width: 86%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-start; background: #1b2a44; border-end-start-radius: 4px; }
.bubble.bot { align-self: flex-end; background: #14332e; border-end-end-radius: 4px; }
.bubble.note { align-self: center; background: none; color: var(--dim); font-size: 12.5px; padding: 0; }
.bubble img.shot { display: block; max-width: min(220px, 100%); border-radius: 8px; border: 1px solid var(--line); }
.bubble .meta { display: block; margin-top: 4px; font-size: 11.5px; color: var(--dim); direction: rtl; }
.bubble .tag { display: inline-block; margin-inline-end: 6px; padding: 0 7px; border-radius: 999px; border: 1px solid #2a9484; color: var(--accent); font-size: 11px; }

.send { display: flex; gap: 8px; }
.send input { flex: 1; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 12px; color: var(--dim); }
.tile canvas { width: 54px; height: 96px; image-rendering: pixelated; border-radius: 4px; background: #000; }
.tile.on { border-color: var(--accent); color: var(--accent); }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 18px; }
.controls label { display: grid; grid-template-columns: 96px 1fr 38px; gap: 8px; }
.controls input[type="range"] { width: 100%; accent-color: var(--accent); }
.controls input[type="color"] { width: 100%; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; }
.controls output { color: var(--text); font-variant-numeric: tabular-nums; text-align: end; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 13.5px; }
.kv b { color: var(--dim); font-weight: normal; }
.kv span { overflow-wrap: anywhere; text-align: right; }

.log { margin: 0; flex: 1; min-height: 140px; max-height: 240px; overflow: auto; background: #080b11; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: 11.5px/1.5 ui-monospace, Menlo, monospace; color: #9fb3cf; white-space: pre-wrap; }

.toast { position: fixed; inset-inline: 0; bottom: 22px; margin: auto; width: fit-content; max-width: 90vw; padding: 9px 16px; border-radius: 12px; background: #000c; border: 1px solid var(--line); z-index: 5; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; max-width: 440px; }
dialog::backdrop { background: #000a; }
dialog h3 { margin: 0 0 6px; }
dialog input { width: 100%; margin: 10px 0; }
dialog code { display: block; padding: 6px 10px; border-radius: 8px; background: #0c0f16; direction: ltr; text-align: left; overflow-x: auto; white-space: nowrap; font-size: 12px; }
dialog p.note { margin: 6px 0; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.92em; }

.volume { font-size: 12.5px; }
.volume input { width: 130px; accent-color: var(--accent); }

/* the memory tab */
textarea { width: 100%; box-sizing: border-box; margin: 10px 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; line-height: 1.55; resize: vertical; }
textarea:focus-visible { outline: 2px solid #2a9484; outline-offset: 1px; }
.memlist { margin: 6px 0 10px; padding: 0 18px 0 0; font-size: 13.5px; line-height: 1.6; }
.memlist li b { color: var(--dim); font-weight: normal; margin-inline-end: 6px; }
.memlist .empty { list-style: none; color: var(--dim); margin-inline-start: -18px; }

/* the extras tab: switches */
.switch { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 24px; margin: 2px 0 0; border-radius: 12px; background: #3a4150; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.switch input:checked { background: #1d9a86; }
.switch input:checked::after { inset-inline-start: 21px; }
.switch input:disabled { opacity: .45; cursor: not-allowed; }
.switch input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.switch span { font-size: 13px; color: var(--dim); line-height: 1.5; }
.switch b { display: block; color: var(--text); font-size: 14.5px; font-weight: 600; }
.memlist button { padding: 1px 9px; margin-inline-start: 8px; font-size: 12px; }
.calhelp { margin: 0 4px 12px; }
/* the extras tab: voice services and their keys */
.svcstate { min-height: 18px; margin: 4px 0 12px; }
.svcstate.bad { color: #ff8a7a; }
.svcstate.good { color: #7fe3d0; }
.svcstate small { display: block; opacity: .75; }
.keyrow { padding: 10px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.keyrow b { font-size: 14.5px; }
.keyrow .has { color: #7fe3d0; font-size: 12.5px; margin-inline-start: 8px; }
.keyrow p { margin: 2px 0 8px; }
.keyrow a { color: #7fe3d0; }
.keyrow input { flex: 1 1 180px; min-width: 0; }
.keyline { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.keyline span { flex: 1; color: var(--dim); }
.keyline span.on { color: #7fe3d0; }
.keyline span.off { color: #ffb59a; }
.keyline button { padding: 1px 9px; font-size: 12px; }
select option:disabled { color: #6b7280; }
.calhelp p { margin: 0 0 4px; }
.calhelp ol { margin: 0 0 8px; padding-inline-start: 20px; line-height: 1.7; }
.calhelp a { color: #7fe3d0; }

/* the history tab: conversations as they were said */
.history { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; max-height: 62vh; overflow-y: auto; padding: 2px; }
.history h4 { margin: 10px 0 0; font-size: 12.5px; font-weight: 600; color: var(--dim); position: sticky; top: 0; background: var(--panel); padding: 4px 0; z-index: 1; }
.history .conv { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.history .conv header { font-size: 12px; color: var(--dim); }
.history .bubble { font-size: 14px; }
.history .bubble.note { align-self: stretch; text-align: center; }
.history .empty { color: var(--dim); text-align: center; margin: 24px auto; max-width: 320px; }
#histForm { margin-top: 8px; }
.switch.inner { margin-inline-start: 28px; }
.switch[hidden] { display: none; }

/* a new reminder, written in the panel */
.remform { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.remform label { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.remform input[type="date"], .remform input[type="time"] { color-scheme: dark; }

/* the Claude Code sessions the assistant may pass instructions to */
.codebox { margin: 0 4px 12px 28px; }
.codebox[hidden] { display: none; }
.codebox #codeName { flex: 1 1 130px; }
.codebox #codeLink { flex: 3 1 240px; }

/* interpreter mode, in the chat tab */
.interp { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; font-size: 13px; color: var(--dim); }
.interp[hidden] { display: none; }
.interp.on { color: var(--accent); }
.interp select { padding: 4px 8px; }
.interp button { padding: 4px 12px; }

/* the WiFi networks a device sees: a name, how strong, and where to put it */
.netnow { margin: 2px 0 10px; padding: 8px 12px; border: 1px solid var(--line, #22313a); border-radius: 10px; }
.netnow b { font-weight: 600; overflow-wrap: anywhere; }
.nets { display: grid; gap: 6px; margin: 4px 0 12px; }
.nets .net { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line, #22313a); border-radius: 10px; }
.nets .net b { flex: 1 1 140px; font-weight: 600; overflow-wrap: anywhere; }
.nets .net span { opacity: 0.7; font-size: 13px; }
.nets .net button { padding: 4px 10px; font-size: 13px; }

/* the account's other connectors: a heading, a note, one switch each */
.connbox { margin: 14px 0 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.connbox > b { display: block; margin-bottom: 4px; }
.connbox #connList { margin: 6px 0 10px; }
