:root {
  --bg: #100c1c;
  --panel: #17132a;
  --panel-2: #1e1836;
  --input: #221c3d;
  --text: #f1eefc;
  --text-dim: #a79fc4;
  --border: #2c2547;
  --accent: #a985ff;
  --accent-2: #ff6fa5;
  --ok: #35d19a;
  --danger: #ff5c6d;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: "Heebo", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(169,133,255,.16), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(255,111,165,.12), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-inline: 16px;
  padding-block: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-bottom));
  min-height: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
select { font: inherit; color: inherit; }

/* ---------- gate ---------- */
.gate { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; }
.gate-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px 28px; box-shadow: var(--shadow);
}
.gate-logo { font-size: 24px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.gate-logo span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gate-lede { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin-bottom: 14px; }
.btn-primary {
  margin-top: 10px; padding: 13px 20px; border-radius: 999px; font-weight: 700; font-size: 15px; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 6px 20px -6px rgba(169,133,255,.55);
}
.btn-primary:active { transform: translateY(1px); }
.gate-error { color: var(--danger); font-size: 13px; margin-top: 14px; }
.gate-examples { margin-top: 18px; text-align: start; }
.gate-examples-title { color: var(--text-dim); font-size: 12.5px; margin-bottom: 6px; }
.gate-examples ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.gate-examples li { font-size: 12.5px; color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }

/* ---------- modal overlays (admin gate/panel, display) ---------- */
.admin-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(16,12,28,.88); backdrop-filter: blur(2px); padding-inline: 16px; }
.admin-password-input { width: 100%; margin-top: 4px; }
.admin-cancel { width: 100%; margin-top: 8px; }
.admin-panel-card, .display-card, .status-card { max-width: 460px; text-align: start; max-height: 80vh; overflow-y: auto; }
.admin-panel-card .gate-logo, .display-card .gate-logo, .status-card .gate-logo { justify-content: center; }
.display-text { font-size: 22px; line-height: 1.6; text-align: center; }

/* ---------- status panel ("מה הותקן כבר") ---------- */
.status-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.status-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.status-item-head { display: flex; align-items: center; gap: 8px; }
.status-badge { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-badge.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-badge.setup { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); }
.status-item-label { font-size: 13.5px; font-weight: 600; }
.status-item-detail { font-size: 11.5px; color: var(--text-dim); margin: 3px 0 0 17px; line-height: 1.5; }
.status-control { margin: 10px 0 0 17px; display: flex; flex-direction: column; gap: 8px; }
.status-control-row { display: flex; gap: 6px; }
.status-control-row input, .status-control-row select { flex: 1; min-width: 0; }
.status-control-row .btn-ghost { padding: 8px 12px; font-size: 12.5px; white-space: nowrap; }
.status-memory-list { display: flex; flex-direction: column; gap: 5px; max-height: 120px; overflow-y: auto; }
.status-memory-note { background: var(--input); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.status-memory-empty { font-size: 12px; color: var(--text-dim); }
.display-image { max-width: 100%; border-radius: 12px; margin-top: 4px; }

/* ---------- radio mini-player ---------- */
.radio-player {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 8px 8px 16px; font-size: 13px;
}

/* ---------- app shell ---------- */
.app { max-width: 640px; margin-inline: auto; display: flex; flex-direction: column; min-height: calc(100vh - 40px); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 6px 4px 18px; }
.brand { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.header-tools { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-tool {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.btn-tool:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- stage ---------- */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: 10px; }
.orb-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.orb {
  width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.25), transparent 60%),
              linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.orb-idle { opacity: .55; }
.orb-listening { animation: pulse 1.4s ease-in-out infinite; }
.orb-thinking { animation: spin 1.6s linear infinite; }
.orb-speaking { animation: pulse 0.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes spin { to { transform: rotate(360deg); } }
.state-label { color: var(--text-dim); font-size: 13.5px; text-align: center; }

.transcript {
  width: 100%; flex: 1; min-height: 160px; max-height: 42vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 4px 2px;
}
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.5; }
.msg-user { align-self: flex-end; background: var(--input); border: 1px solid var(--border); }
.msg-nigi { align-self: flex-start; background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); }

.controls-row { display: flex; gap: 10px; width: 100%; padding-bottom: 6px; }
.btn-talk { flex: 1; }
.btn-ghost {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 12px 18px; font-size: 14px; font-weight: 600; color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
a.btn-ghost, a.btn-tool { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.btn-ghost { display: flex; width: 100%; }

/* ---------- side panels (settings / devices) ---------- */
.side-panel {
  position: fixed; inset-inline-end: 12px; top: 70px; z-index: 40;
  width: 300px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 90px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.side-panel-head { display: flex; align-items: center; justify-content: space-between; }
.side-panel-head h3 { font-size: 15px; font-weight: 700; }
.qi-remove {
  width: 26px; height: 26px; border-radius: 50%; color: var(--text-dim); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.qi-remove:hover { background: rgba(255,92,109,.15); color: var(--danger); }
.panel-row { display: flex; flex-direction: column; gap: 6px; }
.panel-row label { font-size: 12.5px; color: var(--text-dim); }
.panel-row select, .panel-row input, .admin-password-input {
  background: var(--input); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; outline: none; color: var(--text); font-family: inherit;
}
.panel-row select:focus, .panel-row input:focus, .admin-password-input:focus { border-color: var(--accent); }
.panel-hint { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }
#camera-preview { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 18px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 50;
  max-width: calc(100vw - 32px); text-align: center;
}

@media (max-width: 480px) {
  .side-panel { inset-inline: 12px; width: auto; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .btn-tool { padding: 7px 10px; font-size: 12px; }
}
