/* mCard consumer shell — Teenage Engineering inspired: orange-cream, flat, monospace. */
:root {
  color-scheme: light;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --bg: #ece7db;
  --panel: #f7f4ec;
  --panel2: #e6e0d1;
  --field: #fbf9f1;
  --text: #1a1714;
  --muted: #8c8576;
  --accent: #ff4f00;
  --accent-ink: #ffffff;
  --accent2: #ff7a3c;
  --danger: #d23a2a;
  --ok: #3f9e57;
  --line: #cdc6b4;
  --hair: #1a1714;
  --topbar-bg: rgba(247, 244, 236, 0.85);
  --radius: 10px;
  /* Motion tokens — expo-out for movement, a restrained spring for tactile bits. */
  --dur-1: 120ms;   /* press / hover */
  --dur-2: 180ms;   /* toggles, popover, modal */
  --dur-3: 260ms;   /* page / section enter */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font);
}
/* Keep monospace where digits must stay crisp/aligned (stats, battery, versions, code). */
.dstat-kv b, .devbar-bat, .vid-meta, .cb-status, .trim, code, pre, .mono, textarea.mono { font-family: var(--font-mono); }
/* Dark theme — same TE palette, inverted surfaces. Toggled via <html data-theme="dark">. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110d;
  --panel: #1e1a15;
  --panel2: #2a251e;
  --field: #211d17;
  --text: #f3efe6;
  --muted: #9d9484;
  --accent: #ff5a1a;
  --accent-ink: #ffffff;
  --accent2: #ff7a3c;
  --danger: #ff6b5a;
  --ok: #5fbf78;
  --line: #38322a;
  --hair: #6a6253;
  --topbar-bg: rgba(30, 26, 21, 0.85);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }

/* ── Shell layout (top bar) ───────────────────────────────── */
.app-frame { display: flex; flex-direction: column; min-height: 100dvh; }
.app-frame--upload, .app-frame--studio { height: 100dvh; overflow: hidden; } /* editor caps to viewport — footer pinned, no page scroll */
.topbar {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg); backdrop-filter: blur(12px);
  padding-top: env(safe-area-inset-top); /* clear the notch on viewport-fit=cover */
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 11px 22px;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center; font-weight: 800; color: var(--accent-ink);
}
.brand b { font-size: 15px; letter-spacing: 0.01em; }
.brand small { display: block; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status-wrap { position: relative; }
.topbar-status {
  position: relative; width: 38px; height: 38px; border-radius: 9px;
  background: var(--panel2); border: 1px solid var(--line); cursor: pointer;
  display: grid; place-items: center; color: var(--text);
  transition: border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring);
}
.topbar-status:hover { border-color: var(--hair); color: var(--accent); }
.topbar-status:active { transform: scale(0.92); }
/* Language: globe icon over a transparent native <select> (keeps the OS dropdown). */
.lang-wrap { position: relative; }
.lang-wrap .lic { color: inherit; }
.lang-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; cursor: pointer; }
.topbar-status.on { color: var(--accent); }
.topbar-status .sdot {
  position: absolute; top: 5px; right: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: #b3aa98; border: 1.5px solid var(--panel2);
}
.topbar-status .sdot.online { background: var(--ok); }
.status-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 224px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: grid; gap: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  transform-origin: top right;
  /* Animatable hidden state (instead of display:none) so the popover springs open/closed. */
  opacity: 0; transform: translateY(-6px) scale(0.98); visibility: hidden;
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-spring), visibility 0s linear var(--dur-2);
}
.status-pop:not([hidden]) { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.sp-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sp-head b { font-size: 13px; }
.sp-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.sp-row span { display: inline-flex; align-items: center; gap: 6px; }
.sp-row b { color: var(--text); font-size: 13px; }
.status-pop .button { width: 100%; justify-content: center; }

.main { min-width: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.shell { max-width: 960px; width: 100%; margin: auto; padding: 26px 22px 60px; } /* margin:auto centers H + V */

/* Page enter — fires only on a real route change (.main--enter set in render()), not on
   the frequent same-route re-renders (BLE notify / 10s refresh), so it never re-triggers. */
@keyframes viewenter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Gentle, capped stagger of the top-level sections (one animated level — no compounding). */
.main--enter .shell > * { animation: viewenter var(--dur-3) var(--ease-out) both; }
.main--enter .shell > *:nth-child(1) { animation-delay: 20ms; }
.main--enter .shell > *:nth-child(2) { animation-delay: 65ms; }
.main--enter .shell > *:nth-child(3) { animation-delay: 110ms; }
.main--enter .shell > *:nth-child(4) { animation-delay: 155ms; }
.main--enter .shell > *:nth-child(n + 5) { animation-delay: 190ms; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero { padding: 26px 0 18px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.18em; font-size: 11px; color: var(--accent); margin: 0 0 10px; font-weight: 700; }
.hero h1 { font-size: clamp(26px, 4.6vw, 42px); line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 10px; }
.hero p { color: var(--muted); margin: 0; line-height: 1.6; max-width: 56ch; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 1px 0 rgba(26, 23, 20, 0.04);
}
.stack { display: grid; gap: 14px; }
.card h3 { margin: 0; font-size: 15px; letter-spacing: 0.01em; }
.card .sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; line-height: 1.5; }
/* Coming-soon (Studio disabled for now) */
.feature--soon { opacity: 0.62; }
.feature--soon:hover { transform: none; border-color: var(--line); box-shadow: 0 1px 0 rgba(26, 23, 20, 0.04); }
.soon-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); background: rgba(255, 79, 0, 0.12); border: 1px solid rgba(255, 79, 0, 0.3);
  border-radius: 999px; padding: 2px 7px; vertical-align: 2px; margin-left: 4px;
}
.soon-page { align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 24px; }
.soon-ficon { width: 64px; height: 64px; border-radius: 16px; font-size: 28px; }
.soon-h { margin: 4px 0 0; font-size: 20px; }
.soon-p { max-width: 38ch; margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-gap { margin-top: 20px; }

.feature {
  display: flex; gap: 14px; align-items: flex-start; cursor: pointer;
  transition: transform var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.feature:hover { transform: translateY(-2px); border-color: var(--hair); box-shadow: 0 10px 22px rgba(26, 23, 20, 0.08); }
.feature:active { transform: translateY(0) scale(0.985); transition-duration: var(--dur-1); }
.feature .ficon { transition: transform var(--dur-2) var(--ease-spring); }
.feature:hover .ficon { transform: scale(1.06) rotate(-2deg); }
.feature .ficon {
  width: 44px; height: 44px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: rgba(255, 79, 0, 0.12);
  border: 1px solid rgba(255, 79, 0, 0.28);
}

/* ── Buttons ──────────────────────────────────────────────── */
.button, button.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 11px 18px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  transition: filter var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-spring), opacity var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
}
.button:hover { filter: brightness(1.05); }
.button:active { transform: translateY(1px) scale(0.97); transition-duration: var(--dur-1); }
.button[disabled] { opacity: 0.4; cursor: not-allowed; }
.button.ghost { background: transparent; color: var(--text); border: 1px solid var(--hair); }
.button.ghost:hover { background: var(--panel2); filter: none; }
.button.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.button.danger { background: transparent; color: var(--danger); border: 1px solid rgba(210, 58, 42, 0.45); }
.button.block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Fields / chips ───────────────────────────────────────── */
.field { display: grid; gap: 6px; font-size: 13px; }
.field > span { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; font-weight: 600; }
.field input, .field select, select.locale {
  background: var(--field); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 14px;
}
.field input:focus, .field select:focus, select.locale:focus, textarea.ta:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer;
  transition: transform var(--dur-1) var(--ease-spring), background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.chip:hover { transform: scale(1.04); border-color: var(--hair); }
.chip:active { transform: scale(0.95); transition-duration: 90ms; }
.chip.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ── Device pill / status ─────────────────────────────────── */
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b3aa98; }
.dot.online { background: var(--ok); box-shadow: 0 0 8px rgba(63, 158, 87, 0.55); }

.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
}
.list-item .k { color: var(--muted); font-size: 13px; }
.list-item .v { font-weight: 700; font-size: 14px; }

.notice { background: rgba(255, 79, 0, 0.08); border: 1px solid rgba(255, 79, 0, 0.3); border-radius: 9px; padding: 11px 14px; font-size: 13px; color: var(--text); }
.muted { color: var(--muted); }

/* ── Progress ─────────────────────────────────────────────── */
.progress { display: grid; gap: 6px; }
.progress .track { height: 10px; border-radius: 999px; background: var(--panel2); overflow: hidden; border: 1px solid var(--line); }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width 0.15s ease; }

/* ── Editor embed (full-page on Create) ───────────────────── */
.main--upload, .main--studio { overflow: hidden; } /* editor fills the viewport — no page scroll */
.main--upload .shell, .main--studio .shell { max-width: none; margin: 0; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-page { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; } /* flex-fill (no magic top-bar height) */
.ezback {
  /* Align the left edge with the centered nav content (topbar-inner: max-width 1120, padding 22). */
  position: absolute; top: 12px; left: max(22px, calc(50% - 560px + 22px)); z-index: 5;
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring);
}
.ezback:hover { border-color: var(--hair); color: var(--accent); }
.ezback:active { transform: scale(0.92); }
.editor-frame { flex: 1; min-height: 0; width: 100%; overflow: hidden; background: var(--panel); border: 0; }
.editor-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.create-bar { border-top: 1px solid var(--line); background: var(--panel); }
.create-bar-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 22px; }
.create-bar-inner .cb-status {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cb-spin { display: inline-flex; flex: none; color: var(--accent); }
.cb-spin[hidden] { display: none; }
.cb-spin .lic { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.create-bar-inner .button { border-radius: 10px; }
.create-bar-inner .button .lic { vertical-align: -2px; }
@media (max-width: 680px) {
  /* One row: status (ellipsis) + icon-only buttons. */
  .create-bar-inner { flex-wrap: nowrap; gap: 10px; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .create-bar-inner .button { flex: none; padding: 9px 11px; }
  .create-bar-inner .button .btn-tx { display: none; }
  .create-bar-inner .button .lic { vertical-align: -3px; }
}

/* ── Easy mode (crop a photo/video → 240×320) ─────────────── */
.easy-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px 22px; background: var(--bg); overflow: hidden; }
.easy-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
/* Cropper: full image with out-of-frame area dimmed + a white crop frame. Sizes to fit (no scroll). */
.easy-canvas {
  height: min(48vh, 460px); width: auto; max-width: 100%; aspect-ratio: 360 / 440;
  border-radius: 10px; background: #15120f; touch-action: none; cursor: grab;
}
.easy-canvas:active { cursor: grabbing; }
.easy-controls { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.ctl { display: grid; gap: 5px; font-size: 12px; }
.zoom-ctl { display: flex; align-items: center; gap: 12px; }
.zoom-ctl input[type="range"] { flex: 1; }
.z-ic { color: var(--muted); display: flex; flex: none; background: none; border: 0; padding: 4px; cursor: pointer; border-radius: 6px; transition: color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring); }
.z-ic:hover { color: var(--accent); background: var(--panel2); }
.z-ic:active { transform: scale(0.88); }
.easy-actions { display: flex; justify-content: center; align-items: center; gap: 10px; }
.easy-actions .button { border-radius: 10px; }
.bg-btn { position: relative; display: inline-flex; align-items: center; gap: 7px; }
.bg-chip { width: 16px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(0, 0, 0, 0.25); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7); }
.bg-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }

/* ── Video editor tabs (Trim | Edit) ─────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: 999px; overflow: hidden; }
.seg-btn { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
.seg-btn:active { transform: scale(0.97); }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); }
.vtabs { display: flex; }
.vtabs .seg-btn { flex: 1; justify-content: center; }

/* ── Video trimmer (iPhone-style head/tail + play preview) ── */
.vid-edit { display: flex; flex-direction: column; gap: 12px; }
.vid-row { display: flex; align-items: center; gap: 12px; }
.vid-play { width: 54px; height: 54px; border-radius: 10px; border: 1px solid var(--hair); background: var(--panel); color: var(--text); display: grid; place-items: center; padding: 0; flex: none; transition: background var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring); }
.vid-play:hover { background: var(--panel2); }
.vid-play:active { transform: scale(0.93); }
.trim { position: relative; flex: 1; height: 54px; border-radius: 8px; overflow: hidden; background: #000; user-select: none; touch-action: none; }
.trim-strip { position: absolute; inset: 0; display: flex; }
.trim-strip img { flex: 1; min-width: 0; height: 100%; object-fit: cover; pointer-events: none; }
.trim-dim { position: absolute; top: 0; bottom: 0; background: rgba(20, 18, 15, 0.62); pointer-events: none; }
.trim-dim-l { left: 0; width: 0; }
.trim-dim-r { right: 0; left: 100%; }
.trim-sel { position: absolute; top: 0; bottom: 0; left: 0; right: 0; border: 2px solid var(--accent); border-radius: 7px; pointer-events: none; }
.trim-h { position: absolute; top: 0; bottom: 0; width: 16px; background: var(--accent); cursor: ew-resize; pointer-events: auto; display: flex; align-items: center; justify-content: center; }
.trim-h::after { content: ''; width: 3px; height: 42%; background: #fff; border-radius: 2px; }
.trim-h-l { left: -2px; border-radius: 7px 0 0 7px; }
.trim-h-r { right: -2px; border-radius: 0 7px 7px 0; }
.trim-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 4px rgba(0, 0, 0, 0.6); pointer-events: none; }
.vid-meta { display: flex; align-items: center; gap: 16px; font-size: 12px; }
.vid-meta .muted b { color: var(--text); font-variant-numeric: tabular-nums; }
.vid-meta .ctl.inline { display: flex; align-items: center; gap: 8px; flex: 1; }
.vid-meta .ctl.inline > span { white-space: nowrap; }
.vid-meta .ctl.inline input { flex: 1; }
.ctl > span { text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.ctl > span b { color: var(--text); font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { width: 100%; accent-color: var(--accent); }
/* Theme every slider (incl. the carousel interval), and let flex ranges shrink instead of overflowing. */
input[type="range"] { accent-color: var(--accent); min-width: 0; }
/* The carousel slider is a .field input — strip the text-field box so it shows as a clean range. */
.field input[type="range"] { border: 0; background: transparent; padding: 0; height: auto; }
/* Theme native file pickers (carousel "Choose Files") to match the TE buttons. */
input[type="file"] { font: inherit; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; cursor: pointer; margin-right: 10px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 8px; padding: 7px 12px;
  text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
}
input[type="file"]::file-selector-button:hover { border-color: var(--hair); color: var(--accent); }
.ctl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ctl-row .ctl { flex: 1; min-width: 120px; }
.easy-tip { font-size: 12px; margin: 2px 0 0; line-height: 1.5; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: min(440px, 100%); box-sizing: border-box;
  min-height: 280px; max-height: min(64vh, 620px); margin: 22px auto; padding: 28px;
  border: 2px dashed var(--line); border-radius: 12px; text-align: center;
  cursor: pointer; color: var(--muted); background: var(--panel);
  transition: border-color var(--dur-2) var(--ease-out), background var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.dropzone b, .dropzone .dz-sub { max-width: 100%; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(255, 79, 0, 0.05); }
.dropzone.drag { transform: scale(1.01); }
.dropzone b { color: var(--text); font-size: 15px; }
.dz-sub { font-size: 11px; letter-spacing: 0.01em; }
.dz-icon { color: var(--accent); }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  box-shadow: 0 12px 30px rgba(26, 23, 20, 0.28); z-index: 60;
  animation: toastin var(--dur-2) var(--ease-spring);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 680px) {
  .brand small { display: none; }
  .shell { padding: 18px 16px 40px; margin: 0 auto; } /* top-align on mobile (no vertical centering gap) */
  .grid { grid-template-columns: 1fr; }
}

/* ── Home: device preview on top (crops to the top, fades out below), bento menu beneath.
   Same single-column layout at every width — a centered phone-width column on desktop. ── */
.home-main { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 6px; }
.home-right { display: grid; gap: 14px; align-content: start; }
.home-device {
  display: flex; justify-content: center; align-items: flex-start; overflow: hidden;
  padding-top: 6px; margin-top: -8px; /* headroom so the idle float doesn't clip at the top */
  max-height: min(406px, 52vh); /* slot + full screen + a little base */
  -webkit-mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
}
.dev-wrap { position: relative; width: 250px; max-width: 72vw; margin: 0 auto; }
.dev-illu { width: 100%; height: auto; display: block; }
/* Screen content overlay, positioned over the SVG screen rect (viewBox 180×341). */
.dev-screen { position: absolute; left: 5.833%; top: 8.064%; width: 87.778%; height: 61.877%; border-radius: 2px; display: block; }
/* Disconnected: preview rests slightly lower + dimmer; it slides up on connect, down on disconnect.
   margin-bottom reserves layout space so the slid-down (masked) frame doesn't bleed onto the card. */
.home-device--off { transform: translateY(16px); opacity: 0.88; margin-bottom: 16px; }
.dev-slide-up { animation: devslideup var(--dur-3) var(--ease-out) both; }
.dev-slide-down { animation: devslidedown var(--dur-3) var(--ease-out) both; }
@keyframes devslideup { from { transform: translateY(16px); opacity: 0.88; } to { transform: translateY(0); opacity: 1; } }
@keyframes devslidedown { from { transform: translateY(0); opacity: 1; } to { transform: translateY(16px); opacity: 0.88; } }
/* Connected: the badge gently floats (on the wrapper, so SVG + screen move together). */
.home-device:not(.home-device--off) .dev-wrap { animation: devfloat 4s var(--ease-standard) infinite; }
@keyframes devfloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
/* Bento menu: row 1 = upload · studio (2-up), row 2 = carousel · profile · cards (3-up). */
.home-right .grid { grid-template-columns: repeat(6, 1fr); gap: 10px; }
.home-right .grid .feature { flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 16px 8px; }
.home-right .grid .feature .sub { display: none; } /* tiles too tight for descriptions */
.home-right .grid .feature h3 { font-size: 13px; line-height: 1.3; }
.home-right .grid .feature:nth-child(-n + 2) { grid-column: span 3; }
.home-right .grid .feature:nth-child(n + 3) { grid-column: span 2; }

/* ── Device status bar (home, compact) ────────────────────── */
.devbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 22px; padding: 14px 18px; }
.devbar--off { flex-wrap: nowrap; gap: 16px; }
.devbar-off-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.devbar-connect {
  flex: none; width: 56px; height: 56px;
  border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  transition: filter var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
.devbar-connect:hover { filter: brightness(1.05); transform: scale(1.04); }
.devbar-connect:active { transform: scale(0.94); transition-duration: var(--dur-1); }
.devbar-id { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 9px; font-size: 15px; font-weight: 700; width: 100%; }
.devbar-id > b { white-space: nowrap; } /* keep the device name on one piece (no mid-word break) */
.devbar-tools { flex: none; } /* wraps to its own right-aligned row when the header is tight */
.devbar-serial { color: var(--muted); display: inline-flex; cursor: help; }
.devbar-serial:hover { color: var(--accent); }
.devbar-bat { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.devbar-bat.ok { color: var(--ok); }
.devbar-bat.mid { color: #c98a2e; }
.devbar-bat.low { color: var(--danger); }
.devbar-bat .lic { vertical-align: -2px; }
.devbar-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; width: 100%; border-top: 1px solid var(--line); padding-top: 13px; }
.dstat { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dstat-kv { min-width: 0; }
.dstat-kv b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Wide enough → one clean row of 4 (content-sized + spread, so STORE shows in full); narrow → 2×2. */
@media (min-width: 760px) {
  .home-main { max-width: 620px; }
  .devbar-stats { grid-template-columns: repeat(4, auto); justify-content: space-between; }
}
.dstat-ic { width: 28px; height: 28px; border-radius: 8px; background: rgba(255, 79, 0, 0.12); color: var(--accent); display: grid; place-items: center; flex: none; }
.dstat-kv { display: flex; flex-direction: column; line-height: 1.25; }
.dstat-kv i { font-style: normal; font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.dstat-kv b { font-size: 13px; font-variant-numeric: tabular-nums; }
.devbar-hint { font-size: 13px; color: var(--muted); }
.devbar-tools { margin-left: auto; display: flex; gap: 6px; }
.iconbtn {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring);
}
.iconbtn:hover { border-color: var(--hair); color: var(--accent); }
.iconbtn:active { transform: scale(0.9); }

/* ── Modal + iOS-style toggle switch ──────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 23, 20, 0.42); backdrop-filter: blur(2px);
  animation: fadein var(--dur-2) var(--ease-out);
}
.modal {
  width: min(420px, 100%); max-height: calc(100dvh - 40px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 24px 64px rgba(26, 23, 20, 0.32);
  overflow: hidden auto; animation: modalin var(--dur-3) var(--ease-spring) both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.modal-head h3 .lic { color: var(--accent); }
.modal-close { background: none; border: 0; color: var(--muted); cursor: pointer; display: flex; padding: 5px; border-radius: 8px; transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring); }
.modal-close:hover { background: var(--panel2); color: var(--text); }
.modal-close:active { transform: scale(0.88); }
.modal-body { padding: 4px 0; }
.toggle-row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle-row:last-child { border-bottom: 0; }
.tr-icon { width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 79, 0, 0.12); color: var(--accent); display: grid; place-items: center; flex: none; }
.tr-label { flex: 1; font-size: 14px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.sw-track { position: absolute; inset: 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
.sw-knob { position: absolute; top: 50%; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transform: translateY(-50%); transition: transform var(--dur-2) var(--ease-spring); }
.switch input:checked + .sw-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .sw-track .sw-knob { transform: translate(18px, -50%); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalin { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ── Lucide icons ─────────────────────────────────────────── */
.lic { display: inline-block; flex: none; vertical-align: -0.18em; }
.nav-item .lic { vertical-align: middle; }
.ficon .lic { color: var(--accent); }

/* ── Sub-screen back bar + textareas ──────────────────────── */
.backbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.backbtn {
  background: transparent; border: 1px solid var(--hair); color: var(--text);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
  transition: color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-spring);
}
.backbtn:active { transform: scale(0.95) translateX(-1px); }
.backbtn:hover { background: var(--panel2); }
.backbar > span { font-weight: 700; font-size: 15px; }

textarea.ta {
  width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 14px; resize: vertical;
}
textarea.mono { font-family: var(--font-mono); font-size: 12px; line-height: 1.5; }

/* ── Footer (upstream credit + disclaimer) — centered at the bottom ── */
.site-footer { padding: 22px 22px calc(20px + env(safe-area-inset-bottom)); text-align: center; }
.app-frame--home .site-footer { padding-top: 6px; }
.footer-note { margin: 0 auto; max-width: 62ch; font-size: 11px; line-height: 1.9; color: var(--muted); }
.footer-link { color: var(--accent); white-space: nowrap; }
.footer-link:hover { text-decoration: underline; }
button.footer-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--accent); }
.modal-text { margin: 0; padding: 14px 18px 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); }
.modal-text:last-child { padding-bottom: 16px; }
.about-feats { list-style: none; margin: 12px 0 4px; padding: 0 18px; display: grid; gap: 9px; }
.about-feats li { position: relative; padding-left: 22px; font-size: 12.5px; line-height: 1.45; color: var(--text); }
.about-feats li::before { content: "✦"; position: absolute; left: 2px; top: 0; color: var(--accent); font-size: 12px; }

/* ── Bluefy hint (iOS without Web Bluetooth) ──────────────── */
.bluefy { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-color: rgba(255, 79, 0, 0.4); background: rgba(255, 79, 0, 0.06); }
.bluefy-ic { width: 36px; height: 36px; border-radius: 9px; background: rgba(255, 79, 0, 0.14); color: var(--accent); display: grid; place-items: center; flex: none; }
.bluefy-tx { display: grid; gap: 2px; flex: 1; min-width: 170px; }
.bluefy-tx b { font-size: 14px; }
.bluefy-tx span { font-size: 12px; line-height: 1.5; }
.bluefy-get { flex: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
