:root {
  --ink: #0c1220;
  --muted: #5b6b7c;
  --soft: #8b9aab;
  --line: #e2e8ef;
  --line-strong: #c9d4de;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --bg: #eef2f6;
  --accent: #0e6e73;
  --accent-2: #14b8a6;
  --accent-hover: #0a5559;
  --accent-soft: #e6f5f4;
  --ok: #0f7a56;
  --ok-bg: #e5f6ee;
  --warn: #9a6b12;
  --warn-bg: #f8efd6;
  --danger: #c1352c;
  --sidebar-bg: #101820;
  --sidebar-ink: #e8eef4;
  --sidebar-muted: #8fa0b0;
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 0 rgba(16, 24, 32, 0.04), 0 10px 28px rgba(16, 24, 32, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --sidebar: 300px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(20, 184, 166, 0.09), transparent 50%),
    linear-gradient(180deg, #f3f6f9 0%, var(--bg) 100%);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); letter-spacing: 0.08em; font-size: 0.72rem; font-weight: 600; color: var(--soft); }
.kicker {
  margin: 0 0 0.45rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.hint { color: var(--muted); font-size: 0.84rem; }
.hint.danger, .danger { color: var(--danger); }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

/* —— Landing (trước đăng nhập) —— */
.landing {
  --landing-ink: #10231f;
  --landing-muted: #4a635c;
  --landing-accent: #0d6b62;
  position: fixed;
  inset: 0;
  z-index: 2100;
  overflow: hidden;
  color: var(--landing-ink);
  font-family: "Sora", var(--font);
  background:
    linear-gradient(165deg, #f3faf7 0%, #e8f2ee 42%, #dcebe4 100%);
}
.landing.hidden { display: none !important; }
.landing-visual {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.landing-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(13, 107, 98, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 107, 98, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 70% 40%, #000 20%, transparent 75%);
  animation: landing-grid-drift 28s linear infinite;
}
.landing-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.55;
}
.landing-orb-a {
  width: min(62vw, 520px);
  height: min(62vw, 520px);
  right: -8%;
  top: -12%;
  background: radial-gradient(circle at 35% 40%, #7dd3c7 0%, #2a9d8f 45%, transparent 70%);
  animation: landing-orb-float 12s ease-in-out infinite;
}
.landing-orb-b {
  width: min(48vw, 380px);
  height: min(48vw, 380px);
  left: -10%;
  bottom: -18%;
  background: radial-gradient(circle at 50% 40%, #c5e4a8 0%, #6b9f6e 50%, transparent 72%);
  animation: landing-orb-float 15s ease-in-out infinite reverse;
}
@keyframes landing-orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-2%, 3%) scale(1.06); }
}
@keyframes landing-grid-drift {
  from { background-position: 0 0; }
  to { background-position: 48px 48px; }
}
.landing-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem clamp(1.25rem, 4vw, 2.5rem);
}
.landing-wordmark {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--landing-ink);
}
.landing-bar-btn {
  font-family: "Sora", var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 35, 31, 0.18);
  background: rgba(255, 255, 255, 0.55);
  color: var(--landing-ink);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.landing-bar-btn:hover {
  background: #fff;
  border-color: var(--landing-accent);
  transform: translateY(-1px);
}
.landing-hero {
  position: relative;
  z-index: 2;
  min-height: calc(100vh - 7.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem clamp(1.25rem, 5vw, 4rem) 3rem;
  max-width: 920px;
}
.landing-brand {
  margin: 0 0 0.85rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2.8rem, 8vw, 5.2rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--landing-accent);
  animation: landing-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.landing-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.65rem, 4.2vw, 2.65rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--landing-ink);
  max-width: 14ch;
  animation: landing-rise 0.9s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.landing-lead {
  margin: 1.15rem 0 0;
  max-width: 34ch;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 400;
  line-height: 1.55;
  color: var(--landing-muted);
  animation: landing-rise 0.9s 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.landing-actions {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  animation: landing-rise 0.9s 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.landing-cta {
  font-family: "Sora", var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.9rem 1.55rem;
  border: none;
  border-radius: 999px;
  background: var(--landing-ink);
  color: #f4faf8;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(16, 35, 31, 0.18);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.landing-cta:hover {
  background: var(--landing-accent);
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(13, 107, 98, 0.28);
}
.landing-cta:disabled,
.landing-cta-ghost:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}
.landing-cta-ghost {
  font-family: "Sora", var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.9rem 1.45rem;
  border-radius: 999px;
  border: 1.5px solid rgba(16, 35, 31, 0.22);
  background: rgba(255, 255, 255, 0.45);
  color: var(--landing-ink);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}
.landing-cta-ghost:hover {
  border-color: var(--landing-accent);
  background: rgba(255, 255, 255, 0.72);
  transform: translateY(-2px);
}
.landing-dl-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(10, 22, 20, 0.42);
  backdrop-filter: blur(6px);
}
.landing-dl-modal.hidden { display: none !important; }
.landing-dl-card {
  position: relative;
  width: min(420px, 100%);
  padding: 1.55rem 1.45rem 1.35rem;
  border-radius: 18px;
  background: linear-gradient(165deg, #f7fbf9 0%, #eef6f3 100%);
  border: 1px solid rgba(16, 35, 31, 0.08);
  box-shadow: 0 28px 80px rgba(10, 28, 24, 0.28);
  animation: landing-rise 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.landing-dl-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--landing-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.landing-dl-close:hover { color: var(--landing-ink); background: rgba(16, 35, 31, 0.06); }
.landing-dl-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--landing-accent);
}
.landing-dl-title {
  margin: 0 0 0.45rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--landing-ink);
}
.landing-dl-lead {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--landing-muted);
}
.landing-dl-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--landing-muted);
}
.landing-dl-label input {
  font: inherit;
  font-weight: 500;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1.5px solid rgba(16, 35, 31, 0.14);
  background: #fff;
  color: var(--landing-ink);
}
.landing-dl-label input:focus {
  outline: none;
  border-color: var(--landing-accent);
  box-shadow: 0 0 0 3px rgba(13, 107, 98, 0.15);
}
.landing-dl-error {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #b42318;
}
.landing-dl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.1rem;
}
.landing-dl-actions .landing-cta,
.landing-dl-actions .landing-cta-ghost {
  flex: 1 1 10rem;
  text-align: center;
}
.landing-foot {
  position: absolute;
  z-index: 2;
  left: clamp(1.25rem, 4vw, 2.5rem);
  bottom: 1.1rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--landing-muted);
  opacity: 0.75;
}
@media (max-width: 640px) {
  .landing-hero { min-height: calc(100vh - 6.5rem); padding-bottom: 4rem; }
  .landing-title { max-width: none; }
  .landing-lead { max-width: 28ch; }
}
@keyframes landing-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-back {
  justify-self: start;
  margin: 0 0 0.85rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.auth-back:hover { color: var(--accent); }

/* —— Auth —— */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(700px 400px at 20% 0%, rgba(20, 184, 166, 0.18), transparent 55%),
    #0e161c;
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 1.65rem 1.55rem 1.4rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 0.15rem;
}
.auth-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  margin-bottom: 0.75rem;
  background: linear-gradient(145deg, #1ab3a8 0%, #0b5555 100%);
  position: relative;
}
.auth-mark::after {
  content: "";
  position: absolute;
  inset: 12px 10px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 99px;
  border-left-color: transparent;
  transform: rotate(-40deg);
}
.auth-card h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.auth-lead { color: var(--muted); margin: 0.35rem 0 1.1rem; font-size: 0.9rem; }
.auth-steps {
  position: relative;
  min-height: 11.5rem;
}
.auth-step {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
  transition:
    opacity 0.32s ease,
    transform 0.32s ease,
    max-height 0.36s ease;
}
.auth-step.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  max-height: 24rem;
}
.auth-step.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
.btn-block.is-loading {
  opacity: 0.72;
  pointer-events: none;
  position: relative;
}
.btn-block.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  margin-left: 0.45rem;
  vertical-align: -2px;
  animation: spinBtn 0.7s linear infinite;
}
@keyframes spinBtn {
  to { transform: rotate(360deg); }
}
.auth-or {
  margin: 1.1rem 0 0.85rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
  position: relative;
}
.auth-or::before, .auth-or::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 28%;
  height: 1px;
  background: var(--line);
}
.auth-or::before { left: 0; }
.auth-or::after { right: 0; }
.btn-block { width: 100%; margin-top: 0.55rem; }
.auth-fallback {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem 0.75rem;
  background: var(--surface-2);
}
.auth-fallback summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.25rem 0;
}
.auth-card code {
  color: var(--accent);
  font-size: 0.8rem;
}
.account-user {
  margin: 0.25rem 0 0;
  color: #5eead4;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.banner {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
}
.banner.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #e2c98a;
}
.rename-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.55rem;
  max-width: 420px;
}
.rename-row input {
  flex: 1 1 180px;
  margin: 0;
  font-size: 0.86rem;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.85rem 0 0;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
}
.check-row input {
  width: auto;
  margin: 0;
}

/* —— Sidebar —— */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem 0.9rem 0.85rem;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  min-height: 0;
}
.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.15rem 0.15rem 0.75rem;
  border-bottom: 1px solid var(--sidebar-line);
  flex: 0 0 auto;
}
.brand h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
}
.brand p {
  margin: 0.12rem 0 0;
  color: var(--sidebar-muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-row {
  align-items: flex-start;
}
.brand-text {
  flex: 1;
  min-width: 0;
}
.brand-note {
  margin: 0 0 0.75rem;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  line-height: 1.45;
  letter-spacing: 0.01em;
  text-transform: none;
  font-family: var(--sans, inherit);
}
.setup-note {
  max-width: none;
}
.pair-secret {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #9fb2c0;
  vertical-align: baseline;
  transition: filter 0.2s ease, color 0.2s ease, letter-spacing 0.2s ease;
}
.pair-secret.is-masked {
  filter: blur(3.5px);
  opacity: 0.55;
  user-select: none;
  letter-spacing: 0.14em;
}
.secret-toggle {
  display: inline-flex;
  align-items: center;
  margin-left: 0.15rem;
  padding: 0.08rem 0.4rem;
  border: 1px solid var(--sidebar-line, rgba(255,255,255,0.14));
  border-radius: 999px;
  background: transparent;
  color: #7dd3c7;
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  vertical-align: baseline;
  flex-shrink: 0;
}
.secret-toggle:hover {
  background: rgba(125, 211, 199, 0.12);
}
.account-menu-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--sidebar-line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-ink);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.account-menu-btn.warn-pulse {
  border-color: #e2c98a;
  box-shadow: 0 0 0 2px rgba(154, 107, 18, 0.25);
}
.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(145deg, #1ab3a8 0%, #0b5555 100%);
  position: relative;
}
.mark::after {
  content: "";
  position: absolute;
  inset: 10px 8px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 99px;
  border-left-color: transparent;
  transform: rotate(-40deg);
}

.side-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  padding: 0.75rem 0.75rem;
}
.side-block .kicker { color: #6f8494; }

/* Thiết bị: chiếm toàn bộ khoảng trống còn lại, list tự cuộn */
.side-devices {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0.55rem;
}
.side-devices-head {
  flex: 0 0 auto;
}
.side-devices .device-list {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0.45rem;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 0.1rem;
}

/* Bộ cài: footer gọn, có thể thu gọn */
.side-setup {
  flex: 0 0 auto;
  padding: 0.55rem 0.7rem 0.65rem;
}
.setup-drawer {
  margin: 0;
}
.setup-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  padding: 0.1rem 0;
}
.setup-summary::-webkit-details-marker { display: none; }
.setup-summary::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid #7a8fa0;
  border-bottom: 1.5px solid #7a8fa0;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.85;
}
.setup-drawer[open] > .setup-summary::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}
.setup-summary .kicker {
  margin: 0;
}
.setup-summary-meta {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6f8494;
}
.setup-body {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.45rem;
}
.pair-secret-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.pair-secret-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f8494;
  margin-right: 0.15rem;
}
.setup-downloads {
  display: grid;
  gap: 0.32rem;
}
.setup-downloads .btn-block {
  margin-top: 0;
  padding: 0.48rem 0.65rem;
  font-size: 0.8rem;
}
.setup-meta {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}
.setup-meta-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f8494;
}
.setup-meta code {
  font-size: 0.68rem;
  line-height: 1.35;
  color: #a8bbc9;
}
.setup-logout {
  width: 100%;
  margin-top: 0.1rem;
  opacity: 0.9;
}
.side-note {
  margin: 0;
  padding: 0 0.3rem;
  color: #6f8494;
  font-size: 0.75rem;
  line-height: 1.4;
}

.pair-box { text-align: center; }
.pair-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.pair-box strong {
  display: block;
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  margin: 0.4rem 0 0.75rem;
  color: #5eead4;
}
.meta-list {
  margin: 0 0 0.75rem;
  text-align: left;
  display: grid;
  gap: 0.4rem;
}
.meta-list > div {
  display: grid;
  gap: 0.1rem;
}
.meta-list dt {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f8494;
}
.meta-list dd { margin: 0; }
.meta-list code,
code {
  font-family: var(--mono);
  font-size: 0.72rem;
  word-break: break-all;
  color: #c5d4e0;
}
.side-btns { justify-content: stretch; }
.side-btns button { flex: 1; }
.sidebar button.ghost {
  color: var(--sidebar-ink);
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
}
.sidebar button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-height: 820px) {
  .setup-drawer:not([open]) .setup-summary-meta { display: inline; }
}

/* —— Main —— */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.15rem 1.4rem 1.4rem;
  gap: 0.9rem;
}
.main-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.main-head h2 {
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.platform-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
}
.platform-badge.windows,
.platform-badge.macos,
.platform-badge.linux {
  color: var(--accent);
  border-color: #b7d9d9;
  background: var(--accent-soft);
}
.platform-badge.android,
.platform-badge.ios {
  color: #7c5c12;
  border-color: #e2c98a;
  background: var(--warn-bg);
}
.lead { color: var(--muted); margin: 0.28rem 0 0; font-size: 0.88rem; max-width: 52ch; }
.head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 0.45rem;
}
.stat {
  min-width: 96px;
  padding: 0.55rem 0.7rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat span {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 0.2rem;
}
.stat strong, .stat b {
  display: block;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* —— Tabs —— */
.tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0.22rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 11px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  backdrop-filter: blur(8px);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.48rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tab-i {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--soft);
  letter-spacing: 0.04em;
}
.tab:hover { color: var(--ink); background: rgba(12, 18, 32, 0.04); }
.tab.active {
  background: var(--ink);
  color: #fff;
}
.tab.active .tab-i { color: var(--accent-2); }
.tab.tab-hidden { display: none !important; }

.tab-panels { flex: 1; min-height: 0; }
.tab-panel { display: none; gap: 0.85rem; }
.tab-panel.active { display: grid; }

.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.05rem;
  box-shadow: var(--shadow);
}
.block h3 {
  font-size: 0.98rem;
  font-weight: 650;
  margin: 0 0 0.55rem;
  letter-spacing: -0.02em;
}
.block h3 + .hint,
.block .hint { margin-top: -0.25rem; margin-bottom: 0.7rem; }
.block-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.block-head h3 { margin-bottom: 0.15rem; }
.block-head .hint { margin: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.apps-notes-grid {
  align-items: stretch;
  margin-top: 0.25rem;
}
.apps-notes-grid > .block {
  margin: 0;
  min-width: 0;
}
.apps-notes-grid:has(> .phone-only.hidden) {
  grid-template-columns: 1fr;
}
.apps-docs-grid {
  align-items: stretch;
  margin-bottom: 0.85rem;
}
.apps-docs-grid > .block {
  margin: 0;
  min-width: 0;
}
.apps-docs-grid .scroll-list.tall {
  max-height: 420px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}
.settings-grid label { margin: 0; }

/* —— Controls —— */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.26rem 0.7rem 0.26rem 0.3rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  color: var(--muted);
}
.toggle-knob {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #c5d0da;
  position: relative;
  flex-shrink: 0;
}
.toggle-knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.toggle:hover:not(:disabled) { background: var(--surface-2); }
.toggle.is-on { color: var(--ok); border-color: #9ad4b8; background: var(--ok-bg); }
.toggle.is-on:hover:not(:disabled) { background: var(--ok-bg); }
.toggle.is-on .toggle-knob { background: var(--ok); }
.toggle.is-on .toggle-knob::after { transform: translateX(14px); }
.toggle.busy {
  pointer-events: none;
  color: var(--warn);
  border-color: #e2c98a;
  background: var(--warn-bg);
}
.toggle.busy .toggle-knob { background: var(--warn); }

.interval-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.5rem 0.18rem 0.65rem;
}
.interval-chip select,
.interval-chip input[type="number"] {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
}
.interval-chip input[type="number"] {
  width: 3.6rem;
  outline: none;
}

label {
  display: grid;
  gap: 0.28rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
input[type="text"],
input[type="password"],
input[type="time"],
input[type="number"],
input[type="email"],
select {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  padding: 0.52rem 0.68rem;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 110, 115, 0.14);
}

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 0.58rem 0.88rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
button.ghost:hover:not(:disabled) { background: var(--surface-2); }
button.compact { padding: 0.38rem 0.65rem; font-size: 0.8rem; }
button.busy, button:disabled { opacity: 0.7; cursor: wait; }

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 4000;
  display: grid;
  gap: 0.4rem;
  width: min(360px, calc(100vw - 2rem));
}
.toast {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: #101820;
  color: #fff;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--accent-2);
}
.toast.wait { border-left-color: #e0b34e; }
.toast.ok { border-left-color: #3dbe86; }
.toast.err { border-left-color: #e35d55; background: #3a1515; }

.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 160px;
  overflow-y: auto;
}
.feature-chip {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
button.feature-chip,
.feature-chip.toggle-chip {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  line-height: inherit;
}
button.feature-chip:hover,
.feature-chip.toggle-chip:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}
button.feature-chip:disabled {
  opacity: 0.6;
  cursor: wait;
}
.feature-chip.on {
  background: var(--ok-bg);
  border-color: #9ad4b8;
  color: var(--ok);
}

.explorer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.explorer-bar input { flex: 1 1 220px; min-width: 180px; margin: 0; font-family: var(--mono); font-size: 0.82rem; }
.cmd-status { min-height: 1.2em; color: var(--accent); font-family: var(--mono); font-size: 0.75rem; }
.subhead { margin: 1.1rem 0 0.5rem; font-size: 0.92rem; }
.tree-details {
  margin-top: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem 0.75rem;
  background: var(--surface-2);
}
.tree-details summary { cursor: pointer; font-weight: 650; padding: 0.25rem 0; }

.inbox-row {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
}
.inbox-row .meta { font-size: 0.75rem; color: var(--muted); word-break: break-all; }

/* —— Devices —— */
.dev-filter {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem;
  margin: 0.5rem 0 0;
}
.dev-filter button {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.32rem 0.35rem;
  font-size: 0.72rem;
  white-space: nowrap;
}
.dev-filter button.active {
  background: rgba(94, 234, 212, 0.16);
  border-color: rgba(94, 234, 212, 0.4);
  color: #5eead4;
}
.dev-group { margin-bottom: 0.55rem; }
.dev-group:last-child { margin-bottom: 0.15rem; }
.dev-group-title {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6f8494;
  margin: 0.1rem 0 0.3rem;
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #141c24 70%, transparent);
  padding: 0.15rem 0 0.25rem;
}
.device-list {
  display: grid;
  gap: 0.38rem;
  align-content: start;
}
.device-list.empty {
  color: var(--sidebar-muted);
  font-size: 0.84rem;
  padding: 0.55rem 0.15rem;
  display: block;
}
.device-row { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem; align-items: stretch; }
.device {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.12rem 0.5rem;
  padding: 0.58rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  font-weight: 500;
  width: 100%;
}
.device:hover { background: rgba(255, 255, 255, 0.08); }
.device.active {
  border-color: rgba(94, 234, 212, 0.45);
  background: rgba(20, 184, 166, 0.12);
}
.device .name {
  font-weight: 600;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device .kind {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  grid-column: 1 / -1;
}
.device .meta {
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phone-card {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.phone-card .kicker { margin-bottom: 0.45rem; }
.key-rebuilt {
  margin: 0.45rem 0 0.35rem;
  padding: 0.55rem 0.7rem;
  background: color-mix(in srgb, var(--accent, #2a7) 12%, transparent);
  border-radius: 8px;
}
.key-recorded {
  margin: 0.35rem 0;
  padding: 0.55rem 0.7rem;
  background: rgba(16, 24, 32, 0.04);
  border-radius: 8px;
  border: 1px solid var(--line);
}
.key-diag {
  margin: 0.45rem 0 0.2rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent, #2a7) 35%, var(--line));
  background: color-mix(in srgb, var(--accent, #2a7) 8%, transparent);
}
.key-diag.is-warn {
  border-color: #d97706;
  background: color-mix(in srgb, #d97706 12%, transparent);
}
.key-diag.is-ok {
  border-color: color-mix(in srgb, #059669 40%, var(--line));
}
.key-diag-sum {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.key-composed {
  margin: 0 0 0.45rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: rgba(16, 24, 32, 0.04);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88rem;
}
.key-diag-list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}
.key-rebuilt .kicker,
.key-recorded .kicker,
.key-diag .kicker {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.key-rebuilt pre,
.key-recorded pre,
.key-raw pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86rem;
}
.key-raw {
  margin-top: 0.35rem;
  opacity: 0.85;
}
.key-raw summary {
  cursor: pointer;
  font-size: 0.78rem;
}
.apps-docs-grid {
  align-items: stretch;
}
.apps-docs-grid .scroll-list.tall {
  max-height: 420px;
}
.maps-link {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: #5eead4;
  text-decoration: none;
}
.maps-link:hover { text-decoration: underline; }

.gps-minimap {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.65rem;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--bg);
  position: relative;
  z-index: 0;
}
.gps-minimap.hidden { display: none !important; }
.gps-minimap .leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
  background: #e8eef2;
}
.gps-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.gps-now-icon {
  background: transparent !important;
  border: 0 !important;
}
.gps-now-pulse,
.gps-now-core {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.gps-now-pulse {
  width: 28px;
  height: 28px;
  background: rgba(13, 148, 136, 0.28);
  animation: gps-now-pulse 1.6s ease-out infinite;
}
.gps-now-core {
  width: 14px;
  height: 14px;
  background: #0d9488;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
}
@keyframes gps-now-pulse {
  0% { transform: translate(-50%, -50%) scale(0.55); opacity: 0.85; }
  70% { transform: translate(-50%, -50%) scale(1.15); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1.15); opacity: 0; }
}
.gps-admin-tip {
  background: rgba(15, 23, 42, 0.88) !important;
  color: #f8fafc !important;
  border: 0 !important;
  border-radius: 6px !important;
  padding: 0.25rem 0.45rem !important;
  font-size: 0.75rem !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.gps-admin-tip::before { border-top-color: rgba(15, 23, 42, 0.88) !important; }

.day-summary {
  line-height: 1.55;
  white-space: normal;
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo-tile { border-radius: 8px; overflow: hidden; background: var(--card); cursor: pointer; transition: transform .15s; }
.photo-tile:hover { transform: scale(1.03); }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo-tile .photo-name { padding: 4px 6px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.account-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: start center;
  padding: 1.5rem;
}
.account-modal.hidden { display: none !important; }
.account-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 32, 0.45);
}
.account-modal-card {
  position: relative;
  width: min(420px, 100%);
  margin-top: 2.5rem;
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem 1.35rem 1.1rem;
  box-shadow: var(--shadow);
}
.account-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.account-modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.device-del {
  align-self: center;
  color: #f0a8a2 !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  min-width: 42px;
}
.pill {
  align-self: start;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.on { background: rgba(61, 190, 134, 0.2); color: #7ee0b2; }
.pill.off { background: rgba(224, 179, 78, 0.18); color: #f0c56a; }
.pill.wait { background: rgba(224, 179, 78, 0.18); color: #f0c56a; }
.pill.up { background: var(--ok-bg); color: var(--ok); }

/* —— Lists —— */
.usage-list, .scroll-list { display: grid; gap: 0.35rem; }
.usage-list {
  max-height: min(48vh, 420px);
  overflow-y: auto;
}
.scroll-list { max-height: 280px; overflow-y: auto; }
.scroll-list.tall { max-height: min(55vh, 420px); }
.usage-row, .alert-item, .doc-row {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.58rem 0.7rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.86rem;
}
.usage-row .meta, .alert-item .meta, .doc-row .meta {
  font-size: 0.74rem;
  color: var(--muted);
  word-break: break-all;
}

.media-frame {
  border-radius: var(--radius-sm);
  background: #0b1014;
  border: 1px solid #1c2730;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 280px;
}
.media-frame img, .live-frame img {
  width: 100%;
  max-height: min(72vh, 820px);
  object-fit: contain;
  display: block;
}
.live-frame { position: relative; min-height: 280px; background: #0b1014; }
.live-frame.is-remote {
  cursor: crosshair;
  outline: 2px solid var(--accent, #14b8a6);
  outline-offset: 2px;
}
.remote-tap-hint {
  display: none;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: .45rem .6rem;
  font-size: 12px;
  color: #e8f7f4;
  background: rgba(0,0,0,.55);
  pointer-events: none;
}
.live-frame.is-remote .remote-tap-hint { display: block; }
.control-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.7fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .control-layout { grid-template-columns: 1fr; }
}
.control-frame {
  min-height: min(70vh, 760px);
  user-select: none;
  touch-action: none;
}
.control-frame img {
  max-height: min(70vh, 760px);
  pointer-events: auto;
}
.control-pad h3 { margin: 0.15rem 0 0.35rem; }
.live-badge {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(15, 23, 32, 0.78);
  color: #fff;
}
.live-badge.on {
  background: rgba(15, 122, 86, 0.92);
  animation: livepulse 1.6s ease-in-out infinite;
}
@keyframes livepulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.shot-gallery-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 0.55rem;
}
.shot-gallery-head h3 { margin: 0; flex: 1 1 auto; }
.shot-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  max-height: min(60vh, 640px);
  overflow-y: auto;
  padding-right: 0.15rem;
}
.shot-empty {
  grid-column: 1 / -1;
  padding: 1.4rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}
button.shot-thumb {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  padding: 0;
  text-align: left;
  color: inherit;
}
button.shot-thumb:hover:not(:disabled) {
  background: #111;
  border-color: var(--accent);
}
.shot-thumb img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  display: block;
  background: #1a232c;
}
.shot-thumb span {
  display: block;
  padding: 0.35rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  background: #fff;
  border-top: 1px solid var(--line);
}
.video-progress {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.86rem;
}
.video-progress.hidden { display: none; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 12, 16, 0.9);
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 1rem 1rem 0.75rem;
  gap: 0.75rem;
}
.lightbox.hidden { display: none; }
.lb-close, .lb-nav {
  position: absolute;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}
.lb-close { top: 0.75rem; right: 1rem; font-size: 1.5rem; }
.lb-nav { top: 40%; font-size: 1.7rem; }
.lb-prev { left: 0.75rem; }
.lb-next { right: 0.75rem; }
.lb-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  gap: 0.5rem;
}
.lb-stage img {
  max-width: min(96vw, 1100px);
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border-radius: 8px;
  background: #111;
}
.lb-meta { color: rgba(255, 255, 255, 0.85); font-family: var(--mono); font-size: 0.78rem; }
.lb-film {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.35rem 0.25rem 0.75rem;
}
.lb-film button {
  flex: 0 0 auto;
  width: 88px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
}
.lb-film button.active { border-color: #5eead4; }
.lb-film img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }

.folder-tree {
  max-height: min(70vh, 720px);
  overflow: auto;
  padding: 0.35rem 0.15rem 0.6rem;
  font-size: 0.88rem;
}
.folder-tree ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
  border-left: 1px solid var(--line);
}
.folder-tree > ul.tree-root { padding-left: 0; border-left: 0; }
.tree-node { margin: 0.08rem 0; }
.tree-node details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}
.tree-node details > summary::-webkit-details-marker { display: none; }
.tree-node details > summary:hover { background: var(--accent-soft); }
.tree-leaf {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.16rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
}
.tree-leaf:hover { background: var(--surface-2); }
.tree-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-meta { margin-left: auto; color: var(--muted); font-size: 0.72rem; flex-shrink: 0; font-family: var(--mono); }
.tree-ico { width: 0.65rem; height: 0.65rem; border-radius: 2px; flex-shrink: 0; }
.tree-ico.dir { background: var(--accent); }
.tree-ico.file { background: var(--line-strong); }
.tree-more { color: var(--muted); font-size: 0.78rem; padding: 0.2rem 0.35rem; font-style: italic; }
button.tree-open {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.72rem;
  cursor: pointer;
  margin-left: 0.3rem;
  padding: 0.1rem 0.35rem;
}
button.tree-open:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.file-browser {
  margin-top: 0.55rem;
  max-height: min(55vh, 560px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
button.file-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.48rem 0.75rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  width: 100%;
  background: transparent;
  text-align: left;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  border-radius: 0;
}
button.file-row:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--ink);
}
.file-row .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .meta { color: var(--muted); font-size: 0.74rem; font-family: var(--mono); }

.key-log {
  max-height: min(65vh, 680px);
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  background: #0f161c;
  color: #d7e2ea;
  border-radius: var(--radius-sm);
}
.key-chunk { padding: 0.7rem 0.85rem; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.key-chunk .head { color: #5eead4; font-weight: 600; margin-bottom: 0.28rem; }
.key-chunk .when { color: #7d8f9e; font-size: 0.7rem; font-weight: 400; margin-left: 0.4rem; }
.key-chunk pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; color: #e8eef4; }
.key-log .alert-item {
  background: transparent;
  border: 0;
  color: #8fa0b0;
}

.lib-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.library-body {
  margin-top: 0.35rem;
  max-height: min(85vh, 1400px);
  overflow-y: auto;
  padding-right: 0.15rem;
}
.lib-day {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.55rem;
  background: var(--surface-2);
}
.lib-day > summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.86rem;
  padding: 0.55rem 0.75rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.lib-day > summary::-webkit-details-marker { display: none; }
.lib-day > summary::before {
  content: "▸";
  color: var(--accent);
  margin-right: 0.35rem;
  font-size: 0.75rem;
}
.lib-day[open] > summary::before { content: "▾"; }
.lib-day-body { padding: 0 0.65rem 0.75rem; }
.lib-day-body .shot-gallery {
  max-height: none;
  overflow: visible;
}
.lib-card {
  display: grid;
  gap: 0.35rem;
}
.lib-card .shot-thumb { width: 100%; }
.phone-card .scroll-list {
  max-height: min(36vh, 280px);
}

.audio-live {
  position: relative;
  padding: 1.1rem 1rem 0.85rem;
  border-radius: var(--radius-sm);
  background: #0f161c;
  border: 1px solid #1c2730;
}
.audio-live .hint { color: #8fa0b0; margin: 0.55rem 0 0; }
.audio-live .live-badge { position: absolute; top: 0.7rem; left: 0.7rem; }
.listen-wave {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 52px;
  margin: 2.15rem 0 0.15rem;
}
.listen-wave span {
  flex: 1;
  max-width: 9px;
  height: 18%;
  border-radius: 3px;
  background: #2a3a46;
}
.listen-wave.on span {
  background: #3ecf8e;
  animation: listenBar 0.85s ease-in-out infinite;
}
.listen-wave.on span:nth-child(2) { animation-delay: .07s; }
.listen-wave.on span:nth-child(3) { animation-delay: .14s; }
.listen-wave.on span:nth-child(4) { animation-delay: .21s; }
.listen-wave.on span:nth-child(5) { animation-delay: .28s; }
.listen-wave.on span:nth-child(6) { animation-delay: .35s; }
.listen-wave.on span:nth-child(7) { animation-delay: .18s; }
.listen-wave.on span:nth-child(8) { animation-delay: .11s; }
.listen-wave.on span:nth-child(9) { animation-delay: .24s; }
.listen-wave.on span:nth-child(10) { animation-delay: .31s; }
.listen-wave.on span:nth-child(11) { animation-delay: .08s; }
.listen-wave.on span:nth-child(12) { animation-delay: .16s; }
@keyframes listenBar {
  0%, 100% { height: 18%; }
  50% { height: 92%; }
}
.inbox-row audio { width: min(100%, 280px); margin-top: 0.35rem; display: block; }

.audio-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.2fr);
  gap: 0.9rem;
  align-items: start;
}
.audio-controls {
  display: grid;
  gap: 0.85rem;
}
.audio-panel .block-head,
.audio-library .block-head {
  align-items: flex-start;
}
.rec-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.rec-count {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  background: #eef3f7;
  color: var(--ink);
}
.rec-list {
  display: grid;
  gap: 0.55rem;
  max-height: min(70vh, 640px);
  overflow-y: auto;
  padding-right: 0.15rem;
}
.rec-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem 0.85rem;
  align-items: center;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.rec-item-main {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}
.rec-item-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.rec-item-top strong {
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}
.rec-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--mono);
}
.rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: #eef3f7;
  color: var(--muted);
}
.rec-badge.in { background: #e8f7ef; color: #0f7a4a; }
.rec-badge.out { background: #eaf2ff; color: #1d4f91; }
.rec-badge.ott { background: #f3eefc; color: #5b3d8f; }
.rec-item audio {
  width: 100%;
  max-width: 100%;
  height: 34px;
}
.rec-item .rec-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}
.rec-status {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: #f4f7fa;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.84rem;
}
@media (max-width: 980px) {
  .audio-layout { grid-template-columns: 1fr; }
  .rec-item { grid-template-columns: 1fr; }
  .rec-item .rec-actions { flex-direction: row; }
}

.foot {
  margin-top: auto;
  padding-top: 0.25rem;
  color: var(--soft);
  font-size: 0.76rem;
  text-align: center;
}

.doc-badge {
  font-size: 0.7rem;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  background: #eef3f7;
  color: var(--muted);
}
.doc-badge.on { background: var(--ok-bg); color: var(--ok); }

@media (max-width: 1100px) {
  .grid-3, .grid-2, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .stats { width: 100%; }
  .main { padding: 1rem; }
  .head-actions { align-items: stretch; width: 100%; }
}
