/* 花仙 · 方案 C 极简轻应用风（居中轻工作区 + iOS 分组列表 + 手机原生体验） */
:root,
:root[data-theme="floral"] {
  --page-bg: #1b2847;
  --bg: #faf6f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --glass-border: rgba(255, 255, 255, 0.62);
  --bg-scrim: linear-gradient(
    180deg,
    rgba(16, 26, 52, 0.20) 0%,
    rgba(24, 34, 60, 0.10) 48%,
    rgba(14, 28, 44, 0.24) 100%
  );
  --soft: rgba(243, 232, 236, 0.86);
  --soft-hover: rgba(234, 217, 224, 0.94);
  --border: rgba(236, 224, 229, 0.88);
  --border-strong: rgba(219, 199, 208, 0.95);
  --text: #281d22;
  --muted: #6e5b64;
  --primary: #934b67;
  --primary-hover: #7c3c56;
  --primary-soft: rgba(147, 75, 103, 0.13);
  --primary-ring: rgba(147, 75, 103, 0.24);
  --primary-contrast: #ffffff;
  --hero-grad: linear-gradient(135deg, rgba(255, 248, 251, 0.90) 0%, rgba(247, 234, 241, 0.84) 100%);
  --ok: #2c8a56;
  --ok-bg: #e7f6ee;
  --warning: #c47618;
  --warning-bg: #fdf1e2;
  --danger: #c63f4b;
  --danger-bg: #fdebed;
  --shadow-sm: 0 2px 6px rgba(18, 26, 48, 0.08);
  --shadow-card: 0 8px 28px rgba(16, 26, 52, 0.14), 0 1px 3px rgba(16, 26, 52, 0.06);
  --shadow-float: 0 16px 40px rgba(16, 26, 52, 0.28);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 999px;
}

:root[data-theme="neutral"] {
  --page-bg: #1e3138;
  --bg: #f3f6f7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --glass-border: rgba(255, 255, 255, 0.66);
  --bg-scrim: linear-gradient(
    180deg,
    rgba(224, 236, 240, 0.34) 0%,
    rgba(236, 243, 245, 0.28) 52%,
    rgba(216, 230, 235, 0.38) 100%
  );
  --soft: rgba(232, 239, 239, 0.88);
  --soft-hover: rgba(220, 230, 231, 0.96);
  --border: rgba(221, 230, 231, 0.90);
  --border-strong: rgba(198, 213, 214, 0.96);
  --text: #182426;
  --muted: #526466;
  --primary: #2d6368;
  --primary-hover: #224f53;
  --primary-soft: rgba(45, 99, 104, 0.13);
  --primary-ring: rgba(45, 99, 104, 0.24);
  --primary-contrast: #ffffff;
  --hero-grad: linear-gradient(135deg, rgba(244, 250, 250, 0.90) 0%, rgba(231, 243, 243, 0.85) 100%);
  --ok: #238653;
  --ok-bg: #e5f5ec;
  --warning: #b97316;
  --warning-bg: #fcf0e0;
  --danger: #c43d48;
  --danger-bg: #fcebec;
  --shadow-sm: 0 2px 6px rgba(18, 32, 38, 0.08);
  --shadow-card: 0 8px 28px rgba(18, 32, 38, 0.14), 0 1px 3px rgba(18, 32, 38, 0.06);
  --shadow-float: 0 16px 40px rgba(18, 32, 38, 0.26);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--bg-scrim), url("/bg.jpg");
  background-size: cover;
  background-position: center 26%;
  background-repeat: no-repeat;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1, h2, h3, h4, p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  min-height: 40px;
  padding: 8px 15px;
  font-weight: 500;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  box-shadow: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:not([type="checkbox"]):not([type="radio"]) {
  -webkit-appearance: none;
  appearance: none;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

select:not([size]) {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2378656e' d='M2.2 4.2a.75.75 0 0 1 1.06 0L6 6.94l2.74-2.74a.75.75 0 1 1 1.06 1.06l-3.27 3.27a.75.75 0 0 1-1.06 0L2.2 5.26a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

input[type="number"],
.tabular {
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.primary {
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 600;
}
.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}
.primary.stop-action {
  background: var(--surface);
  color: var(--danger);
  border-color: rgba(198, 63, 75, 0.3);
  box-shadow: var(--shadow-sm);
}
.primary.stop-action:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.secondary:hover:not(:disabled) {
  background: var(--soft);
}

.soft-btn {
  background: var(--soft);
  color: var(--text);
}
.soft-btn:hover:not(:disabled) {
  background: var(--soft-hover);
}

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

.text-button,
.text-link {
  background: transparent;
  color: var(--primary);
  padding: 4px 8px;
  min-height: 32px;
  font-size: 13px;
  font-weight: 500;
}
.text-button:hover:not(:disabled),
.text-link:hover:not(:disabled) {
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
}

.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(198, 63, 75, 0.25);
}
.danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.compact-btn {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: var(--radius-pill);
}

.pill-btn {
  min-height: 34px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill-btn[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-contrast);
}

.icon-pill-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-pill);
  background: var(--soft);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.icon-pill-btn:hover:not(:disabled) {
  background: var(--soft-hover);
}

.full-width {
  width: 100%;
}

/* Typography helpers */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}
.muted {
  color: var(--muted);
}
.small-note {
  font-size: 12px;
  color: var(--muted);
}
.view-title {
  font-size: 20px;
  font-weight: 700;
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  flex-shrink: 0;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.brand-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

/* Unauthenticated Header & Auth Card */
.auth-header {
  max-width: 860px;
  margin: 0 auto;
  padding: 18px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-header .brand {
  padding: 5px 13px 5px 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}
.auth-header .soft-btn {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

.auth-card {
  width: min(410px, calc(100% - 32px));
  margin: 44px auto 72px;
  padding: 28px 26px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 14px;
}
.auth-card h1 {
  font-size: 24px;
  font-weight: 700;
}
.locked-banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid rgba(198, 63, 75, 0.35);
  color: var(--danger);
  display: grid;
  gap: 8px;
  justify-items: start;
  font-size: 13px;
}
.warning-banner {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  border: 1px solid rgba(196, 118, 24, 0.35);
  color: var(--warning);
  font-size: 12px;
}
.code-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.code-input-row input {
  flex: 1 1 0;
  min-width: 0;
}
.code-send-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 8px 13px;
}
.auth-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.checkbox-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}
.account-bar-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

/* Global Toast */
.global-toast {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}
.global-toast:empty {
  display: none;
}
.app-root > .global-toast:not(:empty) {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(520px, calc(100% - 28px));
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid rgba(198, 63, 75, 0.35);
  box-shadow: var(--shadow-float);
  font-weight: 500;
}
dialog .global-toast:not(:empty) {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  text-align: left;
}

/* Segmented Control (iOS style) */
.segmented-control {
  display: inline-flex;
  padding: 3px;
  border-radius: 13px;
  background: var(--soft);
  gap: 3px;
}
.segmented-control button {
  flex: 1;
  min-height: 34px;
  padding: 5px 14px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  border: none;
  white-space: nowrap;
}
.segmented-control button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.segmented-control.compact-seg button {
  min-height: 32px;
  padding: 4px 11px;
  font-size: 12px;
}

/* Forms */
.stack-form {
  display: grid;
  gap: 14px;
}
.stack-field {
  display: grid;
  gap: 6px;
}
.stack-field > span {
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   AUTHENTICATED TOP HEADER (Scheme C Light Centered Bar)
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  margin-bottom: 10px;
}
:root[data-theme="neutral"] .app-header {
  background: rgba(246, 250, 251, 0.82);
}

.app-header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.header-left {
  flex: 1 1 0;
}
.header-right {
  flex-shrink: 0;
  gap: 8px;
}

/* Desktop Pill Account Switcher */
.account-pill-bar {
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  gap: 2px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.account-pills {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.account-pills::-webkit-scrollbar {
  display: none;
}
.account-pills[data-overflow-left="true"][data-overflow-right="true"] {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 14px,
    #000 calc(100% - 14px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 14px,
    #000 calc(100% - 14px),
    transparent 100%
  );
}
.account-pills[data-overflow-left="true"]:not([data-overflow-right="true"]) {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 100%);
}
.account-pills[data-overflow-right="true"]:not([data-overflow-left="true"]) {
  -webkit-mask-image: linear-gradient(
    to right,
    #000 0,
    #000 calc(100% - 14px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    #000 0,
    #000 calc(100% - 14px),
    transparent 100%
  );
}
.account-pill {
  min-height: 30px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 140px;
}
.account-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-pill:hover:not(:disabled) {
  color: var(--text);
}
.account-pill[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.pill-add-btn,
.pill-more-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pill-add-btn:hover:not(:disabled),
.pill-more-btn:hover:not(:disabled) {
  background: var(--surface);
  color: var(--primary);
}

/* Desktop Pill Navigation */
.desktop-pill-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.desktop-pill-nav button {
  min-height: 34px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.desktop-pill-nav button:hover {
  color: var(--text);
  background: var(--soft);
}
.desktop-pill-nav button[aria-pressed="true"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.mobile-account-trigger {
  display: none;
}

/* Status Dots & Badges */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.42;
  flex-shrink: 0;
}
.status-dot[data-state="online"] {
  background: var(--ok);
  opacity: 1;
}
.status-dot[data-state="failed"] {
  background: var(--danger);
  opacity: 1;
}
.status-dot[data-state="authorizing"],
.status-dot[data-state="connecting"],
.status-dot[data-state="reconnecting"],
.status-dot[data-state="scanning"],
.status-dot[data-state="devices"],
.status-dot[data-state="discovering"] {
  background: var(--warning);
  opacity: 1;
}

.dirty-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.admin-alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  background: var(--warning);
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-alert-badge[data-severity="critical"] {
  background: var(--danger);
}

/* ============================================================
   CENTERED LIGHT-APP CONTAINER (860px)
   ============================================================ */
.light-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 6px 20px 104px;
}

.view-stack {
  display: grid;
  gap: 18px;
}

.group-section {
  display: grid;
  gap: 0;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 6px;
}

.group-section > .section-header,
.group-section > .section-label {
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.34);
  border-bottom: 1px solid var(--border);
}

.section-label {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.group-section > .section-header .text-link {
  padding: 3px 9px;
  min-height: 28px;
}

.group-section > .grouped-list,
.group-section > .inset-card {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.group-section > .log-list {
  padding: 12px 14px;
}

.section-meta,
.section-hint {
  font-size: 12px;
  color: var(--muted);
  padding: 0 2px;
}
.section-meta:empty {
  display: none;
}

/* Empty Hero */
.empty-hero {
  max-width: 420px;
  margin: 64px auto;
  padding: 36px 26px;
  text-align: center;
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
  justify-items: center;
}
.empty-hero-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Error Banner */
.error-banner {
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(198, 63, 75, 0.25);
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   SCHEME C HERO LIGHT CARD (Overview)
   ============================================================ */
.hero-card {
  background: var(--hero-grad);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 24px 26px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-card[data-tone="running"] {
  border-color: rgba(44, 138, 86, 0.34);
}
.hero-card[data-tone="attention"] {
  border-color: rgba(196, 118, 24, 0.42);
}

.hero-card-info {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 5px;
}
.hero-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-title-row h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}
.hero-meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hero-status-title {
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}
.hero-status-desc {
  font-size: 12px;
  color: var(--muted);
}
.hero-sync {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.hero-card-cta {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
}
.hero-btn {
  min-height: 46px;
  padding: 11px 26px;
  border-radius: 16px;
  font-size: 14px;
}

/* State Pill Badge */
.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}
.state-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.state-badge[data-state="online"] {
  background: var(--ok-bg);
  color: var(--ok);
}
.state-badge[data-state="failed"] {
  background: var(--danger-bg);
  color: var(--danger);
}
.state-badge[data-state="authorizing"],
.state-badge[data-state="connecting"],
.state-badge[data-state="reconnecting"],
.state-badge[data-state="scanning"],
.state-badge[data-state="devices"],
.state-badge[data-state="discovering"] {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ============================================================
   iOS INSET CARDS & GROUPED LISTS (Scheme C Signature)
   ============================================================ */
.inset-card {
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(1.18);
  -webkit-backdrop-filter: blur(16px) saturate(1.18);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card-heading h2,
.card-heading h3 {
  font-size: 15px;
  font-weight: 700;
}

.grouped-list {
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(1.18);
  -webkit-backdrop-filter: blur(16px) saturate(1.18);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.group-row {
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: background 0.14s ease;
}
.group-row + .group-row {
  border-top: 1px solid var(--border);
}
.group-row:hover {
  background: rgba(0, 0, 0, 0.018);
}

.group-row-info {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}
.group-row-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.group-row-head strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.priority-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.group-row-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-row-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.row-chevron {
  color: var(--muted);
  opacity: 0.6;
  font-size: 18px;
  line-height: 1;
}

/* iOS Modern Toggle Switch */
.hx-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.hx-toggle-label:has(input:checked) {
  background: var(--primary-soft);
  border-color: rgba(147, 75, 103, 0.22);
}
:root[data-theme="neutral"] .hx-toggle-label:has(input:checked) {
  border-color: rgba(45, 99, 104, 0.25);
}
.hx-toggle-label > span {
  font-size: 13px;
  font-weight: 500;
}

.hx-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.hx-switch input {
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  cursor: pointer;
}
.hx-switch-track {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.18s ease;
  pointer-events: none;
}
.hx-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}
.hx-switch input:checked + .hx-switch-track {
  background: var(--primary);
}
.hx-switch input:checked + .hx-switch-track::after {
  transform: translateX(18px);
}
.hx-switch input:focus-visible + .hx-switch-track {
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Enrollment Panel */
.enrollment-card {
  justify-items: start;
}
.qr-image {
  width: 210px;
  height: 210px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px;
}
.enrollment-list,
.role-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}
.role-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.enrollment-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}

/* Budget Progress Bars */
.budget-bars {
  display: grid;
  gap: 12px;
}
.budget-bar-row {
  display: grid;
  gap: 6px;
}
.budget-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.budget-bar-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  overflow: hidden;
}
.budget-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 0.25s ease;
}
.budget-bar-fill[data-high="true"] {
  background: var(--warning);
}

/* Recent Feed (Minimal iOS Hairline Rows) */
.recent-card {
  padding: 6px 16px 12px;
  gap: 0;
}
.recent-list {
  display: grid;
}
.recent-row {
  padding: 11px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.recent-row + .recent-row {
  border-top: 1px solid var(--border);
}
.recent-row-text {
  min-width: 0;
  flex: 1;
}
.recent-row-text strong {
  font-weight: 600;
}
.recent-row-text span {
  color: var(--muted);
}
.recent-row time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.recent-footer {
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.uncertain-card {
  border-color: var(--warning);
  border-left: 4px solid var(--warning);
}
.uncertain-list {
  display: grid;
  gap: 10px;
}
.uncertain-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  display: grid;
  gap: 8px;
}

.continuity-note {
  font-size: 12px;
  color: var(--text);
  text-align: center;
  margin: 4px auto 0;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
}

/* ============================================================
   PLAN VIEW (iOS Segmented + Inset Grouped Settings)
   ============================================================ */
#automation {
  gap: 0;
}
#planFeatures,
#budgetDetails {
  gap: 0;
}
#featureGroupList,
#budgetSettings,
#strategyDetails,
#emptyFeatures {
  margin-top: 16px;
}
#featureGroupList {
  gap: 16px;
}

.plan-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}
#automation:has(> #planFeatures:not([hidden])) > .plan-top-bar,
#automation:has(> #budgetDetails:not([hidden])) > .plan-top-bar {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: var(--border);
  box-shadow: none;
}
.plan-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.plan-sub-panel,
#budgetDetails > .section-hint {
  padding: 12px 16px 14px;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--glass-border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.plan-sub-panel {
  display: grid;
  gap: 8px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-wrap {
  flex: 1;
  min-width: 0;
}
.search-wrap input {
  min-height: 40px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.72);
}

/* Feature Detail Inspector inside Modal/Sheet */
.feature-detail-body {
  display: grid;
}
.feature-card {
  display: grid;
  gap: 14px;
}
.feature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.feature-status {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
}
.feature-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.feature-description {
  font-size: 13px;
  color: var(--muted);
}
.feature-run-result {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  border: 1px solid var(--border);
  font-size: 13px;
}
.feature-run-result[data-state="error"] {
  background: var(--danger-bg);
  border-color: transparent;
}
.run-result-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.run-result-head time,
.run-result-note,
.run-result-item span {
  color: var(--muted);
}
.run-result-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
}
.run-result-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.run-result-item > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.run-result-mark {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface);
  color: var(--muted);
}
.run-result-item[data-status="success"] .run-result-mark {
  background: var(--ok-bg);
  color: var(--ok);
}
.run-result-item[data-status="error"] .run-result-mark {
  background: var(--danger-bg);
  color: var(--danger);
}
.run-result-item[data-status="blocked"] .run-result-mark,
.run-result-item[data-status="uncertain"] .run-result-mark {
  background: var(--warning-bg);
  color: var(--warning);
}
.run-result-item .run-result-gains {
  color: var(--ok);
}
.run-result-more {
  justify-self: start;
  font-size: 12px;
}
.feature-parameters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.number-field,
.select-field {
  display: grid;
  gap: 6px;
}
.number-field > span,
.select-field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.item-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
}
.item-field > p,
.item-field > label {
  font-size: 13px;
  font-weight: 600;
}
.item-field select[size] {
  min-height: 108px;
  padding: 6px 8px;
}
.item-field-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.item-field-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.item-field-summary {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}
.item-field-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.selected-items {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}
.selected-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
}
.selected-item > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.tiny {
  min-height: 30px;
  padding: 3px 9px;
  font-size: 12px;
}

/* Budgets & Schedule */
.budget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.budget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
}
.budget-card h3 {
  font-size: 15px;
  font-weight: 700;
}
.budget-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.strategy-body {
  display: grid;
  gap: 14px;
}
.reconnect-settings {
  display: grid;
  gap: 8px;
}
.reconnect-presence-options {
  display: grid;
  gap: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border, #e5e7eb);
}
.reconnect-presence-options[hidden] {
  display: none;
}
.reconnect-settings .small-note {
  margin: 0;
}
.bootstrap-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 8px;
}
.bootstrap-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.bootstrap-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-subtle, rgba(0, 0, 0, 0.03));
}
.bootstrap-item-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.bootstrap-item-actions {
  display: flex;
  gap: 6px;
}
.bootstrap-select-label {
  display: grid;
  gap: 6px;
  flex: 1 1 240px;
}
.redeem-card {
  display: grid;
  gap: 14px;
}
.redeem-submit-form {
  display: grid;
  gap: 10px;
}
.redeem-input-field textarea {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
}
.redeem-submit-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.redeem-ttl-field {
  max-width: 180px;
}
.redeem-subsection {
  display: grid;
  gap: 8px;
}
.redeem-subhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.redeem-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.redeem-slot-card {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-subtle, rgba(0, 0, 0, 0.03));
}
.redeem-slot-card.is-done {
  border-color: rgba(45, 138, 78, 0.35);
}
.redeem-slot-card.is-alerted {
  border-color: rgba(198, 71, 71, 0.45);
}
.redeem-slot-card.is-listening {
  border-color: rgba(65, 118, 198, 0.4);
}
.redeem-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.redeem-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
}
.redeem-status-badge.is-done {
  background: rgba(45, 138, 78, 0.16);
  color: #1f6b3a;
}
.redeem-status-badge.is-alerted {
  background: rgba(198, 71, 71, 0.16);
  color: #a62c2c;
}
.redeem-status-badge.is-listening {
  background: rgba(65, 118, 198, 0.16);
  color: #24569e;
}
.redeem-slot-code {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}
.redeem-slot-alert-note {
  margin: 0;
  font-size: 12px;
  color: #a62c2c;
}
.redeem-clues {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.redeem-clue-chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.redeem-history-list {
  display: grid;
  gap: 8px;
}
.redeem-history-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-subtle, rgba(0, 0, 0, 0.03));
  display: grid;
  gap: 4px;
}
.redeem-history-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.redeem-config-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.redeem-config-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.redeem-config-body {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}
.redeem-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.redeem-probe-field {
  max-width: 280px;
}
.redeem-slot-editor {
  display: grid;
  gap: 8px;
}
.redeem-editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-subtle, rgba(0, 0, 0, 0.03));
}
.redeem-editor-row input[type="time"] {
  width: 112px;
}
.redeem-editor-row input[type="text"] {
  flex: 1 1 130px;
  min-width: 110px;
}
.redeem-mini-field {
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}
.redeem-mini-field input {
  width: 72px;
}
.time-settings {
  display: grid;
  gap: 10px;
}
.time-settings > p {
  font-size: 13px;
  font-weight: 600;
}
.time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.time-row input[type="time"],
.time-row select {
  width: auto;
  flex: 1;
  min-width: 118px;
}

/* Smart Floating Save Pill */
.save-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 22px;
  z-index: 40;
  width: min(560px, calc(100% - 32px));
  padding: 11px 15px;
  border-radius: 18px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.save-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.save-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f5b942;
  flex-shrink: 0;
}
.save-bar-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}
.save-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.save-bar-ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  min-height: 36px;
  padding: 6px 12px;
}
.save-bar-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.24);
}
.save-bar .primary {
  min-height: 36px;
  padding: 6px 16px;
}

/* Logs */
.log-toolbar {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) minmax(180px, 2fr);
  gap: 10px;
  align-items: end;
}
.log-toolbar label {
  display: grid;
  gap: 5px;
}
.log-toolbar label > span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.log-list {
  display: grid;
  gap: 10px;
}
.log-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 6px;
}
.log-row[data-status="success"] { border-left-color: var(--ok); }
.log-row[data-status="blocked"],
.log-row[data-status="uncertain"] { border-left-color: var(--warning); }
.log-row[data-status="error"] { border-left-color: var(--danger); }
.log-row-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.log-row-heading time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.log-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  color: var(--muted);
}
.log-row[data-status="success"] .log-status { background: var(--ok-bg); color: var(--ok); }
.log-row[data-status="blocked"] .log-status,
.log-row[data-status="uncertain"] .log-status { background: var(--warning-bg); color: var(--warning); }
.log-row[data-status="error"] .log-status { background: var(--danger-bg); color: var(--danger); }
.log-row details {
  font-size: 12px;
  color: var(--muted);
}
.log-row summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
}

/* Settings */
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-form .stack-field {
  flex: 1;
  min-width: 180px;
}
.danger-zone {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  justify-items: start;
}
.event-pre {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Admin Console */
.admin-console-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(1.18);
  -webkit-backdrop-filter: blur(16px) saturate(1.18);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}
.admin-console-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.admin-stat-card {
  padding: 14px 16px;
  gap: 6px;
}
.admin-stat-card strong {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
}
.admin-stat-card[data-severity="warning"] {
  border-color: var(--warning);
  border-left: 4px solid var(--warning);
}
.admin-stat-card[data-severity="critical"] {
  border-color: var(--danger);
  border-left: 4px solid var(--danger);
}
.admin-toolbar {
  grid-template-columns: repeat(3, minmax(110px, 1fr)) minmax(160px, 2fr);
}
.protocol-alerts-list {
  display: grid;
  gap: 10px;
}
.protocol-alert-item {
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  background: var(--bg);
  display: grid;
  gap: 7px;
}
.protocol-alert-item[data-severity="critical"] { border-left-color: var(--danger); }
.protocol-alert-item[data-acknowledged="true"] { opacity: 0.65; }
.protocol-alert-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.protocol-alert-head time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.protocol-alert-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--warning);
  color: #fff;
}
.protocol-alert-item[data-severity="critical"] .protocol-alert-badge {
  background: var(--danger);
}
.alert-code-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.protocol-alert-item button {
  justify-self: start;
}

.user-filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  margin-top: 8px;
}
.user-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.user-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  gap: 10px;
}
.user-card[data-locked="true"] {
  border-color: var(--danger);
  border-left: 4px solid var(--danger);
}
.user-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.user-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  color: var(--text);
}
.user-badge.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.user-badge.badge-muted {
  background: var(--soft);
  color: var(--muted);
}
.user-badge.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.user-badge.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.smtp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.smtp-test-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.form-grid {
  display: grid;
  gap: 8px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
}
.logs-header-card > .section-header {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
}

.empty-state,
.empty-copy {
  color: var(--muted);
  font-size: 13px;
  padding: 18px 14px;
  text-align: center;
}
.view-stack > .empty-state {
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}
.official-help {
  white-space: pre-line;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  font-size: 13px;
  line-height: 1.6;
}

/* ============================================================
   DIALOGS & BOTTOM SHEETS
   ============================================================ */
dialog {
  width: min(500px, calc(100% - 24px));
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  padding: 22px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-float);
}
dialog#featureDetailDialog {
  width: min(580px, calc(100% - 24px));
}
dialog::backdrop {
  background: rgba(20, 16, 18, 0.4);
  backdrop-filter: blur(3px);
}
dialog > * + * {
  margin-top: 14px;
}
.sheet-handle {
  display: none;
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dialog-heading h2 {
  font-size: 18px;
  font-weight: 700;
}

.mobile-game-list {
  display: grid;
  gap: 8px;
}
.mobile-game-row {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}
.mobile-game-row[aria-pressed="true"] {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.mobile-game-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.mobile-game-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--surface);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mobile-game-row[aria-pressed="true"] .mobile-game-avatar {
  background: var(--primary);
  color: var(--primary-contrast);
}
.mobile-game-meta {
  min-width: 0;
  display: grid;
}
.mobile-game-meta strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-game-meta small {
  font-size: 12px;
  color: var(--muted);
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.account-section {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}
.channel-field {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
}
.channel-field legend {
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px;
}
.channel-choices {
  display: grid;
  gap: 8px;
}
.channel-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}
.channel-choice small {
  margin-left: auto;
  color: var(--muted);
}
.controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.effect-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 2px;
}
.effect-item small {
  color: var(--muted);
}

/* Mobile-only Bottom TabBar hidden on desktop */
.mobile-tabbar {
  display: none;
}

/* ============================================================
   MOBILE NATIVE LIGHT-APP EXPERIENCE (< 820px)
   ============================================================ */
@media (max-width: 819px) {
  /* Prevent iOS Safari input zoom */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }
  button {
    min-height: 44px;
  }

  .desktop-only-brand,
  .account-pill-bar,
  .desktop-pill-nav {
    display: none;
  }

  .app-header-inner {
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  }

  .mobile-account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    max-width: 100%;
    min-width: 0;
    padding: 6px 13px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    font-weight: 700;
  }
  .mobile-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-chip-caret {
    color: var(--muted);
    font-size: 12px;
  }

  .light-container {
    padding: 4px 14px calc(104px + env(safe-area-inset-bottom));
  }

  .hero-card {
    padding: 18px;
    border-radius: 22px;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .hero-btn {
    width: 100%;
  }

  .plan-top-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .plan-top-bar .segmented-control {
    width: 100%;
  }
  .plan-top-actions {
    justify-content: flex-end;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .segmented-control {
    width: 100%;
  }

  .budget-grid,
  .budget-inputs,
  .feature-parameters,
  .log-toolbar,
  .admin-toolbar,
  .smtp-grid,
  .user-filter-bar {
    grid-template-columns: 1fr;
  }

  .admin-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Floating Save Bar sits cleanly above Bottom TabBar */
  .save-bar {
    left: 12px;
    right: 12px;
    width: auto;
    transform: none;
    bottom: calc(68px + env(safe-area-inset-bottom));
    padding: 10px 14px;
  }

  /* Native Bottom TabBar */
  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    min-height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .mobile-tabbar button {
    border: none;
    border-radius: 0;
    padding: 6px 4px;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
  }
  .mobile-tabbar button[aria-pressed="true"] {
    color: var(--primary);
    font-weight: 700;
  }
  .mobile-tabbar .tab-icon {
    font-size: 18px;
    line-height: 1;
  }

  /* Native Bottom Sheet Style for Feature Inspector & Account Switcher */
  dialog.sheet-dialog {
    margin: auto 0 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 86dvh;
    border-radius: 24px 24px 0 0;
    padding: 12px 16px calc(22px + env(safe-area-inset-bottom));
  }
  .sheet-handle {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: 0 auto 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
