:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-warm: #fbf7ef;
  --ink: #111827;
  --muted: #5e6b7b;
  --faint: #8a96a6;
  --line: #d7dee6;
  --line-strong: #c3ccd7;
  --blue: #0d6fd6;
  --blue-soft: #eaf3ff;
  --green: #0ba35a;
  --green-soft: #e8f7ef;
  --purple: #9538d4;
  --purple-soft: #f4eafa;
  --orange: #f1790a;
  --orange-soft: #fff0df;
  --amber: #f5ad17;
  --shadow: 0 18px 44px rgba(17, 24, 39, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f9fbfc 0%, #eef3f7 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.42;
}

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

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin: 0;
}

ul {
  padding-left: 18px;
}

.desktop-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  border: 1px solid #cfd7df;
}

.app-titlebar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.title-lockup strong {
  display: block;
  font-size: 16px;
  line-height: 1.1;
}

.title-lockup span:not(.sq-mark):not(.version-pill) {
  color: var(--muted);
  font-size: 12px;
}

.sq-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #05070a;
  color: white;
  font-weight: 900;
}

.version-pill,
.mini-version,
.status-badge,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef3f7;
  color: #445161;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.window-tools {
  display: flex;
  gap: 16px;
  padding-right: 6px;
}

.window-tools span {
  width: 12px;
  height: 12px;
  border: 1px solid #111827;
  border-radius: 2px;
}

.window-tools span:first-child {
  height: 2px;
  align-self: end;
  margin-bottom: 2px;
  border-width: 0 0 1px;
}

.window-tools span:last-child {
  border: 0;
  position: relative;
}

.window-tools span:last-child::before,
.window-tools span:last-child::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 0;
  width: 14px;
  height: 1px;
  background: #111827;
}

.window-tools span:last-child::before {
  transform: rotate(45deg);
}

.window-tools span:last-child::after {
  transform: rotate(-45deg);
}

.workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: 358px minmax(620px, 1fr) 408px;
  background: var(--surface);
}

.library-pane,
.preset-pane,
.connection-pane {
  min-width: 0;
  min-height: 0;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.library-pane,
.preset-pane {
  border-right: 1px solid var(--line);
}

.library-pane,
.connection-pane {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.connection-pane {
  grid-template-rows: auto 1fr;
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px 20px 8px;
  color: #253042;
  text-transform: uppercase;
}

.pane-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.pane-title h2 {
  font-size: 13px;
  letter-spacing: 0;
}

.pane-title-row {
  justify-content: space-between;
}

.pane-title-row::after {
  order: 1;
}

.pane-title-row h2 {
  order: 0;
}

.pane-title-row .status-badge,
.pane-title-row .ghost-button {
  order: 2;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  padding: 8px 20px 14px;
}

.search-row input,
.field-grid input,
.assignment-card input,
.assignment-card select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 11px;
}

.search-row input::placeholder {
  color: #7b8796;
  font-style: italic;
}

.icon-button,
.tool-button,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: #1f2937;
  font-weight: 800;
  cursor: pointer;
}

.icon-button:hover,
.tool-button:hover,
.ghost-button:hover {
  background: #f3f7fb;
  border-color: #9fb0c2;
}

.mic-library {
  min-height: 0;
  overflow: auto;
  padding: 0 20px 16px;
}

.brand-group {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  overflow: hidden;
}

.brand-header {
  width: 100%;
  min-height: 47px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.brand-header strong {
  text-align: left;
  font-size: 15px;
}

.chevron {
  color: #0f172a;
  font-weight: 900;
}

.brand-models {
  display: grid;
}

.mic-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 10px;
  border-bottom: 1px solid #edf1f5;
  cursor: pointer;
  outline: 0;
}

.mic-row:last-child {
  border-bottom: 0;
}

.mic-row:hover,
.mic-row:focus-visible,
.mic-row.is-selected {
  background: linear-gradient(180deg, #f5f9ff, #edf5ff);
}

.mic-row.is-selected {
  box-shadow: inset 0 0 0 1px var(--blue);
}

.mic-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.mic-row-copy {
  min-width: 0;
}

.mic-row-name {
  display: block;
  overflow: hidden;
  color: #0f172a;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mic-row-meta {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.7);
}

.preset-pane {
  display: grid;
  grid-template-rows: auto 1fr;
}

.preset-detail,
.connection-panel {
  min-height: 0;
  overflow: auto;
}

.preset-detail {
  padding: 0 16px 18px;
}

.preset-identity {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr) 164px;
  gap: 18px;
  align-items: center;
  padding: 10px 0 20px;
}

.mic-art-card {
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-art {
  width: 100%;
  max-width: 220px;
  height: 132px;
  filter: drop-shadow(0 18px 22px rgba(15, 23, 42, 0.16));
}

.identity-copy {
  min-width: 0;
}

.headline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.headline-row h1 {
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.15;
}

.mic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
}

.mic-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.mic-tags span + span::before {
  content: "";
  width: 4px;
  height: 4px;
  margin-right: 8px;
  border-radius: 50%;
  background: #6b7280;
}

.source-list {
  display: grid;
  gap: 5px;
  margin-top: 18px;
}

.source-list div,
.settings-list div,
.status-card dl div {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px;
}

.source-list dt,
.settings-list dt,
.status-card dt {
  color: var(--muted);
}

.source-list dd,
.settings-list dd,
.status-card dd {
  color: #283445;
}

.verify-card {
  display: grid;
  gap: 12px;
  justify-items: end;
  color: #263445;
}

.verified-dot,
.ready-dot {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(11, 163, 90, 0.12);
}

.verify-card .verified-dot {
  justify-self: end;
}

.processor-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.processor-header,
.processor-row {
  display: grid;
  grid-template-columns: 126px minmax(250px, 0.86fr) minmax(248px, 1fr) 56px;
}

.processor-header {
  min-height: 38px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: #4c5a69;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.processor-header span,
.processor-row > div {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.processor-header span:last-child,
.processor-row > div:last-child {
  border-right: 0;
}

.processor-row {
  min-height: 134px;
  border-bottom: 1px solid var(--line);
}

.processor-row:last-child {
  border-bottom: 0;
}

.processor-name {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 9px;
  text-align: center;
}

.processor-name strong {
  line-height: 1.15;
}

.processor-icon {
  width: 46px;
  height: 46px;
}

.tone-green {
  color: var(--green);
}

.tone-purple {
  color: var(--purple);
}

.tone-blue {
  color: var(--blue);
}

.tone-orange {
  color: var(--orange);
}

.processor-settings,
.processor-graph,
.toggle-wrap {
  display: flex;
  align-items: center;
}

.processor-settings {
  color: #273242;
}

.settings-list {
  width: 100%;
  display: grid;
  gap: 6px 14px;
}

.settings-list dt,
.settings-list dd {
  font-size: 12px;
}

.settings-list dd {
  font-weight: 650;
}

.peq-mini-table {
  width: 100%;
  border-collapse: collapse;
  color: #273242;
  font-size: 12px;
}

.peq-mini-table th,
.peq-mini-table td {
  padding: 4px 7px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  white-space: nowrap;
}

.peq-mini-table th {
  color: var(--muted);
  font-weight: 800;
}

.peq-mini-table tr:last-child td {
  border-bottom: 0;
}

.processor-graph {
  min-width: 0;
}

.mini-graph {
  width: 100%;
  min-width: 220px;
  height: 118px;
}

.grid-lines line {
  stroke: #e1e7ee;
  stroke-width: 1;
}

.axis-labels text,
.mini-graph text {
  fill: #607083;
  font-size: 10px;
  font-family: inherit;
}

.graph-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.graph-line.green {
  stroke: var(--green);
}

.graph-line.purple {
  stroke: var(--purple);
}

.graph-line.blue {
  stroke: var(--blue);
}

.graph-line.orange {
  stroke: var(--orange);
}

.graph-fill {
  opacity: 0.16;
}

.graph-fill.purple {
  fill: var(--purple);
}

.graph-marker {
  stroke: #c2ccd6;
  stroke-dasharray: 4 4;
}

.zero-line {
  stroke: #9aa7b5;
  stroke-width: 1.2;
}

.band-dot {
  fill: white;
  stroke-width: 3;
}

.band-1 {
  stroke: #5b8ee5;
}

.band-2 {
  stroke: var(--green);
}

.band-3 {
  stroke: #1f78d1;
}

.band-4 {
  stroke: var(--purple);
}

.toggle-wrap {
  justify-content: center;
}

.toggle {
  width: 34px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  background: #c9d2dd;
}

.toggle::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.24);
}

.toggle.is-on {
  justify-content: flex-end;
  background: currentColor;
}

.notes-board {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  margin-top: 14px;
}

.notes-board > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.notes-board h2 {
  margin-bottom: 8px;
  color: #263445;
  font-size: 13px;
  text-transform: uppercase;
}

.notes-board li,
.notes-board p {
  margin: 6px 0;
  color: var(--muted);
}

.connection-panel {
  padding: 0 20px 20px;
}

.field-grid,
.color-icon-row {
  display: grid;
  grid-template-columns: 1fr 122px;
  gap: 14px;
}

.color-icon-row {
  grid-template-columns: 1fr 1fr;
}

.connection-panel label,
.assignment-card label {
  display: grid;
  gap: 5px;
}

.connection-panel label span,
.assignment-card label span {
  color: #2b3544;
  font-size: 12px;
  font-weight: 750;
}

.full-width,
.apply-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  min-height: 38px;
}

.status-card,
.assignment-card,
.terminal-card {
  margin-top: 18px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.status-card {
  background: linear-gradient(135deg, #fbfffd, var(--green-soft));
}

.status-card > div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: #087243;
}

.status-card dl {
  display: grid;
  gap: 6px;
}

.assignment-card h3,
.terminal-card h3 {
  margin-bottom: 10px;
  color: #263445;
  font-size: 13px;
  text-transform: uppercase;
}

.assignment-card {
  display: grid;
  gap: 12px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.mode-card {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.mode-card strong {
  color: #172033;
}

.mode-card span {
  color: var(--muted);
  font-size: 12px;
}

.mode-card.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.terminal-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tiny-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.terminal-card pre {
  min-height: 148px;
  max-height: 210px;
  margin: 0;
  overflow: auto;
  border-radius: 6px;
  background: #06080a;
  color: #84ff72;
  font: 12px/1.45 "SFMono-Regular", Consolas, monospace;
  padding: 12px;
  white-space: pre-wrap;
}

.safety-row {
  grid-template-columns: 18px 1fr;
  align-items: start;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.safety-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.apply-button {
  border: 1px solid #b8c2cf;
  border-radius: 8px;
  background: #eef2f6;
  color: #6e7886;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-panel {
  margin: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.compare-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  padding: 14px;
}

.compare-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.compare-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compare-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compare-card p {
  margin: 6px 0 12px;
  color: var(--muted);
}

.statusbar {
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: #4e5b69;
  font-size: 12px;
}

.statusbar div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.statusbar a {
  justify-self: end;
  color: #334155;
  font-weight: 800;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

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

@media (max-width: 1260px) {
  .workbench {
    grid-template-columns: 320px minmax(520px, 1fr);
  }

  .connection-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .connection-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 14px;
  }

  .connection-panel > * {
    margin-top: 0;
  }

  .field-grid,
  .full-width,
  .apply-button,
  .safety-row {
    grid-column: auto;
  }
}

@media (max-width: 940px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .library-pane,
  .preset-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .library-pane {
    max-height: 520px;
  }

  .preset-identity,
  .notes-board,
  .connection-panel {
    grid-template-columns: 1fr;
  }

  .verify-card {
    justify-items: start;
  }

  .processor-header {
    display: none;
  }

  .processor-row {
    grid-template-columns: 112px 1fr;
  }

  .processor-graph {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .toggle-wrap {
    position: absolute;
    right: 18px;
    margin-top: 10px;
    border-right: 0;
  }

  .processor-row {
    position: relative;
  }

  .mini-graph {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .app-titlebar,
  .title-lockup,
  .headline-row,
  .statusbar {
    align-items: start;
  }

  .app-titlebar,
  .title-lockup,
  .headline-row {
    flex-direction: column;
  }

  .window-tools {
    display: none;
  }

  .pane-title,
  .search-row,
  .mic-library,
  .library-footer,
  .connection-panel {
    padding-left: 12px;
    padding-right: 12px;
  }

  .preset-detail {
    padding-left: 10px;
    padding-right: 10px;
  }

  .processor-row {
    grid-template-columns: 1fr;
  }

  .processor-row > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .processor-row > div:last-child {
    border-bottom: 0;
  }

  .toggle-wrap {
    position: static;
    justify-content: start;
  }

  .field-grid,
  .color-icon-row,
  .mode-grid,
  .library-footer,
  .statusbar {
    grid-template-columns: 1fr;
  }

.statusbar a {
    justify-self: start;
  }
}

.legal-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.14), transparent 28rem),
    linear-gradient(135deg, #f7faf9 0%, #eef2ef 100%);
  color: var(--ink);
}

.legal-shell {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.legal-shell h1 {
  margin: 18px 0 8px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
}

.legal-shell h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.legal-shell p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.legal-shell section {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.legal-date {
  font-weight: 700;
}

.legal-back {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}
