:root {
  --bg: #06061a;
  --bg-elev: #0e0e24;
  --card: #12122e;
  --card-hover: #16163a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4fb;
  --muted: #9a9ab5;
  --faint: #6b6b88;
  --accent: #00e5ff;
  --accent-2: #7c3aed;
  --danger: #ff5470;
  --danger-bg: rgba(255, 84, 112, 0.12);
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(ellipse 70% 40% at 100% 100%, rgba(0, 229, 255, 0.08), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

.view { min-height: 100vh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px; color: #06061a;
  background: linear-gradient(135deg, #00e5ff, #00b8d4);
}
.brand-name { font-weight: 800; letter-spacing: -0.02em; font-size: 17px; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, opacity .18s ease, border-color .18s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  color: var(--text);
  background: transparent;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

.btn-primary {
  background: linear-gradient(135deg, #00e5ff, #00b8d4);
  color: #06061a;
  box-shadow: 0 8px 22px -10px rgba(0, 229, 255, .5);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(255, 84, 112, .35);
  color: #ff8098;
}
.btn-danger:hover:not(:disabled) { background: rgba(255, 84, 112, .2); }

.btn-neutral {
  background: rgba(255, 255, 255, .05);
  border-color: var(--border);
  color: var(--text);
}
.btn-neutral:hover:not(:disabled) { background: rgba(255, 255, 255, .09); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }

/* Stealth / secondary action (Fake Shutdown) — outline, deliberately muted */
.btn-stealth {
  background: transparent;
  border-color: var(--border-strong);
  border-style: dashed;
  color: var(--muted);
}
.btn-stealth:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, .04); border-color: var(--faint); }

/* ---------- Spinner ---------- */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.btn-primary .spinner { border-color: rgba(6, 6, 26, .35); border-top-color: #06061a; }
.spinner-lg { width: 26px; height: 26px; border-width: 3px; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
#login-view { align-items: center; justify-content: center; padding: 24px; }
.login-wrap {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 26px 26px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .8);
}
.login-title { font-size: 26px; margin: 22px 0 6px; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; line-height: 1.5; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 229, 255, .12); }
.error-line { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 12px; line-height: 1.4; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--faint); font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
#google-btn { gap: 10px; }
.login-foot { color: var(--faint); font-size: 12px; text-align: center; margin: 18px 0 0; line-height: 1.5; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 6, 26, .7);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-email { font-size: 13px; color: var(--muted); max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Content ---------- */
.content { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 24px 18px 8px; }
.content-head h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
.content-head .muted { font-size: 14px; margin: 0 0 20px; }

.devices { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Device card ---------- */
.device-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .18s ease;
}
.device-card:hover { border-color: var(--border-strong); }

.dev-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dev-name { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.dev-meta { margin: 5px 0 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.dev-meta .dot::before { content: "·"; margin-right: 10px; color: var(--faint); }
.platform-badge {
  flex-shrink: 0;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent);
  background: rgba(0, 229, 255, .08);
  border: 1px solid rgba(0, 229, 255, .18);
  padding: 4px 9px; border-radius: 999px;
}

.online-note {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--faint); margin-top: 12px;
}
.online-note::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, .18);
}

/* ---------- Actions ---------- */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.actions .btn-primary { grid-column: 1 / -1; }
.actions [data-cmd="locate"] { grid-column: 1 / -1; }
.actions [data-cmd="capture_photo"] { grid-column: 1 / -1; }
.actions [data-cmd="fake_shutdown"] { grid-column: 1 / -1; }

.fake-help {
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.5;
  margin: 8px 2px 0;
}

/* ---------- Fake Shutdown: exit guide ---------- */
.fake-exit-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 8px 2px 2px; margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}
.fake-exit-toggle:hover { text-decoration: underline; }
.fake-exit-toggle .chev { transition: transform .18s ease; display: inline-block; font-size: 15px; line-height: 1; }
.fake-exit-toggle.open .chev { transform: rotate(90deg); }

.fake-exit-guide {
  display: flex; gap: 16px; align-items: center;
  margin-top: 12px; padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.exit-diagram { position: relative; flex-shrink: 0; line-height: 0; }
.exit-badge {
  position: absolute; top: 44px; left: 60px;
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: rgba(0, 229, 255, .1); border: 1px solid rgba(0, 229, 255, .25);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap; line-height: 1.2;
}
.hotspot-ring { animation: hotspot 1.8s ease-in-out infinite; transform-origin: 34px 40px; }
@keyframes hotspot {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}
.exit-steps {
  margin: 0; padding-left: 18px;
  font-size: 13px; color: var(--muted); line-height: 1.55;
  display: flex; flex-direction: column; gap: 4px;
}
.exit-steps strong { color: var(--text); }
.exit-note { font-size: 11.5px; color: var(--faint); line-height: 1.5; margin: 10px 0 0; }

@media (max-width: 440px) {
  .fake-exit-guide { flex-direction: column; align-items: flex-start; }
}

/* Inline confirm bar */
.confirm-bar {
  margin-top: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.confirm-text { font-size: 14px; font-weight: 600; }
.confirm-text .muted { font-weight: 400; }
.confirm-actions { display: flex; gap: 8px; }

/* ---------- Location ---------- */
.location-slot { margin-top: 4px; }
.locate-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  padding: 10px 12px; margin-top: 12px;
  border-radius: var(--radius-sm);
}
.locate-status.locating { color: var(--accent); background: rgba(0, 229, 255, .07); border: 1px solid rgba(0, 229, 255, .18); }
.locate-status.offline { color: #ff8098; background: var(--danger-bg); border: 1px solid rgba(255, 84, 112, .3); }

.loc-panel { margin-top: 14px; }
.loc-map {
  width: 100%; height: 200px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: block; background: var(--bg-elev);
}
.loc-addr { font-size: 14px; color: var(--text); margin-top: 10px; line-height: 1.45; }
.loc-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-top: 8px; font-size: 13px;
}
.loc-link { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.loc-link:hover { text-decoration: underline; }
.loc-empty { font-size: 13px; margin-top: 14px; }

/* ---------- Request Photo ---------- */
.photo-help { font-size: 11.5px; color: var(--faint); line-height: 1.5; margin: 14px 2px 0; }
.photo-slot { margin-top: 4px; }
.capture-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  padding: 10px 12px; margin-top: 12px;
  border-radius: var(--radius-sm);
}
.capture-status.capturing { color: var(--accent); background: rgba(0, 229, 255, .07); border: 1px solid rgba(0, 229, 255, .18); }
.capture-status.fail { color: #ff8098; background: var(--danger-bg); border: 1px solid rgba(255, 84, 112, .3); }

.photo-panel { margin-top: 14px; }
.photo-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.photo-figure { margin: 0; }
.photo-img {
  width: 100%; max-width: 100%; max-height: 320px; height: auto;
  object-fit: contain; display: block;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.photo-cap {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.photo-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-top: 10px; font-size: 13px;
}
.photo-link { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.photo-link:hover { text-decoration: underline; }

@media (min-width: 520px) {
  .photo-grid.two { grid-template-columns: 1fr 1fr; }
}

/* ---------- Command history ---------- */
.history { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.history-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint); font-weight: 700; margin: 0 0 10px;
}
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px;
}
.cmd-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 600;
}
.cmd-pill .ico { font-size: 13px; }
.history-time { color: var(--faint); font-size: 12px; white-space: nowrap; }
.history-empty { color: var(--faint); font-size: 13px; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { font-size: 34px; margin-bottom: 10px; }
.empty p { margin: 4px 0; }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center; color: var(--faint); font-size: 12px;
  padding: 24px 18px 32px; line-height: 1.5;
}

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 10px;
  width: calc(100% - 32px); max-width: 420px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #1a1a3a;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 14px; line-height: 1.4;
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .7);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in .25s cubic-bezier(.2, .8, .2, 1);
}
.toast.leaving { animation: toast-out .2s ease forwards; }
.toast .t-ico { flex-shrink: 0; font-size: 15px; margin-top: 1px; }
.toast.ok { border-color: rgba(52, 211, 153, .4); }
.toast.err { border-color: rgba(255, 84, 112, .45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

@media (min-width: 560px) {
  .user-email { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
