: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 (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; } }

.device {
  position: relative;
  width: calc(135px * 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(135px * var(--scale)); height: calc(240px * var(--scale)); image-rendering: pixelated; border-radius: 5px; background: #000; }

.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; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.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 .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: 360px; }
dialog::backdrop { background: #000a; }
dialog h3 { margin: 0 0 6px; }
dialog input { width: 100%; margin: 10px 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); }
