:root {
  --ink: #102a3f;
  --ink-soft: #29485f;
  --teal: #087f78;
  --teal-dark: #06645f;
  --teal-soft: #dff3f0;
  --teal-faint: #f2faf8;
  --paper: #f4f7f6;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --line: #dbe4e2;
  --line-strong: #c4d2cf;
  --muted: #607585;
  --amber: #d98214;
  --amber-soft: #fff2d8;
  --red: #c74638;
  --red-soft: #fdeae6;
  --green: #17845f;
  --green-soft: #e1f4ec;
  --blue-soft: #e9f1fb;
  --shadow-sm: 0 1px 2px rgba(16, 42, 63, 0.06), 0 6px 18px rgba(16, 42, 63, 0.05);
  --shadow-lg: 0 22px 60px rgba(16, 42, 63, 0.14);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button { cursor: pointer; }

button:disabled,
input:disabled { cursor: not-allowed; }

a { color: inherit; }

.page-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% -8%, rgba(8, 127, 120, 0.12), transparent 31rem),
    radial-gradient(circle at 100% 28%, rgba(217, 130, 20, 0.07), transparent 26rem),
    linear-gradient(rgba(16, 42, 63, 0.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 42, 63, 0.024) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  mask-image: linear-gradient(to bottom, black 0, transparent 70%);
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(196, 210, 207, 0.8);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header-inner,
.dashboard,
.site-footer {
  width: min(1480px, calc(100% - 64px));
  margin: 0 auto;
}

.header-inner {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 13px;
  background: transparent;
  box-shadow: 0 7px 18px rgba(11, 120, 240, 0.18);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }

.brand-copy { display: grid; line-height: 1.2; }
.brand-copy strong { font-size: 0.98rem; letter-spacing: -0.01em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 0.72rem; }

.module-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 4px;
}

.module-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 11px;
  font-size: 0.76rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.module-nav a span { color: #8ba09d; font-family: var(--font-mono); font-size: 0.62rem; }
.module-nav a:hover { color: var(--teal-dark); background: var(--teal-soft); }
.module-nav a.active { color: #fff; background: var(--ink); box-shadow: var(--shadow-sm); }
.module-nav a.active span { color: #9dd7d1; }

.auth-panel {
  width: min(560px, 58vw);
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(300px, 1.7fr);
  align-items: end;
  gap: 16px;
}

.session-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-width: 300px;
}

.auth-panel[hidden],
.session-panel[hidden] { display: none; }
.session-label { color: var(--ink-soft); font-size: 0.75rem; font-weight: 750; }
.session-panel .status-line { justify-content: flex-end; }

.auth-heading { min-width: 0; }

.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8c9aa4;
  box-shadow: 0 0 0 4px rgba(140, 154, 164, 0.14);
}

.status-line[data-state="connected"] { color: var(--green); }
.status-line[data-state="connected"] .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(23, 132, 95, 0.13); }
.status-line[data-state="error"] { color: var(--red); }
.status-line[data-state="error"] .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(199, 70, 56, 0.13); }

.token-row { display: flex; gap: 8px; }

.token-field { position: relative; min-width: 0; flex: 1; }
.token-field input { padding-right: 62px; }

.icon-button {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 7px;
  color: var(--teal-dark);
  background: transparent;
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 700;
}

.icon-button:hover { background: var(--teal-soft); }

.connect-button,
.primary-button,
.secondary-button,
.warning-button,
.danger-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.connect-button,
.primary-button {
  border: 1px solid var(--teal);
  color: #fff;
  background: var(--teal);
  box-shadow: 0 5px 14px rgba(8, 127, 120, 0.16);
}

.connect-button:hover,
.primary-button:hover { background: var(--teal-dark); border-color: var(--teal-dark); transform: translateY(-1px); }
.connect-button:active,
.primary-button:active { transform: translateY(0); box-shadow: none; }

.dashboard { padding: 54px 0 76px; }

.overview { margin-bottom: 28px; }

.section-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  align-items: end;
  gap: 48px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.65rem, 5.1vw, 5.4rem);
  line-height: 0.99;
  letter-spacing: -0.055em;
}

h1 span { color: var(--teal); }

h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h3 { margin: 0; font-size: 1.15rem; line-height: 1.3; letter-spacing: -0.015em; }

.overview-actions { display: grid; justify-items: start; gap: 18px; padding-bottom: 5px; }
.overview-actions p { max-width: 460px; margin: 0; color: var(--muted); }

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.secondary-button:hover { border-color: var(--teal); color: var(--teal-dark); background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.secondary-button span { font-size: 1.1em; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  position: relative;
  min-height: 154px;
  display: grid;
  align-content: space-between;
  padding: 22px 26px;
  border-right: 1px solid var(--line);
}

.metric-card:last-child { border-right: 0; }
.metric-card::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--teal); }
.metric-offline::after { background: var(--red); }
.metric-pending::after { background: var(--amber); }

.metric-label { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.metric-label i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.metric-offline .metric-label i { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.metric-pending .metric-label i { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.metric-card strong { margin-top: 12px; font-size: clamp(2.3rem, 4vw, 3.55rem); line-height: 1; letter-spacing: -0.055em; font-variant-numeric: tabular-nums; }
.metric-card small { color: var(--muted); font-size: 0.76rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(390px, 0.78fr);
  align-items: start;
  gap: 24px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
}

.fleet-panel { min-width: 0; padding: 28px; }

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.last-refresh { color: var(--muted); font-size: 0.74rem; text-align: right; }

.device-list { display: grid; gap: 12px; padding-top: 20px; }

.device-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 19px 20px 19px 24px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.device-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.device-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #aab5bc; }
.device-card.online::before { background: var(--green); }

.device-top { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.device-name { margin: 0 0 3px; font-size: 1.05rem; line-height: 1.3; }
.device-id { color: var(--muted); font-family: var(--font-mono); font-size: 0.7rem; overflow-wrap: anywhere; }

.pill,
.history-status {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  padding: 4px 9px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.online .pill { border-color: #b8dfd0; color: var(--green); background: var(--green-soft); }

.device-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 20px;
  margin: 15px 0 13px;
  color: var(--muted);
  font-size: 0.79rem;
}

.microphone-status {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 10px 11px;
}

.microphone-symbol {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.microphone-content { min-width: 0; }
.microphone-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 0.64rem; font-weight: 800; letter-spacing: 0.045em; text-transform: uppercase; }
.microphone-name { display: block; color: var(--ink); font-size: 0.87rem; line-height: 1.3; overflow-wrap: anywhere; }
.microphone-content small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.68rem; line-height: 1.35; }
.microphone-badge { min-width: max-content; border-radius: 999px; color: var(--teal-dark); background: var(--teal-soft); padding: 5px 8px; font-size: 0.64rem; font-weight: 850; }
.microphone-status.is-fallback .microphone-symbol,
.microphone-status.is-fallback .microphone-badge,
.microphone-status.is-unavailable .microphone-symbol,
.microphone-status.is-unavailable .microphone-badge { color: #986313; background: var(--amber-soft); }
.microphone-status.is-offline { opacity: 0.78; }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 15px;
}

.resource-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  padding: 9px 10px;
}

.resource-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.resource-heading span { color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.045em; text-transform: uppercase; }
.resource-heading strong { color: var(--ink); font-size: 0.82rem; }
.resource-metric small { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 0.65rem; text-overflow: ellipsis; white-space: nowrap; }

.resource-track {
  display: block;
  overflow: hidden;
  height: 4px;
  margin-top: 6px;
  border-radius: 999px;
  background: #dfe8e6;
}

.resource-fill { display: block; height: 100%; border-radius: inherit; background: var(--teal); transition: width 300ms ease; }
.resource-metric[data-kind="memory"] .resource-fill { background: #2f6fa5; }
.resource-metric[data-kind="disk"] .resource-fill { background: var(--amber); }

.livestudio-status {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f7faf9;
  padding: 11px 12px;
}

.livestudio-status.is-running { border-color: #b8dfd0; background: var(--green-soft); }
.livestudio-status.is-alert { border-color: #efb6b1; background: var(--red-soft); }
.livestudio-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.livestudio-heading strong { font-size: 0.76rem; }
.livestudio-heading span { color: var(--muted); font-size: 0.66rem; font-weight: 800; text-transform: uppercase; }
.livestudio-status.is-running .livestudio-heading span { color: var(--green); }
.livestudio-status.is-alert .livestudio-heading span { color: var(--red); }
.livestudio-status p { margin: 0; color: var(--muted); font-size: 0.7rem; line-height: 1.45; }
.livestudio-meta { display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: 0.64rem; }

.application-section {
  border-radius: 11px;
  background: #f8faf9;
  padding: 11px 12px;
}

.application-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.application-heading strong { font-size: 0.76rem; }
.application-heading span { color: var(--muted); font-size: 0.68rem; }
.processes { display: flex; flex-wrap: wrap; gap: 6px; }
.processes span { border: 1px solid #dce7e4; border-radius: 999px; color: var(--ink-soft); background: #edf4f2; padding: 4px 9px; font-size: 0.69rem; font-weight: 650; }
.processes .process-empty { border-style: dashed; color: var(--muted); background: transparent; font-weight: 500; }

.app-list-toggle {
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  padding: 8px 0 0;
  font-size: 0.71rem;
  font-weight: 750;
}

.app-list-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }

.card-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }

.link-button {
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  padding: 3px 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.link-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.link-button:disabled { color: #9ca9b1; }

.actions-panel { position: sticky; top: 108px; overflow: hidden; }
.actions-heading { padding: 24px 24px 18px; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 0 14px;
  border-radius: 11px;
  background: #edf2f1;
  padding: 5px;
}

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  padding: 7px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(16, 42, 63, 0.11); }

.action-form { display: none; padding: 24px; }
.action-form.active { display: block; animation: panel-in 220ms ease-out; }

.form-heading { margin-bottom: 21px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.form-heading p { margin: 5px 0 0; color: var(--muted); font-size: 0.82rem; }

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #fff;
  padding: 9px 11px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea { min-height: 108px; resize: vertical; line-height: 1.5; }
select { cursor: pointer; }
input::placeholder,
textarea::placeholder { color: #91a0aa; }
input:hover,
textarea:hover,
select:hover { border-color: #9eb2ad; }
input:focus,
textarea:focus,
select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 127, 120, 0.11); }
input:disabled { color: #8e9aa1; background: #eef2f1; }

.form-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 54px; }
.input-suffix span { position: absolute; top: 50%; right: 11px; transform: translateY(-50%); color: var(--muted); font-size: 0.72rem; pointer-events: none; }
.input-suffix.compact { width: 124px; flex: 0 0 auto; }

.repeat-control {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 15px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
  padding: 11px 12px;
  transition: opacity 160ms ease, border-color 160ms ease, background 160ms ease;
}

.repeat-control label { margin: 0 0 2px; }
.repeat-control small { display: block; color: var(--muted); font-size: 0.68rem; }
.muted-control { opacity: 0.56; }
.muted-control.enabled { opacity: 1; border-color: #b9dcd7; background: var(--teal-faint); }

.primary-button { width: 100%; margin-top: 20px; }
.primary-button span { margin-left: auto; font-size: 1.1rem; }

.check-card {
  display: flex;
  align-items: start;
  gap: 10px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
  padding: 11px 12px;
  cursor: pointer;
}

.check-card input { width: 17px; min-height: 17px; margin: 2px 0 0; accent-color: var(--teal); }
.check-card span { display: grid; }
.check-card strong { font-size: 0.76rem; }
.check-card small { margin-top: 2px; color: var(--muted); font-size: 0.68rem; font-weight: 400; }

.secret-result {
  margin-top: 16px;
  border: 1px solid #225067;
  border-radius: 10px;
  color: #d8f5ee;
  background: var(--ink);
  padding: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.55;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  justify-items: center;
  text-align: center;
  color: var(--muted);
  padding: 44px 20px;
}

.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 13px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  color: var(--teal-dark);
  background: var(--teal-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.empty-state strong { color: var(--ink); font-size: 0.92rem; }
.empty-state p { max-width: 360px; margin: 5px 0 0; font-size: 0.8rem; }
.empty-state:not(:has(.empty-icon)) { min-height: 180px; }

.history-panel { margin-top: 24px; padding: 28px; }
.history-heading { align-items: center; }
.history-heading-actions { display: flex; align-items: center; gap: 10px; }
.compact-button { min-height: 38px; padding: 0 13px; font-size: 0.78rem; }

.view-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-muted);
  padding: 3px;
}

.view-switch button {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  padding: 0 11px;
  font-size: 0.74rem;
  font-weight: 750;
}

.view-switch button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(16, 42, 63, 0.12); }

.history-tools {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 210px 180px;
  gap: 12px;
  margin: 20px 0;
  border-radius: 13px;
  background: var(--surface-muted);
  padding: 13px;
}

.history-tools label { margin-top: 0; }
.search-field { position: relative; }

.history-list { display: grid; gap: 11px; }

.history-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 19px 20px;
  transition: padding 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.history-card.compact { padding-top: 15px; padding-bottom: 14px; }
.history-card.expanded { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.history-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: #8ca0ad; }
.history-card.queued::before { background: var(--amber); }
.history-card.delivered::before { background: #4b82bd; }
.history-card.acknowledged::before { background: var(--green); }
.history-card.cancelled::before { background: #8b969c; }
.history-card.expired::before { background: var(--red); }
.history-card.cancelled { background: #fafbfa; }

.history-card-top { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.history-card-top > div { min-width: 0; }
.history-title { margin: 0; font-size: 1rem; line-height: 1.35; }
.history-message { max-width: 880px; margin: 6px 0 0; color: var(--muted); font-size: 0.84rem; white-space: pre-wrap; }
.history-card.compact .history-message {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  white-space: normal;
}

.history-summary { margin: 9px 0 0; color: var(--muted); font-size: 0.72rem; }
.history-details[hidden] { display: none; }

.history-status.queued { border-color: #f0d6a0; color: #9a5b09; background: var(--amber-soft); }
.history-status.delivered { border-color: #c8dbef; color: #356caa; background: var(--blue-soft); }
.history-status.acknowledged { border-color: #b8dfd0; color: var(--green); background: var(--green-soft); }
.history-status.cancelled { border-color: #d8dfe1; color: #687781; background: #eef1f2; }
.history-status.expired { border-color: #f1c8c0; color: var(--red); background: var(--red-soft); }

.history-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px 20px;
  margin: 18px 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 0.78rem;
}

.history-facts span { min-width: 0; overflow-wrap: anywhere; }
.history-facts strong { display: block; margin-bottom: 3px; color: var(--muted); font-size: 0.63rem; letter-spacing: 0.065em; text-transform: uppercase; }

.delivery-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
}

.delivery-stats span { padding: 9px 11px; border-right: 1px solid var(--line); color: var(--muted); font-size: 0.68rem; }
.delivery-stats span:last-child { border-right: 0; }
.delivery-stats b { display: block; margin-bottom: 1px; color: var(--ink); font-size: 1.08rem; line-height: 1.2; font-variant-numeric: tabular-nums; }

.history-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.history-detail-toggle { margin-right: auto; }

.warning-button,
.danger-button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.74rem;
}

.warning-button { border: 1px solid #efd09f; color: #985908; background: var(--amber-soft); }
.warning-button:hover { border-color: var(--amber); color: #fff; background: var(--amber); }

.danger-button {
  border: 1px solid #efc0b8;
  color: var(--red);
  background: var(--red-soft);
}

.danger-button:hover { border-color: var(--red); color: #fff; background: var(--red); }
.danger-button-quiet { min-height: 40px; border-color: transparent; background: transparent; padding: 0 8px; }

dialog {
  width: min(820px, calc(100% - 32px));
  max-height: 84vh;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 26px;
}

dialog::backdrop { background: rgba(10, 31, 48, 0.58); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-close { width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface-muted); font-size: 1.4rem; line-height: 1; }
.dialog-close:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-faint); }
.dialog-description { margin: 17px 0; color: var(--muted); font-size: 0.84rem; }

.config-form { display: grid; gap: 14px; }
.config-section { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); padding: 16px; }
.config-section-heading { display: grid; gap: 3px; margin-bottom: 4px; }
.config-section-heading strong { font-size: 0.9rem; }
.config-section-heading small { color: var(--muted); font-size: 0.72rem; }
.config-three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.config-toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.config-toggle-grid .check-card { height: 100%; margin: 0; }
.config-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 2px 0; }
.config-actions .primary-button { width: auto; min-width: 240px; margin: 0; }
.config-sync-status { color: var(--muted); font-size: 0.74rem; }
.config-snapshot { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.config-snapshot summary { color: var(--teal-dark); cursor: pointer; font-size: 0.76rem; font-weight: 750; }
.config-snapshot pre { margin-top: 12px; }

pre {
  max-height: 55vh;
  overflow: auto;
  margin: 0;
  border-radius: 12px;
  color: #d9eee9;
  background: #102a3f;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: min(420px, calc(100% - 32px));
  border: 1px solid #25556c;
  border-radius: 13px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow-lg);
  padding: 13px 16px;
  transform: translateY(30px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms ease, opacity 220ms ease;
}

#toast.show { transform: translateY(0) scale(1); opacity: 1; }
#toast.error { border-color: #dc796d; background: #9f3429; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 21px 0 32px;
  font-size: 0.72rem;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 1080px) {
  .header-inner,
  .dashboard,
  .site-footer { width: min(100% - 40px, 1480px); }
  .auth-panel { width: min(525px, 64vw); }
  .workspace { grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr); }
}

@media (max-width: 900px) {
  .site-header { position: relative; }
  .header-inner { min-height: auto; align-items: stretch; flex-direction: column; gap: 18px; padding: 20px 0; }
  .auth-panel { width: 100%; grid-template-columns: minmax(130px, 0.45fr) minmax(290px, 1fr); }
  .session-panel { width: 100%; justify-content: space-between; }
  .module-nav { width: 100%; }
  .module-nav a { flex: 1; justify-content: center; }
  .dashboard { padding-top: 38px; }
  .section-intro { grid-template-columns: 1fr; gap: 22px; }
  .overview-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
  .overview-actions p { max-width: 520px; }
  .workspace { grid-template-columns: 1fr; }
  .actions-panel { position: static; }
  .history-tools { grid-template-columns: 1fr 1fr; }
  .history-tools .search-field { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .header-inner,
  .dashboard,
  .site-footer { width: min(100% - 28px, 1480px); }
  .auth-panel { grid-template-columns: 1fr; gap: 9px; }
  .session-panel { min-width: 0; }
  .auth-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
  .auth-heading label { margin: 0; }
  .status-line { margin: 0; }
  .token-row { align-items: stretch; }
  .connect-button { padding: 0 13px; }
  .dashboard { padding-top: 30px; padding-bottom: 50px; }
  h1 { font-size: clamp(2.45rem, 12vw, 4rem); }
  .section-intro { margin-bottom: 25px; }
  .overview-actions { align-items: flex-start; flex-direction: column; gap: 14px; }
  .metrics { grid-template-columns: 1fr; border-radius: var(--radius); }
  .metric-card { min-height: 116px; grid-template-columns: 1fr auto; align-items: center; padding: 18px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-card:last-child { border-bottom: 0; }
  .metric-card::after { inset: 0 auto 0 0; width: 3px; height: auto; }
  .metric-card strong { grid-column: 2; grid-row: 1 / 3; margin: 0; }
  .metric-card small { grid-column: 1; }
  .panel,
  .metrics { border-radius: var(--radius); }
  .fleet-panel,
  .history-panel { padding: 20px; }
  .panel-heading { align-items: start; flex-direction: column; gap: 10px; }
  .last-refresh { text-align: left; }
  .device-top,
  .history-card-top { gap: 12px; }
  .tabs { overflow-x: auto; grid-template-columns: repeat(3, minmax(100px, 1fr)); }
  .action-form { padding: 20px; }
  .form-split { grid-template-columns: 1fr; gap: 0; }
  .config-three-columns,
  .config-toggle-grid { grid-template-columns: 1fr; gap: 0; }
  .config-toggle-grid { gap: 9px; }
  .config-actions { align-items: stretch; flex-direction: column; }
  .config-actions .primary-button { width: 100%; min-width: 0; }
  .repeat-control { align-items: stretch; flex-direction: column; }
  .input-suffix.compact { width: 100%; }
  .history-heading { flex-direction: row; align-items: center; }
  .history-tools { grid-template-columns: 1fr; }
  .history-tools .search-field { grid-column: auto; }
  .history-facts { grid-template-columns: 1fr 1fr; }
  .delivery-stats { grid-template-columns: 1fr 1fr; }
  .delivery-stats span:nth-child(2) { border-right: 0; }
  .delivery-stats span:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 4px; }
  #toast { right: 14px; bottom: 14px; }
}

@media (max-width: 420px) {
  .brand-copy small { display: none; }
  .module-nav { overflow-x: auto; }
  .module-nav a { min-width: max-content; }
  .token-row { flex-direction: column; }
  .connect-button { width: 100%; }
  .resource-grid { grid-template-columns: 1fr; }
  .microphone-status { grid-template-columns: 38px minmax(0, 1fr); }
  .microphone-badge { grid-column: 2; width: max-content; }
  .history-heading { align-items: start; flex-direction: column; }
  .history-heading-actions { width: 100%; justify-content: space-between; }
  .history-card-top { align-items: start; flex-direction: column-reverse; }
  .history-facts { grid-template-columns: 1fr; }
}
