:root {
  color-scheme: dark;

  /* Canon 7: High-Contrast Monochrome Palette */
  --bg: #000000;
  --surface: #0a0a0c;
  --surface-hover: #121216;
  --field: #050507;
  --line: rgba(255, 255, 255, 0.18);
  --line-strong: rgba(255, 255, 255, 0.42);
  --ink: #ffffff;
  --ink-soft: #e4e4e7;
  --muted: #8e8e99;

  /* Canon 8: Strict Semantic RGB Status System
     GREEN = Online / Enabled / Ready / Saved
     BLUE  = Processing / Syncing / Draft
     RED   = Blocked (Blacklist) / Error / Offline / Destructive */
  --led-g: #00e676;
  --led-g-ring: rgba(0, 230, 118, 0.18);
  --led-g-glow: rgba(0, 230, 118, 0.5);

  --led-b: #2979ff;
  --led-b-ring: rgba(41, 121, 255, 0.2);
  --led-b-glow: rgba(41, 121, 255, 0.55);

  --led-r: #ff2d55;
  --led-r-ring: rgba(255, 45, 85, 0.2);
  --led-r-glow: rgba(255, 45, 85, 0.55);
  --led-r-dim: rgba(255, 45, 85, 0.1);

  /* Canon 3: Strictly Two Border Radii Across Entire App */
  --r-card: 10px;
  --r-ctrl: 6px;

  /* Canon 2: 8pt Spacing Rhythm */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;

  --ctrl-h: 44px;
  --ctrl-sm: 34px;
  --width: 800px;
  --edge: clamp(16px, 4vw, 24px);

  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font: 14px/1.5 var(--font-sans);
}

/* Canon 4: Zero Horizontal Scrollbar Jump */
html {
  scrollbar-gutter: stable;
  background: var(--bg);
}

* { box-sizing: border-box; }

/* Canon 1: Prevent Accidental Text Selection on UI Chrome */
body {
  margin: 0;
  min-height: 100dvh;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
  background-color: var(--bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

p, small, code, pre, .hint, .selectable {
  overflow-wrap: anywhere;
}

input, textarea, code, pre, .selectable {
  user-select: text;
  -webkit-user-select: text;
}

::selection {
  background: #ffffff;
  color: #000000;
}

code, pre, textarea, input[type="number"], input[type="datetime-local"], input[type="date"] {
  font-family: var(--font-mono);
}

/* Canon 3: Complete Removal of Native OS Form Styling */
button, select, input, textarea {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctrl);
  transition: border-color .12s ease, background-color .12s ease, color .12s ease, box-shadow .12s ease;
}

button, select, summary, label:has(input[type=checkbox]) {
  cursor: pointer;
}

/* Hide ugly native number steppers & search cancel buttons */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }
input[type="search"] { -webkit-appearance: none; appearance: none; }

/* Custom Unified Select (No macOS Aqua double-arrows or shrink) */
select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--ctrl-h);
  padding: 0 38px 0 14px;
  background-color: var(--field);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  border-color: var(--line-strong);
  color: #ffffff;
  font-weight: 500;
}

/* Custom Unified Inputs & Textareas */
input:not([type=checkbox]):not([type=range]):not([type=hidden]):not([type=file]),
textarea {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--field);
  border-color: var(--line-strong);
  color: #ffffff;
}

input:not([type=checkbox]):not([type=range]):not([type=hidden]):not([type=file]) {
  height: var(--ctrl-h);
  padding: 0 14px;
}

input::placeholder, textarea::placeholder {
  color: #5c5c66;
}

textarea {
  resize: vertical;
  padding: 12px 14px;
  font: 13px/1.55 var(--font-mono);
  min-height: 132px;
}

input[type=file] {
  width: 100%;
  padding: 9px 12px;
  background: var(--field);
  border-color: var(--line);
  font-size: 13px;
}

/* Custom Architectural Checkbox (18x18 Monochrome) */
input[type=checkbox] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 4px;
  background-color: var(--field);
  display: inline-grid;
  place-content: center;
}

input[type=checkbox]:checked {
  background-color: #ffffff;
  border-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

input[type=range] {
  width: 100%;
  height: 32px;
  accent-color: #ffffff;
}

/* Unified Buttons: Zero Transform Jump, Strict 44px Height */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ctrl-h);
  padding: 0 16px;
  background: #101014;
  border-color: var(--line-strong);
  color: #ffffff;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
  text-align: center;
}

button:enabled:hover, select:enabled:hover {
  border-color: #ffffff;
  background-color: #18181e;
}

button:disabled, select:disabled, input:disabled {
  opacity: 0.36;
  cursor: default;
}

input:not([type=checkbox]):not([type=range]):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #ffffff;
  background-color: #0b0b0f;
  box-shadow: 0 0 0 2px var(--led-b-ring);
}

:focus-visible {
  outline: 2px solid var(--led-b);
  outline-offset: 2px;
}

h1:focus { outline: none; }

/* Primary CTA: Pure White Inversion (#FFFFFF on #000000) */
button.primary {
  color: #000000;
  border-color: #ffffff;
  background: #ffffff;
  font-weight: 600;
}

button.primary:enabled:hover {
  background: #e8e8ec;
  border-color: #ffffff;
}

button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

button.ghost:enabled:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #ffffff;
  color: #ffffff;
}

button.danger {
  color: #ff6b86;
  background: var(--led-r-dim);
  border-color: rgba(255, 45, 85, 0.42);
}

button.danger:enabled:hover {
  color: #ffffff;
  background: rgba(255, 45, 85, 0.24);
  border-color: var(--led-r);
}

button.btn-sm {
  min-height: var(--ctrl-sm);
  padding: 0 12px;
  font-size: 12.5px;
}

/* Status Pulse Animations */
@keyframes pulseGreen {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px var(--led-g-ring), 0 0 8px var(--led-g-glow); }
  50% { opacity: .55; box-shadow: 0 0 0 1px var(--led-g-ring), 0 0 2px var(--led-g-glow); }
}

@keyframes pulseBlue {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px var(--led-b-ring), 0 0 8px var(--led-b-glow); }
  50% { opacity: .48; box-shadow: 0 0 0 1px var(--led-b-ring), 0 0 2px var(--led-b-glow); }
}

@keyframes pulseRed {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px var(--led-r-ring), 0 0 8px var(--led-r-glow); }
  50% { opacity: .5; box-shadow: 0 0 0 1px var(--led-r-ring), 0 0 2px var(--led-r-glow); }
}

/* Optical Status Indicators */
.led {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: rgba(255, 255, 255, 0.28);
}

.led.mono {
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.65);
}

.led.g { background: var(--led-g); box-shadow: 0 0 0 3px var(--led-g-ring), 0 0 8px var(--led-g-glow); }
.led.b { background: var(--led-b); box-shadow: 0 0 0 3px var(--led-b-ring), 0 0 8px var(--led-b-glow); }
.led.r { background: var(--led-r); box-shadow: 0 0 0 3px var(--led-r-ring), 0 0 8px var(--led-r-glow); }
.led.pulse-g { animation: pulseGreen 2.2s infinite ease-in-out; }
.led.pulse-b { animation: pulseBlue 1.5s infinite ease-in-out; }
.led.pulse-r { animation: pulseRed 1.7s infinite ease-in-out; }

/* Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  height: 56px;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 0 max(var(--edge), calc((100% - var(--width)) / 2 + var(--edge)));
}

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

.brand-name {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  color: #ffffff;
  white-space: nowrap;
  flex: none;
}

.mode-tag {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font: 600 10px/1.2 var(--font-mono);
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  flex: none;
}

.mode-dock {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  width: min(420px, calc(100vw - 20px));
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(10, 10, 12, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.82);
}

body:has(main.editing) .mode-dock {
  display: none;
}

.mode-dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 46px;
  height: 46px;
  padding: 4px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color .14s ease, color .14s ease;
}

.mode-dock-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.mode-dock-item:enabled:hover,
a.mode-dock-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.mode-dock-item.active,
.mode-dock-item.active:enabled:hover {
  background: #ffffff;
  color: #000000;
}

.mark {
  flex: none;
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: var(--r-ctrl);
  background: #ffffff;
  position: relative;
}

.mark::before, .mark::after {
  content: "";
  position: absolute;
  width: 3px;
  background: #000000;
  transform: skew(-14deg);
}
.mark::before { top: 9px; bottom: 5px; left: 6px; }
.mark::after { top: 5px; bottom: 5px; left: 13px; }

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--ctrl-sm);
  padding: 0 10px;
  border-radius: var(--r-ctrl);
  font: 600 11.5px/1 var(--font-mono);
  color: #ffffff;
  background: var(--surface);
  border: 1px solid var(--line);
}

.live-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--led-g);
  box-shadow: 0 0 0 3px var(--led-g-ring);
  animation: pulseGreen 2.2s infinite;
}

.live-pill.syncing { border-color: rgba(41, 121, 255, 0.48); }
.live-pill.syncing::before {
  background: var(--led-b);
  box-shadow: 0 0 0 3px var(--led-b-ring);
  animation: pulseBlue 1.5s infinite;
}

.live-pill.offline { border-color: rgba(255, 45, 85, 0.5); }
.live-pill.offline::before {
  background: var(--led-r);
  box-shadow: 0 0 0 3px var(--led-r-ring);
  animation: pulseRed 1.7s infinite;
}

#language {
  width: auto;
  height: var(--ctrl-sm);
  min-height: var(--ctrl-sm);
  padding: 0 30px 0 10px;
  background-position: right 8px center;
  background-size: 14px 14px;
  font: 600 12px/1 var(--font-mono);
  background-color: var(--surface);
  border-color: var(--line);
}

/* Canon 2: Main Layout Enforces Exact 16px Vertical Rhythm Everywhere */
main {
  display: grid;
  gap: var(--s-4);
  align-content: start;
  width: min(100%, var(--width));
  margin-inline: auto;
  padding: 20px var(--edge) calc(32px + env(safe-area-inset-bottom));
}

main > * {
  min-width: 0;
  margin: 0;
}

main.editing {
  padding-bottom: calc(108px + env(safe-area-inset-bottom));
}

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

h1 {
  font-size: clamp(22px, 4.8vw, 28px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.03em;
  color: #ffffff;
}

h2 {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.section-title h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-title h2::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 1px;
  background: #ffffff;
  flex: none;
}

h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

/* Page Header Block (Back + Title + Context cleanly grouped) */
.page-header {
  display: grid;
  gap: var(--s-2);
  justify-items: start;
}

.intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
  width: 100%;
}

.back {
  min-height: var(--ctrl-sm);
  padding: 0 12px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.back:enabled:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.edit-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 12.5px/1.4 var(--font-mono);
  color: var(--muted);
}

.edit-context.draft-banner {
  padding: 8px 12px;
  border-radius: var(--r-ctrl);
  background: rgba(41, 121, 255, 0.08);
  border: 1px solid rgba(41, 121, 255, 0.4);
  color: #ffffff;
}

.edit-context.draft-banner::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--led-b);
  box-shadow: 0 0 8px var(--led-b-glow);
}

/* Canon 2: Panels Are Strict 16px Vertical Stacks — Elements Can Never Collide */
.panel,
main > section {
  display: grid;
  gap: var(--s-4);
  align-content: start;
  padding: var(--s-5);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-card);
}

/* Direct standalone buttons inside forms align cleanly to 100% width */
.panel > button,
details .inner > button,
main > section > button {
  width: 100%;
}

details.panel {
  display: block;
  padding: 0;
  overflow: hidden;
}

details.panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 50px;
  padding: 13px var(--s-5);
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  list-style: none;
}

details.panel > summary::-webkit-details-marker { display: none; }

details.panel > summary::after {
  content: "+";
  font: 500 18px/1 var(--font-mono);
  color: var(--muted);
  flex: none;
}

details.panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

details.panel[open] > summary::after {
  content: "−";
  color: #ffffff;
}

details .inner {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-5);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
}

/* Telemetry Bar */
.telemetry-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.telemetry-kpi {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
}

.telemetry-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.telemetry-kpi span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.telemetry-kpi strong {
  font: 700 16px/1.2 var(--font-mono);
  color: #ffffff;
}

/* Active Profile Card: Crisp Pure White Frame */
.profile-card {
  background: var(--surface);
  border: 1px solid #ffffff;
  border-radius: var(--r-card);
  overflow: hidden;
}

.profile-head {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-5);
}

.profile-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.profileStatus {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-ctrl);
  background: #ffffff;
  color: #000000;
  font: 700 11px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profileStatus::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: #000000;
}

.profile-name {
  font-size: clamp(20px, 4.2vw, 24px);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #ffffff;
}

.profile-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 2px;
}

.profile-manage {
  border-top: 1px solid var(--line);
  background: #060608;
}

.profile-manage > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 var(--s-5);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  list-style: none;
}

.profile-manage > summary::-webkit-details-marker { display: none; }
.profile-manage > summary::after {
  content: "▾";
  font-family: var(--font-mono);
  color: var(--muted);
}
.profile-manage[open] > summary { border-bottom: 1px solid var(--line); }
.profile-manage[open] > summary::after { content: "▴"; color: #ffffff; }

.profile-controls {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5) var(--s-5);
}

.profile-controls > button { width: 100%; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.profile-controls .actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: var(--r-ctrl);
  font: 600 11.5px/1.2 var(--font-mono);
  background: #111116;
  border: 1px solid var(--line);
  color: #ffffff;
}

.chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: #ffffff;
  flex: none;
}

.chip.muted-chip {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.12);
}
.chip.muted-chip::before { background: #52525b; }

.chip.emerald { border-color: rgba(0, 230, 118, 0.42); }
.chip.emerald::before {
  border-radius: 50%;
  background: var(--led-g);
  box-shadow: 0 0 6px var(--led-g-glow);
}

.chip.sky { border-color: rgba(41, 121, 255, 0.45); }
.chip.sky::before {
  border-radius: 50%;
  background: var(--led-b);
  box-shadow: 0 0 6px var(--led-b-glow);
}

.chip.crimson { border-color: rgba(255, 45, 85, 0.48); }
.chip.crimson::before {
  border-radius: 50%;
  background: var(--led-r);
  box-shadow: 0 0 6px var(--led-r-glow);
}

.chip button.chip-x {
  min-height: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #1b1b22;
  color: #ffffff;
  font-size: 12px;
}

.chip button.chip-x:enabled:hover {
  border-color: var(--led-r);
  background: var(--led-r);
}

/* Section Navigation Grid */
.section-menu {
  display: grid;
  gap: 10px;
}

.section-link {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 72px;
  padding: 14px 16px;
  align-items: center;
  grid-template-columns: 40px minmax(0, 1fr) 20px;
  gap: 14px;
  text-align: left;
  justify-content: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.section-link:enabled:hover {
  background: var(--surface-hover);
  border-color: #ffffff;
}

.section-copy { display: grid; gap: 3px; }
.section-copy strong {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.section-copy small, .hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 400;
}

.section-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-ctrl);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: #ffffff;
  font-size: 18px;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}

.section-link:enabled:hover .section-icon {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
}

.section-link[data-led] .section-icon::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #000000;
}

.section-link[data-led="g"] .section-icon::after {
  background: var(--led-g);
  box-shadow: 0 0 7px var(--led-g-glow);
}

.section-link[data-led="b"] .section-icon::after {
  background: var(--led-b);
  box-shadow: 0 0 7px var(--led-b-glow);
  animation: pulseBlue 1.5s infinite;
}

.section-link[data-led="r"] .section-icon::after {
  background: var(--led-r);
  box-shadow: 0 0 7px var(--led-r-glow);
}

.section-icon svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.forward {
  font: 500 19px/1 var(--font-mono);
  color: var(--muted);
  text-align: right;
}

.section-link:enabled:hover .forward { color: #ffffff; }

/* Manual Presets */
.preset-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-tabs button {
  min-height: var(--ctrl-sm);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--field);
  border-color: var(--line);
  color: var(--ink-soft);
}

.preset-tabs button[aria-pressed=true] {
  color: #000000;
  background: #ffffff;
  border-color: #ffffff;
}

.manual-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(148px, 100%), 1fr));
  gap: 6px;
  max-height: 184px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.manual-presets::-webkit-scrollbar {
  width: 5px;
}

.manual-presets::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
}

.manual-presets button {
  justify-content: flex-start;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--field);
  border-color: var(--line);
  color: #ffffff;
}

.manual-presets button::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
}

.manual-presets button[aria-pressed=true] {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.manual-presets button[aria-pressed=true]::before {
  background: #000000;
  border-color: #000000;
}

.manual-presets button[data-badge]::after {
  content: attr(data-badge);
  margin-left: auto;
  flex: none;
  padding: 3px 6px;
  border-radius: 4px;
  font: 700 9.5px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

.manual-presets button[data-preset-kind="custom"][data-badge]::after {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.34);
}

.manual-presets button[aria-pressed=true][data-badge]::after {
  color: #000000;
  border-color: rgba(0, 0, 0, 0.28);
  background: rgba(0, 0, 0, 0.08);
}

.preset-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding-top: 2px;
}

.icon-btn {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  height: 40px;
  padding: 0;
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.manual-bounds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.manual-bounds > div {
  padding: 12px 14px;
  border-radius: var(--r-ctrl);
  background: var(--field);
  border: 1px solid var(--line);
  border-top: 2px solid #ffffff;
}

.manual-bounds dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.manual-bounds dd {
  margin-top: 4px;
  font: 700 16px/1.2 var(--font-mono);
  color: #ffffff;
}

.preset-builder {
  border-top: 1px solid var(--line);
  padding-top: var(--s-3);
}

.preset-builder > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  list-style: none;
}

.preset-builder > summary::-webkit-details-marker { display: none; }
.preset-builder > summary::after { content: "+"; font-family: var(--font-mono); color: var(--muted); }
.preset-builder[open] > summary::after { content: "−"; color: #ffffff; }

.preset-builder-body {
  display: grid;
  gap: var(--s-3);
  padding-top: var(--s-3);
}

/* Forms & Controls (Canon 2: Strict 8px Label-to-Field Gap) */
.stack {
  display: grid;
  align-content: start;
  gap: var(--s-2);
  min-width: 0;
}

.field {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.3;
}

.check {
  display: flex;
  gap: 10px;
  min-height: 36px;
  align-items: center;
  font-weight: 500;
  font-size: 13.5px;
  color: #ffffff;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  align-items: end;
}

/* Canon 6: Clean Static Profile Bar Instead of Fake Read-Only Input Cell */
.profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 10px 14px;
  border-radius: var(--r-ctrl);
  background: var(--field);
  border: 1px solid var(--line);
}

.profile-bar-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.profile-bar-info small {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.profile-bar-info strong {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.pills {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.pills button {
  min-height: 40px;
  padding: 0 8px;
  font: 600 13px/1 var(--font-mono);
  background: var(--field);
  border-color: var(--line);
}

.pills button[aria-pressed=true] {
  border-color: #ffffff;
  background: #ffffff;
  color: #000000;
}

/* Canon 5: Clean Compact Metric Filter Rows (No 170 Repeated Min/Max Headings) */
.parameter-group .inner {
  gap: var(--s-3);
}

.parameter-group .row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(96px, 1fr));
  gap: 10px;
  align-items: center;
  padding-top: var(--s-3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.parameter-group .row:first-child {
  padding-top: 0;
  border-top: none;
}

.parameter-group .row > span:first-child {
  font-size: 13.5px;
  font-weight: 500;
  color: #ffffff;
  line-height: 1.35;
}

.parameter-group .row input {
  height: 40px;
  padding: 0 11px;
  font-size: 13px;
}

.parameter-group .date-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.parameter-group .date-row > span:first-child {
  grid-column: 1 / -1;
}

/* Excel Columns Checklist */
.col-list {
  display: grid;
  gap: 0;
}

.colrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.colrow:first-child { border-top: none; padding-top: 0; }

.colrow .actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.colrow button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font: 600 14px/1 var(--font-mono);
}

/* Form Action Groups */
.form-actions {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

/* Compact Collapsible Technical Footnotes */
.data-status,
.coverage-status {
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  overflow: hidden;
}

.data-status > summary,
.coverage-status > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 42px;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  list-style: none;
}

.data-status > summary::-webkit-details-marker,
.coverage-status > summary::-webkit-details-marker { display: none; }

.data-status > summary::after,
.coverage-status > summary::after {
  content: "▾";
  font-family: var(--font-mono);
  color: var(--muted);
}

.data-status p,
.coverage-status p {
  padding: 0 16px 12px;
}

/* Provider Rules, Market Bands & Templates */
.rule-group {
  display: grid;
  gap: 10px;
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

.rule-group > button { justify-self: start; }

.rule {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctrl);
  background: var(--field);
}

.rule-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bounds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) 40px;
  gap: 8px;
  align-items: end;
}

.band button {
  width: 40px;
  min-height: var(--ctrl-h);
  padding: 0;
  font-size: 17px;
}

.template-list { display: grid; gap: 10px; }

.template-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-ctrl);
  background: var(--field);
  border: 1px solid var(--line);
}

.template-card > button {
  justify-self: start;
  min-height: var(--ctrl-sm);
  font-size: 12.5px;
}

/* Behavioral Groups & Transfer Graph */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  gap: 8px;
}

.group-tile {
  justify-content: space-between;
  text-align: left;
  background: var(--field);
  border-color: var(--line);
}

.group-tile::after {
  content: "→";
  font-family: var(--font-mono);
  color: var(--muted);
}

.group-tile:enabled:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.group-tile:enabled:hover::after { color: #000000; }

.group-wallet {
  display: grid;
  gap: 4px;
  width: 100%;
  justify-content: stretch;
  text-align: left;
  padding: 12px 14px;
}

.funding-graph {
  padding: 10px;
  border-radius: var(--r-ctrl);
  background: var(--field);
  border: 1px solid var(--line);
}
.funding-graph svg { width: 100%; height: auto; display: block; }

/* Notices */
.notice {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  background: var(--led-r-dim);
  border: 1px solid rgba(255, 45, 85, 0.48);
  color: #ffd6de;
}

/* Export Job Cards: LEDs ONLY on active/fault states; Monochrome ✓/× on finished states */
.export-job {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--line);
  background: var(--field);
}

.export-job.status-done { border-left: 2px solid #ffffff; }
.export-job.status-cancelled { border-left: 2px solid rgba(255, 255, 255, 0.28); }
.export-job.status-running,
.export-job.status-acquiring,
.export-job.status-queued { border-left: 3px solid var(--led-b); }
.export-job.status-failed { border-left: 3px solid var(--led-r); }

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--r-ctrl);
  font: 600 11px/1 var(--font-mono);
  text-transform: uppercase;
  background: #111116;
  border: 1px solid var(--line);
  color: #ffffff;
}

/* Completed = Crisp Monochrome Checkmark (No Lamp) */
.status-done .job-badge {
  border-color: rgba(255, 255, 255, 0.34);
  color: #ffffff;
}
.status-done .job-badge::before {
  content: "✓";
  font: 700 11px/1 var(--font-mono);
  color: #ffffff;
}

/* Cancelled = Muted Monochrome Cross (No Fault Lamp) */
.status-cancelled .job-badge {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--muted);
}
.status-cancelled .job-badge::before {
  content: "×";
  font: 700 12px/1 var(--font-mono);
  color: var(--muted);
}

/* Active Computation = Pulsing Blue Lamp */
.status-running .job-badge,
.status-acquiring .job-badge,
.status-queued .job-badge { border-color: rgba(41, 121, 255, 0.45); }

.status-running .job-badge::before,
.status-acquiring .job-badge::before,
.status-queued .job-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--led-b);
  box-shadow: 0 0 6px var(--led-b-glow);
  animation: pulseBlue 1.4s infinite;
}

/* Fault = Red Lamp */
.status-failed .job-badge { border-color: rgba(255, 45, 85, 0.48); }
.status-failed .job-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--led-r);
  box-shadow: 0 0 6px var(--led-r-glow);
}

.export-job small {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

/* Guide Links & Sticky Footer */
.guide-links-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.guide-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-underline-offset: 4px;
  font-size: 13px;
  font-weight: 500;
}
.guide-link:hover { color: #ffffff; text-decoration-color: #ffffff; }

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 15;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  max-width: var(--width);
  margin: auto;
  padding: 10px var(--edge);
}

#save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 600 12.5px/1.3 var(--font-mono);
  color: var(--ink-soft);
}

/* Saved (at rest) = Quiet Monochrome Checkmark, NO Lamp */
#save-status::before {
  content: "✓";
  font: 700 12px/1 var(--font-mono);
  color: var(--muted);
}

/* Unsaved Edits = Pulsing Blue Lamp */
#save-status[data-led="dirty"] {
  color: #ffffff;
}
#save-status[data-led="dirty"]::before {
  content: "";
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: var(--led-b);
  box-shadow: 0 0 0 3px var(--led-b-ring);
  animation: pulseBlue 1.5s infinite;
}

/* Version Conflict = Pulsing Red Fault Lamp */
#save-status[data-led="conflict"] {
  color: #ffd6de;
}
#save-status[data-led="conflict"]::before {
  content: "";
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: var(--led-r);
  box-shadow: 0 0 0 3px var(--led-r-ring);
  animation: pulseRed 1.5s infinite;
}

.footer .primary { min-width: 164px; }

#feedback.show {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 11px 16px;
  background: #0b0b0f;
  color: #ffffff;
  border: 1px solid #ffffff;
  border-radius: var(--r-ctrl);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.9);
  font-size: 13px;
  font-weight: 600;
  z-index: 30;
}

/* Completed Toast = Crisp White Checkmark, Error Toast = Red Fault Lamp */
#feedback.show:not(.error)::before {
  content: "✓";
  font: 700 12.5px/1 var(--font-mono);
  color: #ffffff;
  flex: none;
}

#feedback.error {
  border-color: var(--led-r);
  color: #ffe4e8;
}
#feedback.error::before {
  content: "";
  width: 6.5px;
  height: 6.5px;
  flex: none;
  border-radius: 50%;
  background: var(--led-r);
  box-shadow: 0 0 6px var(--led-r-glow);
}

dialog {
  background: #0a0a0d;
  color: #ffffff;
  border: 1px solid #ffffff;
  border-radius: var(--r-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.95);
  width: min(400px, 92vw);
  padding: var(--s-5);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: var(--s-3); }
dialog p { color: var(--muted); font-size: 13.5px; }
dialog .actions { justify-content: flex-end; padding-top: 4px; }
dialog label { display: grid; gap: 6px; }
dialog label span { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }

/* Main Hub Module Grid */
.hub-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.hub-card {
  display: grid;
  gap: 12px;
  width: 100%;
  min-height: 104px;
  padding: 16px 18px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--surface);
  color: #ffffff;
  text-align: left;
  justify-content: stretch;
  align-content: space-between;
}

.hub-card:enabled:hover {
  border-color: #ffffff;
  background: var(--surface-hover);
}

.hub-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.hub-badge {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--muted);
  font: 600 10.5px/1.2 var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}

.hub-card-top .forward {
  margin-left: auto;
  font: 500 20px/1 var(--font-mono);
  color: var(--muted);
}

.hub-card:enabled:hover .forward {
  color: #ffffff;
}

.hub-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.hub-card-body strong {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.hub-card-body small {
  font-size: 12.5px;
  font-weight: 450;
  line-height: 1.45;
  color: var(--muted);
}

@media (min-width: 680px) {
  .section-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .telemetry-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .parameter-group .row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 6px;
  }
  .parameter-group .row > span:first-child { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  main { padding-top: 16px; }
  .panel, details .inner, .profile-head { padding: 16px; }
  details.panel > summary, .profile-manage > summary { padding-inline: 16px; }
  .profile-controls { padding: 14px 16px 16px; }
  .control-grid, .profile-quick-actions, .manual-bounds {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
}

.web-login-bots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease;
}

.btn-link:hover {
  border-color: #ffffff;
  background: var(--surface-hover);
}

.btn-link.primary-link {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.btn-link.primary-link:hover {
  background: #e6e6e6;
}

.web-login-error:empty {
  display: none;
}

.web-login-error {
  color: #ff4d6d;
}
