:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --soft-surface: #f2f3f5;
  --line: #dde1e5;
  --text: #2f3438;
  --muted: #767d84;
  --accent: #111111;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Barlow", "DIN Alternate", "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1680px, calc(100% - 22px));
  margin: 0 auto;
  padding: 8px 0 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  padding: 6px 0 10px;
  background: #fff;
}

.app-nav {
  display: flex;
  gap: 12px;
}

.app-nav a {
  color: var(--muted);
  font-size: 0.64rem;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.app-nav a[aria-current="page"] {
  color: var(--text);
}

.topbar-copy {
  display: grid;
  gap: 3px;
}

.topbar h1,
.panel-head h2,
.rule-list h3 {
  margin: 0;
  font-family: "Barlow", "DIN Alternate", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar h1 {
  font-size: clamp(1.2rem, 1.8vw, 1.75rem);
  line-height: 1;
}

.topbar-lede,
.topbar-note,
.status-text,
.legend-row p,
.mini-note,
.insight-list,
.detection-list,
.rule-list p {
  margin: 0;
}

.topbar-lede {
  font-size: 0.82rem;
}

.topbar-note {
  font-size: 0.66rem;
  color: var(--muted);
}

.dashboard {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 308px;
  gap: 18px;
  align-items: start;
}

.control-panel,
.preview-panel,
.score-panel,
.insight-card {
  padding: 14px;
  background: var(--soft-surface);
}

.panel-head,
.subhead-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.panel-head {
  margin-bottom: 12px;
}

.panel-kicker,
.mini-kicker {
  margin: 0;
  font-size: 0.56rem;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-head h2 {
  font-size: 0.92rem;
  line-height: 1;
}

.upload-dropzone {
  display: grid;
  gap: 8px;
  padding: 18px 16px;
  background: #fff;
}

.file-input {
  width: 100%;
}

.upload-copy {
  display: grid;
  gap: 2px;
  font-size: 0.72rem;
}

.upload-copy strong {
  font-size: 0.82rem;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.action-button,
.ghost-button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
}

.action-button {
  background: #111111;
  color: #fff;
}

.action-button:disabled {
  background: #9aa1a8;
  cursor: default;
}

.ghost-button {
  background: #fff;
  color: var(--text);
}

.status-text {
  min-height: 32px;
  margin-top: 10px;
  font-size: 0.68rem;
  color: var(--muted);
}

.score-legend {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: start;
  padding-top: 8px;
  border-top: 1px solid rgba(49, 54, 58, 0.08);
}

.legend-row span {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 0.95;
}

.legend-row p {
  font-size: 0.7rem;
  line-height: 1.4;
}

.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #fff;
  overflow: hidden;
}

.image-canvas,
.overlay-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.image-canvas {
  display: block;
}

.overlay-layer {
  pointer-events: none;
}

.overlay-box {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.4);
}

.overlay-box span {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #111111;
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-focus {
  position: absolute;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  transform: rotate(45deg);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.76rem;
}

.total-score-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: #fff;
}

.total-score-label,
.score-chip-label,
.breakdown-card p,
.palette-chip-code,
.detection-list dt,
.detection-list dd,
.rule-list article,
.mini-note {
  margin: 0;
}

.total-score-label {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.total-score-value {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 4.8rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
  font-weight: 700;
}

.breakdown-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.breakdown-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 12px 14px;
  background: #fff;
}

.breakdown-card strong {
  font-size: 0.74rem;
  line-height: 1;
}

.breakdown-card p {
  font-size: 0.64rem;
  color: var(--muted);
}

.breakdown-card span {
  font-size: 1.56rem;
  line-height: 0.9;
  font-weight: 700;
}

.palette-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  background: #fff;
}

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

.palette-chip {
  display: grid;
  gap: 4px;
}

.palette-chip-color {
  min-height: 48px;
  background: var(--chip-color);
}

.palette-chip-code {
  font-size: 0.56rem;
  line-height: 1.2;
  color: var(--muted);
  text-transform: uppercase;
}

.insight-section {
  margin-top: 18px;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1fr;
  gap: 18px;
}

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

.insight-list {
  display: grid;
  gap: 10px;
  padding-left: 16px;
  font-size: 0.72rem;
  line-height: 1.5;
}

.detection-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-content: start;
}

.detection-list dt {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detection-list dd {
  font-size: 0.72rem;
}

.rule-list {
  display: grid;
  gap: 12px;
}

.rule-list h3 {
  font-size: 0.82rem;
  line-height: 1;
}

.rule-list p {
  margin-top: 4px;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--muted);
}

.alert-list {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.alert-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 6px;
  align-items: start;
  padding: 6px 10px;
  border-left: 2px solid #d97706;
  background: #fffbf0;
  font-size: 0.68rem;
  line-height: 1.4;
}

.alert-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  background: #d97706;
  color: #fff;
  font-size: 0.54rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.suggestion-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  background: var(--soft-surface);
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  vertical-align: middle;
  white-space: nowrap;
}

.action-button:focus-visible,
.ghost-button:focus-visible,
.file-input:focus-visible,
.app-nav a:focus-visible {
  outline: 2px solid #9aa1a8;
  outline-offset: 2px;
}

@media (max-width: 1120px) {
  .dashboard,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 14px, 100%);
  }

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

  .palette-swatches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
