:root {
  --bg: #f3f2f2;
  --surface: #eae9e9;
  --text: #201e1d;
  --muted: color-mix(in srgb, #201e1d 55%, transparent);
  --divider: color-mix(in srgb, #201e1d 40%, transparent);
  --accent: #ec3013;
  --font-heading: "Archivo", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, sans-serif;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2d2b2b;
    --surface: #444141;
    --text: #f8f4f4;
    --muted: color-mix(in srgb, #f8f4f4 58%, transparent);
    --divider: color-mix(in srgb, #f8f4f4 35%, transparent);
    --accent: #ff563c;
  }
}

:root[data-theme="dark"] {
  --bg: #2d2b2b;
  --surface: #444141;
  --text: #f8f4f4;
  --muted: color-mix(in srgb, #f8f4f4 58%, transparent);
  --divider: color-mix(in srgb, #f8f4f4 35%, transparent);
  --accent: #ff563c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}

:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* — top bar — */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  border-bottom: 2px solid var(--divider);
}
.wordmark {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
}
.tagline {
  font-size: 13px;
  color: var(--muted);
}
.btn {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: 0;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
}
.btn-secondary {
  border-color: var(--divider);
  margin-left: auto;
}
.btn-secondary:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

/* — two-column layout — */
.app {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  align-content: start;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) 0;
  box-sizing: border-box;
}
.col-left {
  border-right: 2px solid var(--divider);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.group-rule {
  border-top: 2px solid var(--divider);
  padding-top: var(--space-4);
}
.group-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

/* — fields — */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-4);
}
.field:last-child {
  margin-bottom: 0;
}
.field-row {
  display: flex;
  gap: var(--space-4);
}
.field-row[hidden] {
  display: none;
}
.field-row .field {
  flex: 1;
  margin-bottom: 0;
}
.checkbox-field label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
#multi-screen-fields {
  margin-bottom: var(--space-4);
}
.screen-row {
  align-items: flex-end;
  margin-bottom: var(--space-3);
}
.remove-screen-btn {
  flex: none;
  height: 36px;
  padding: 0 var(--space-3);
}
#add-screen-btn {
  width: 100%;
}

/* — per-screen result blocks (multi-screen mode) — */
#screen-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0;
}
.screen-block {
  padding: var(--space-4);
  border-bottom: 2px solid var(--divider);
  border-right: 2px solid var(--divider);
  min-width: 0;
}
.screen-block-title {
  font-size: 10px;
}
.screen-block-stats {
  font-size: 11px;
  color: var(--muted);
  margin: var(--space-1) 0 var(--space-2);
}
.screen-block-map {
  max-width: 240px;
  margin: 0 auto;
}
.screen-block-power {
  max-width: 240px;
  margin: var(--space-2) auto 0;
}
.screen-block-power {
  aspect-ratio: auto !important;
  height: 18px;
}
.screen-block-power .connector-mark {
  display: none;
}
.screen-block-power-stats {
  font-size: 10px;
  color: var(--muted);
  margin-top: var(--space-1);
}
.screen-block-legend {
  font-size: 10px;
  margin-top: var(--space-2);
}
label {
  font-size: 12px;
  color: var(--muted);
}
.input {
  font: inherit;
  font-size: 14px;
  min-height: 36px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--divider);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
}
.input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* — tables — */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: var(--space-2) 0;
  border-bottom: 2px solid var(--divider);
}
.table td {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--divider);
}
.table td.num,
.table th.num {
  text-align: right;
}
.table tr.no-rule td {
  border-bottom: 0;
}
.spec-table td {
  padding: 6px 0;
}

/* — headline band — */
.headline-band {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 2px solid var(--divider);
}
.headline-tile {
  padding: var(--space-6);
  border-right: 2px solid var(--divider);
}
.headline-tile:last-child {
  border-right: 0;
}
.headline-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-2);
}
.headline-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.headline-sub {
  font-size: 13px;
  margin-top: var(--space-2);
}

/* — cables table + panel map — */
.detail-row {
  display: grid;
  grid-template-columns: 1fr 380px;
}
.detail-row + .detail-row {
  border-top: 2px solid var(--divider);
}
.detail-row.full-width {
  grid-template-columns: 1fr;
}
.detail-row.full-width .cables-col {
  border-right: 0;
}
.cables-col {
  padding: var(--space-6);
  border-right: 2px solid var(--divider);
}
.map-col {
  padding: var(--space-6);
}
.power-strip {
  aspect-ratio: auto !important;
  height: 40px;
}
.power-cell {
  position: relative;
}
.connector-mark {
  position: absolute;
  top: 50%;
  right: -8px;
  transform: translate(50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--text);
  color: var(--text);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.warning {
  margin-top: var(--space-3);
  color: var(--accent);
  font-size: 12px;
}
.illustration {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 2px solid var(--text);
  cursor: pointer;
}
.illustration:hover,
.illustration:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.panel-cell {
  border-radius: 0;
}
.map-hint {
  margin-top: var(--space-2);
  font-size: 11px;
  color: var(--muted);
}

/* — map modal — */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: color-mix(in srgb, #000 60%, transparent);
}
.modal[hidden] {
  display: none;
}
.modal-content {
  background: var(--bg);
  border: 2px solid var(--text);
  padding: var(--space-6);
  width: min(90vw, 800px);
  max-height: 90vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.modal-actions {
  display: flex;
  gap: var(--space-3);
}
.illustration-large {
  cursor: default;
}
.illustration-large:hover,
.illustration-large:focus-visible {
  outline: none;
}
.power-strip-large {
  cursor: default;
  height: 70px;
}
.power-strip-large:hover,
.power-strip-large:focus-visible {
  outline: none;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
  font-size: 11px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
  flex: none;
}

.hint {
  padding: var(--space-6);
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .col-left {
    border-right: 0;
    border-bottom: 2px solid var(--divider);
  }
  .headline-band {
    grid-template-columns: 1fr;
  }
  .headline-tile {
    border-right: 0;
    border-bottom: 2px solid var(--divider);
  }
  .headline-tile:last-child {
    border-bottom: 0;
  }
  .detail-row {
    grid-template-columns: 1fr;
  }
  .cables-col {
    border-right: 0;
    border-bottom: 2px solid var(--divider);
  }
}

@media (max-width: 480px) {
  .field-row {
    flex-direction: column;
  }
}
