/* ==========================================================================
   SoundDeck Companion — Shared Design System
   Used by: preview_companion_local.html, preview_companion_portal.html
   Palette mirrors the desktop app (SoundboardView pad card) exactly.
   ========================================================================== */

@import url('/assets/fonts/fonts.css');

:root {
  --bg-0: #05070B;
  --bg-1: #080A0F;
  --bg-2: #0D1117;
  --bg-2h: #121620;
  --bg-3: #161B22;
  --bg-4: #21262D;
  --line-1: #21262D;
  --line-2: #30363D;
  --line-3: #484F58;
  --fg-0: #FFFFFF;
  --fg-1: #E6EDF3;
  --fg-2: #8B949E;
  --fg-3: #6E7681;
  --blue: #1F6FEB;
  --blue-hi: #388BFD;
  --blue-text: #58A6FF;
  --blue-wash: rgba(31, 111, 235, 0.12);
  --red: #DA3633;
  --red-hi: #F85149;
  --red-wash: rgba(218, 54, 51, 0.12);
  --green: #3FB950;
  --green-wash: rgba(63, 185, 80, 0.12);
  --amber: #D29922;
  --amber-wash: rgba(210, 153, 34, 0.12);

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-press: cubic-bezier(0.2, 0, 0, 1);
  --shadow-ambient: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-raise: 0 12px 32px -12px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-device: 0 60px 120px -40px rgba(0, 0, 0, 0.9), 0 30px 60px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(31, 111, 235, 0.07), transparent 60%),
    linear-gradient(var(--bg-0), var(--bg-0));
  color: var(--fg-1);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--blue-hi); outline-offset: 2px; }

/* ==========================================================================
   Review Bar (preview chrome — not part of the product)
   ========================================================================== */
.review-bar {
  position: relative;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: rgba(8, 10, 15, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-1);
}
.rb-left, .rb-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rb-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 13px; color: var(--fg-0); white-space: nowrap; }
.rb-brand img { width: 22px; height: 22px; border-radius: 6px; }
.rb-tag {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--fg-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 6px;
}
.rb-label { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--fg-3); }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: 9px;
}
.seg > a, .seg > button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--fg-2); text-decoration: none; white-space: nowrap;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.2s var(--ease-out);
}
.seg > a:hover, .seg > button:hover { color: var(--fg-0); }
.seg > .on { background: var(--bg-4); color: var(--fg-0); box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 1px 3px rgba(0,0,0,0.5); }

/* ==========================================================================
   Stage & Device Frames
   ========================================================================== */
.stage {
  position: relative;
  height: calc(100% - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.device-fit { position: relative; flex-shrink: 0; }
.device {
  position: absolute;
  top: 0; left: 0;
  transform-origin: top left;
  transition: opacity 0.25s ease;
}
.device.is-swapping { opacity: 0; }

.device.phone {
  width: 417px; height: 876px;
  padding: 12px;
  border-radius: 64px;
  background: linear-gradient(145deg, #2A2F37, #14171C 40%, #0B0D11);
  box-shadow: var(--shadow-device), inset 0 0 0 1.5px rgba(255,255,255,0.08), inset 0 0 0 5px #07080B;
}
.device.phone::before, .device.phone::after { /* side buttons */
  content: ''; position: absolute; width: 3px; border-radius: 2px; background: #1A1D23;
}
.device.phone::before { left: -3px; top: 180px; height: 64px; box-shadow: 0 84px 0 #1A1D23; }
.device.phone::after { right: -3px; top: 220px; height: 96px; }
.device.phone .screen { border-radius: 52px; }

.device.tablet {
  width: 1216px; height: 856px;
  padding: 18px;
  border-radius: 40px;
  background: linear-gradient(145deg, #2A2F37, #14171C 40%, #0B0D11);
  box-shadow: var(--shadow-device), inset 0 0 0 1.5px rgba(255,255,255,0.08), inset 0 0 0 7px #07080B;
}
.device.tablet .screen { border-radius: 22px; }

.device.desktop {
  width: 1320px; height: 820px;
  border-radius: 12px;
  background: var(--bg-2);
  box-shadow: var(--shadow-device);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.browser-bar {
  display: none;
  height: 40px; flex-shrink: 0;
  align-items: center; gap: 14px;
  padding: 0 14px;
  background: #11151C;
  border-bottom: 1px solid var(--line-1);
}
.device.desktop .browser-bar { display: flex; }
.traffic { display: flex; gap: 7px; }
.traffic i { width: 11px; height: 11px; border-radius: 50%; background: #2B3038; }
.url-pill {
  flex: 1; max-width: 520px; margin: 0 auto;
  height: 26px; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--bg-1); border: 1px solid var(--line-1); border-radius: 7px;
  font-family: var(--mono); font-size: 11px; color: var(--fg-2);
}
.url-pill b { color: var(--fg-1); font-weight: 600; }
.device.desktop .screen { flex: 1; border-radius: 0; }

.screen {
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-1);
  container-type: inline-size;
  container-name: screen;
  isolation: isolate;
}

/* Phone OS chrome */
.os-status {
  display: none;
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  height: 54px; padding: 18px 34px 0;
  justify-content: space-between; align-items: flex-start;
  font-size: 15px; font-weight: 600; color: var(--fg-0);
  pointer-events: none;
}
.os-status .os-icons { display: flex; gap: 6px; align-items: center; padding-top: 2px; }
.island {
  display: none;
  position: absolute; z-index: 41; top: 11px; left: 50%; transform: translateX(-50%);
  width: 122px; height: 35px; border-radius: 20px; background: #000;
}
.home-bar {
  display: none;
  position: absolute; z-index: 41; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 134px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.55);
  pointer-events: none;
}
.device.phone .os-status { display: flex; }
.device.phone .island, .device.phone .home-bar { display: block; }
.device.phone .app { padding-top: 50px; padding-bottom: 20px; }

/* Real phones visiting the page: drop the frame, go full-bleed */
@media (max-width: 560px) {
  .review-bar { height: 48px; padding: 0 12px; }
  .rb-hide-sm { display: none !important; }
  .stage { height: calc(100% - 48px); padding: 0; }
  .device-fit { width: 100% !important; height: 100% !important; }
  .device, .device.phone, .device.tablet, .device.desktop {
    position: relative; width: 100% !important; height: 100% !important;
    transform: none !important; padding: 0; border-radius: 0; box-shadow: none; background: var(--bg-1);
  }
  .device.phone::before, .device.phone::after { display: none; }
  .device .screen { border-radius: 0 !important; }
  .device.phone .os-status, .device.phone .island, .device.phone .home-bar, .device.desktop .browser-bar { display: none; }
  .device.phone .app { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}

/* ==========================================================================
   App Shell
   ========================================================================== */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app-header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-2);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: var(--bg-3); border: 1px solid var(--line-2);
  display: grid; place-items: center; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { min-width: 0; }
.brand-name { font-size: 14px; font-weight: 800; color: var(--fg-0); letter-spacing: -0.01em; line-height: 1.15; }
.brand-sub { font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--fg-3); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 10px;
  border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--line-1);
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--fg-1);
  white-space: nowrap;
}
.chip .muted { color: var(--fg-3); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; position: relative; }
.dot::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid currentColor; color: var(--green); opacity: 0;
  animation: ping 2.2s var(--ease-out) infinite;
}
.dot.warn { background: var(--amber); } .dot.warn::after { color: var(--amber); }
.dot.off { background: var(--red-hi); } .dot.off::after { display: none; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.7; } 100% { transform: scale(1.8); opacity: 0; } }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--fg-2);
  background: var(--bg-3); border: 1px solid var(--line-1);
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.12s var(--ease-press);
}
.icon-btn:hover { color: var(--fg-0); border-color: var(--line-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.on { color: var(--fg-0); background: var(--bg-4); border-color: var(--line-3); }

/* Hotkey arm switch (mirrors desktop TOGGLE_HOTKEYS) */
.arm {
  display: inline-flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 4px 0 10px;
  border-radius: 8px; background: var(--bg-3); border: 1px solid var(--line-1);
  font-family: var(--mono); font-size: 10px; font-weight: 800; letter-spacing: 0.05em; color: var(--fg-2);
  transition: border-color 0.2s;
}
.arm .track {
  width: 30px; height: 18px; border-radius: 9px; background: var(--bg-4); position: relative;
  transition: background 0.25s var(--ease-out);
}
.arm .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--fg-2); transition: transform 0.25s var(--ease-out), background 0.25s;
}
.arm.on { color: var(--fg-0); border-color: rgba(63,185,80,0.35); }
.arm.on .track { background: rgba(63,185,80,0.35); }
.arm.on .track::after { transform: translateX(12px); background: var(--green); }

/* ==========================================================================
   Now Playing
   ========================================================================== */
.np {
  flex-shrink: 0;
  margin: 12px 16px 0;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  box-shadow: var(--shadow-ambient);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 12px; row-gap: 8px;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.np.live { border-color: var(--line-3); background: var(--bg-3); }
.np-meta { min-width: 0; display: flex; align-items: center; gap: 10px; }
.np-eq { display: flex; align-items: flex-end; gap: 2px; height: 14px; width: 16px; flex-shrink: 0; }
.np-eq i { flex: 1; background: var(--line-3); border-radius: 1px; height: 30%; transition: background 0.2s; }
.np.live .np-eq i { background: var(--fg-0); animation: eq 0.9s ease-in-out infinite; }
.np.live .np-eq i:nth-child(2) { animation-delay: -0.3s; }
.np.live .np-eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
.np-text { min-width: 0; }
.np-label { font-family: var(--mono); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; color: var(--fg-3); text-transform: uppercase; }
.np-title { font-size: 13px; font-weight: 700; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np.idle .np-title { color: var(--fg-2); font-weight: 600; }
.np-time { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--fg-2); align-self: center; font-variant-numeric: tabular-nums; }
.np.live .np-time { color: var(--fg-0); }
.np-wave { grid-column: 1 / -1; height: 28px; width: 100%; display: block; }

/* ==========================================================================
   Toolbar, Search & Category Chips
   ========================================================================== */
.toolbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 0;
}
.search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-1);
  color: var(--fg-3);
  transition: border-color 0.15s, box-shadow 0.2s;
}
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); color: var(--fg-2); }
.search input { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; font-size: 13px; color: var(--fg-0); }
.search input::placeholder { color: var(--fg-3); }
.kbd {
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--fg-3);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px;
}
.toolbar .icon-btn { width: 36px; height: 36px; border-radius: 10px; }

.cats {
  flex-shrink: 0;
  display: flex; gap: 6px;
  padding: 10px 16px 12px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line-1);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: 8px;
  background: transparent; border: 1px solid var(--line-1);
  font-size: 12px; font-weight: 600; color: var(--fg-2);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.cat:hover { color: var(--fg-0); border-color: var(--line-2); }
.cat .n { font-family: var(--mono); font-size: 10px; color: var(--fg-3); }
.cat.on { background: var(--fg-0); border-color: var(--fg-0); color: var(--bg-1); }
.cat.on .n { color: #57606A; }

/* ==========================================================================
   Pad Grid — identical anatomy to desktop SoundboardView card
   ========================================================================== */
.grid-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  padding: 14px 16px 20px;
}
@container screen (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; padding: 16px 20px 24px; } }

.pad {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 142px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
  text-align: left;
  cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease, transform 0.12s var(--ease-press), opacity 0.2s;
  animation: padIn 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
@keyframes padIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (hover: hover) { .pad:hover { background: var(--bg-2h); border-color: var(--line-2); } }
.pad:active, .pad.pressed { transform: scale(0.98); }
.pad.is-playing {
  background: var(--bg-3);
  border-color: var(--fg-0);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.4), 0 8px 24px -8px rgba(0,0,0,0.8);
}
.pad.is-locked { opacity: 0.45; cursor: not-allowed; }
.pad.is-locked:active { transform: none; }

.pad-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.keycap {
  padding: 2px 10px;
  border-radius: 6px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(0,0,0,0.3);
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--fg-0);
  text-transform: uppercase; white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.keycap.none { color: var(--fg-3); border-style: dashed; }
.pad.is-playing .keycap { background: var(--fg-0); color: var(--bg-1); border-color: var(--fg-0); font-weight: 800; }
.pad-meta { display: flex; align-items: center; gap: 4px; min-width: 0; }
.badge {
  padding: 1px 7px; border-radius: 4px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 9px; font-weight: 700; color: var(--fg-2);
  text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72px;
}
.star { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; color: var(--fg-3); transition: color 0.15s, transform 0.2s var(--ease-out); }
.star:hover { color: var(--fg-0); }
.star.on { color: var(--fg-0); }
.star.pop { animation: pop 0.35s var(--ease-out); }
@keyframes pop { 40% { transform: scale(1.35); } }

.pad-mid { margin: 6px 0; }
.pad-title {
  font-size: 12px; font-weight: 700; color: var(--fg-0);
  line-height: 1.3; letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 31px; word-break: break-word;
}
.pad-stats {
  margin-top: 3px;
  display: flex; justify-content: space-between; gap: 6px;
  font-family: var(--mono); font-size: 10px; color: var(--fg-2); font-variant-numeric: tabular-nums;
}
.pad-stats .plays { font-weight: 600; }
.pad.is-playing .pad-stats .time { color: var(--fg-0); font-weight: 700; }

.pad-bottom { display: flex; flex-direction: column; gap: 6px; }
.trench {
  height: 18px; padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-1); border: 1px solid var(--line-1);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
  overflow: hidden;
}
.trench canvas { width: 100%; height: 100%; display: block; }
.trench.loading { position: relative; }
.trench.loading::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.gauge { position: absolute; left: 0; right: 0; bottom: -8px; height: 4px; border-radius: 4px; background: var(--bg-3); border: 1px solid var(--line-1); overflow: hidden; opacity: 0; transition: opacity 0.2s ease; }
.pad-bottom { position: relative; }
.pad.is-playing .gauge { opacity: 1; }
.gauge i { display: block; height: 100%; width: 0; background: var(--fg-0); border-radius: 4px; }

/* Cooldown sweep for rate-limited remote producers */
.pad .cool {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0.06) var(--p, 0%), transparent var(--p, 0%));
  opacity: 0; transition: opacity 0.2s;
}
.pad.cooling .cool { opacity: 1; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 16px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: 12px;
  color: var(--fg-2); font-size: 13px;
}
.empty b { display: block; color: var(--fg-0); font-size: 14px; margin-bottom: 4px; }

/* ==========================================================================
   Dock
   ========================================================================== */
.dock {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-1);
}
.btn-stop {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px;
  border-radius: 11px;
  background: var(--red); color: #fff;
  font-family: var(--mono); font-size: 11.5px; font-weight: 800; letter-spacing: 0.06em;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 6px 18px -6px rgba(218,54,51,0.7);
  transition: background 0.15s, transform 0.12s var(--ease-press);
  white-space: nowrap;
}
.btn-stop:hover { background: #E5443F; }
.btn-stop:active { transform: scale(0.96); background: #B62324; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 14px;
  border-radius: 11px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-0);
  font-family: var(--mono); font-size: 11px; font-weight: 800; letter-spacing: 0.05em;
  transition: background 0.15s, border-color 0.15s, transform 0.12s var(--ease-press);
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--line-3); background: var(--bg-4); }
.btn-ghost:active { transform: scale(0.96); }
.btn-ghost .kbd { color: var(--fg-2); }
.btn-ghost.busy { pointer-events: none; color: var(--fg-2); }
.btn-ghost[disabled] { opacity: 0.4; pointer-events: none; }

.vol { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line-1); }
.vol svg { color: var(--fg-2); }
.vol output { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--fg-0); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.range {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 22px; background: transparent; cursor: pointer;
  --v: 80%;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--fg-0) var(--v), var(--bg-4) var(--v)); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--bg-4); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--fg-0); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--fg-0); border: 3px solid var(--bg-2); box-shadow: 0 0 0 1px var(--line-3), 0 2px 6px rgba(0,0,0,0.5); transition: transform 0.15s var(--ease-out); }
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--fg-0); border: 3px solid var(--bg-2); box-shadow: 0 0 0 1px var(--line-3); }
.range:active::-webkit-slider-thumb { transform: scale(1.2); }
.range[disabled] { opacity: 0.4; cursor: not-allowed; }

@container screen (max-width: 520px) {
  .dock { gap: 8px; padding: 10px 12px; }
  .btn-stop { padding: 0 14px; }
  .btn-ghost .lbl-long, .btn-stop .lbl-long { display: none; }
  .vol { padding: 0 10px; gap: 8px; }
  .vol svg { display: none; }
}

/* ==========================================================================
   Bottom Sheet
   ========================================================================== */
.scrim {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; z-index: 61; left: 0; right: 0; bottom: 0;
  max-height: 82%;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-top: 1px solid var(--line-2);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.6);
  transform: translateY(105%);
  transition: transform 0.4s var(--ease-out);
}
.sheet.open { transform: none; }
@container screen (min-width: 760px) {
  .sheet { left: 50%; right: auto; bottom: 50%; width: 460px; border-radius: 16px; border: 1px solid var(--line-2); transform: translate(-50%, 54%) scale(0.97); opacity: 0; pointer-events: none; transition: transform 0.35s var(--ease-out), opacity 0.25s; }
  .sheet.open { transform: translate(-50%, 50%); opacity: 1; pointer-events: auto; }
  .sheet-grip { display: none; }
}
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line-3); margin: 10px auto 2px; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line-1); }
.sheet-title { font-size: 15px; font-weight: 800; color: var(--fg-0); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-sub { font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--fg-3); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }
.sheet-body { padding: 16px 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-wave { height: 56px; border-radius: 10px; background: var(--bg-1); border: 1px solid var(--line-1); padding: 8px 10px; box-shadow: inset 0 2px 6px rgba(0,0,0,0.6); }
.sheet-wave canvas { width: 100%; height: 100%; display: block; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { padding: 10px; border-radius: 10px; background: var(--bg-3); border: 1px solid var(--line-1); min-width: 0; }
.fact span { display: block; font-family: var(--mono); font-size: 9px; font-weight: 800; color: var(--fg-3); letter-spacing: 0.08em; text-transform: uppercase; }
.fact b { display: block; margin-top: 3px; font-family: var(--mono); font-size: 13px; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; border-radius: 11px;
  background: var(--fg-0); color: var(--bg-1);
  font-family: var(--mono); font-size: 11.5px; font-weight: 800; letter-spacing: 0.05em;
  transition: transform 0.12s var(--ease-press), background 0.15s;
}
.btn-primary:hover { background: #E6EDF3; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.wide, .btn-ghost.wide { grid-column: 1 / -1; }

.pack { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--line-1); }
.pack-art { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; background: var(--bg-1); border: 1px solid var(--line-2); font-family: var(--mono); font-weight: 800; font-size: 12px; color: var(--fg-0); }
.pack-info { flex: 1; min-width: 0; }
.pack-name { font-size: 13px; font-weight: 700; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pack-sub { font-family: var(--mono); font-size: 10px; color: var(--fg-3); margin-top: 2px; }
.pack-btn { position: relative; overflow: hidden; height: 32px; min-width: 92px; padding: 0 12px; border-radius: 8px; background: var(--fg-0); color: var(--bg-1); font-family: var(--mono); font-size: 10.5px; font-weight: 800; letter-spacing: 0.04em; transition: background 0.2s, color 0.2s; }
.pack-btn .fill { position: absolute; inset: 0; width: 0; background: rgba(31,111,235,0.35); transition: width 0.15s linear; }
.pack-btn span { position: relative; }
.pack-btn.busy { background: var(--bg-4); color: var(--fg-0); }
.pack-btn.done { background: transparent; color: var(--green); border: 1px solid rgba(63,185,80,0.4); pointer-events: none; }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toasts {
  position: absolute; z-index: 70; left: 50%; bottom: 86px; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 6px;
  width: calc(100% - 32px); pointer-events: none;
}
.device.phone .toasts { bottom: 104px; }
.toast {
  max-width: 100%;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(22, 27, 34, 0.96);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-raise);
  font-size: 12px; font-weight: 600; color: var(--fg-0);
  animation: toastIn 0.35s var(--ease-out) both;
}
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.out { animation: toastOut 0.25s ease forwards; }
.toast.ok svg { color: var(--green); } .toast.stop svg { color: var(--red-hi); } .toast.info svg { color: var(--blue-text); } .toast.warn svg { color: var(--amber); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(4px) scale(0.98); } }

/* ==========================================================================
   Full-screen State Overlays (pairing, reconnecting, approval, revoked)
   ========================================================================== */
.overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(8, 10, 15, 0.86);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.overlay.solid { background: var(--bg-1); }
.overlay.open { opacity: 1; pointer-events: auto; }
.ov-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
  transform: translateY(8px); transition: transform 0.4s var(--ease-out);
}
.overlay.open .ov-card { transform: none; }
.ov-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-0); }
.ov-icon.warn { color: var(--amber); border-color: rgba(210,153,34,0.35); background: var(--amber-wash); }
.ov-icon.off { color: var(--red-hi); border-color: rgba(248,81,73,0.35); background: var(--red-wash); }
.ov-icon.ok { color: var(--green); border-color: rgba(63,185,80,0.35); background: var(--green-wash); }
.ov-title { font-size: 19px; font-weight: 800; color: var(--fg-0); letter-spacing: -0.015em; }
.ov-text { font-size: 13px; line-height: 1.55; color: var(--fg-2); }
.ov-text b { color: var(--fg-1); }
.ov-meta { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--fg-3); letter-spacing: 0.04em; }
.ov-actions { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ov-actions .btn-primary, .ov-actions .btn-ghost { width: 100%; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--amber); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line-1); font-size: 12px; font-weight: 600; color: var(--fg-2); }
.step i { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; border: 1.5px solid var(--line-3); }
.step.done { color: var(--fg-1); } .step.done i { border-color: var(--green); background: var(--green); color: var(--bg-1); }
.step.active { color: var(--fg-0); border-color: var(--line-2); } .step.active i { border-color: var(--amber); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.step .k { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--fg-3); }

.pin { display: flex; gap: 8px; justify-content: center; }
.pin input {
  width: 44px; height: 54px; border-radius: 11px; text-align: center;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--fg-0);
  font-family: var(--mono); font-size: 22px; font-weight: 800; outline: none;
  transition: border-color 0.15s, box-shadow 0.2s;
}
.pin input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.pin.error input { border-color: var(--red-hi); animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ==========================================================================
   Portal-specific: host bar, permissions, activity log, fire budget
   ========================================================================== */
.host {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-1);
}
.avatar { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; background: var(--bg-3); border: 1px solid var(--line-2); font-family: var(--mono); font-weight: 800; font-size: 12px; color: var(--fg-0); position: relative; }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; border: 2px solid var(--bg-1); width: 11px; height: 11px; }
.host-info { min-width: 0; flex: 1; }
.host-name { font-size: 13px; font-weight: 700; color: var(--fg-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-sub { font-family: var(--mono); font-size: 10px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perms { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.perm { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-1); font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--fg-2); background: var(--bg-2); white-space: nowrap; }
.perm.y svg { color: var(--green); } .perm.n { color: var(--fg-3); } .perm.n svg { color: var(--fg-3); }
@container screen (max-width: 640px) { .perms { display: none; } }

.layout { flex: 1; min-height: 0; display: flex; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.activity { display: none; width: 300px; flex-shrink: 0; border-left: 1px solid var(--line-1); background: var(--bg-2); flex-direction: column; min-height: 0; }
@container screen (min-width: 1000px) { .activity { display: flex; } .only-narrow { display: none !important; } }
.act-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line-1); }
.act-title { font-family: var(--mono); font-size: 10px; font-weight: 800; letter-spacing: 0.1em; color: var(--fg-2); text-transform: uppercase; }
.act-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.log { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 8px; border-radius: 8px; font-size: 12px; animation: toastIn 0.35s var(--ease-out) both; }
.log:hover { background: var(--bg-3); }
.log time { font-family: var(--mono); font-size: 10px; color: var(--fg-3); padding-top: 2px; font-variant-numeric: tabular-nums; }
.log .who { font-family: var(--mono); font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.log .who[data-k="you"] { color: var(--fg-0); } .log .who[data-k="peer"] { color: var(--blue-text); } .log .who[data-k="sys"] { color: var(--fg-3); } .log .who[data-k="warn"] { color: var(--amber); } .log .who[data-k="stop"] { color: var(--red-hi); }
.log .what { color: var(--fg-1); line-height: 1.4; margin-top: 1px; word-break: break-word; }
.log .ack { font-family: var(--mono); font-size: 9.5px; color: var(--fg-3); margin-top: 2px; }
.act-foot { padding: 12px 16px; border-top: 1px solid var(--line-1); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat span { display: block; font-family: var(--mono); font-size: 9px; font-weight: 800; color: var(--fg-3); letter-spacing: 0.08em; text-transform: uppercase; }
.stat b { display: block; font-family: var(--mono); font-size: 15px; font-weight: 800; color: var(--fg-0); margin-top: 2px; font-variant-numeric: tabular-nums; }

.budget { display: flex; flex-direction: column; justify-content: center; gap: 5px; height: 46px; padding: 0 12px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line-1); flex-shrink: 0; }
.budget-head { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 9px; font-weight: 800; letter-spacing: 0.08em; color: var(--fg-3); }
.budget-head b { color: var(--fg-0); font-variant-numeric: tabular-nums; }
.cells { display: flex; gap: 3px; }
.cells i { width: 10px; height: 6px; border-radius: 2px; background: var(--fg-0); transition: background 0.25s; }
.cells i.spent { background: var(--bg-4); }
.budget.low .budget-head b { color: var(--amber); }
.budget.empty .budget-head b { color: var(--red-hi); }
@container screen (max-width: 520px) { .budget { display: none; } }

.session-timer { font-variant-numeric: tabular-nums; }
.sheet .act-list { padding: 0; overflow: visible; }

/* ==========================================================================
   Forms (portal join), utilities, layering
   ========================================================================== */
.form { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.field-row { display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-family: var(--mono); font-size: 9.5px; font-weight: 800; letter-spacing: 0.08em; color: var(--fg-3); text-transform: uppercase; }
.field input {
  width: 100%; height: 44px; padding: 0 12px;
  border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--fg-0); letter-spacing: 0.02em;
  outline: none; transition: border-color 0.15s, box-shadow 0.2s;
}
.field input::placeholder { color: var(--fg-3); font-weight: 600; }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.field.bad input { border-color: var(--red-hi); box-shadow: 0 0 0 3px var(--red-wash); }
.form .btn-primary { width: 100%; margin-top: 4px; }
.form[aria-busy="true"] { opacity: 0.45; pointer-events: none; }
.ov-err { min-height: 16px; font-size: 12px; font-weight: 600; color: var(--red-hi); text-align: center; }
.ov-err:empty { min-height: 0; }
.ov-link { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--fg-2); text-decoration: none; letter-spacing: 0.04em; }
.ov-link:hover { color: var(--fg-0); }
.rb-brand { text-decoration: none; }
[hidden] { display: none !important; }

.device.phone .os-status { z-index: 80; }
.device.phone .island, .device.phone .home-bar { z-index: 81; }
@container screen (max-width: 440px) { .hide-narrow { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
