:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #111827;
  --muted: #687386;
  --line: #dfe4ec;
  --surface: rgba(255, 255, 255, 0.94);
  --soft: #f3f5f8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, rgba(27, 142, 45, 0.13), transparent 28rem),
    radial-gradient(circle at 95% 10%, rgba(25, 90, 210, 0.11), transparent 30rem),
    #f7f8fa;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

.lab-header,
.lab-footer {
  width: min(1180px, 100%);
  margin-inline: auto;
  padding-left: max(18px, var(--safe-left));
  padding-right: max(18px, var(--safe-right));
}

.lab-header {
  min-height: 70px;
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.lab-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 800;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  font-family: "Space Mono", monospace;
}
.lab-nav { display: flex; gap: 20px; }
.lab-nav a { color: var(--muted); text-decoration: none; font-size: 0.88rem; font-weight: 700; }
.lab-nav a:hover { color: var(--ink); }

.lab-main {
  width: min(1180px, 100%);
  margin-inline: auto;
  padding: 42px max(18px, var(--safe-right)) 80px max(18px, var(--safe-left));
}
.intro-section { max-width: 750px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 9px; color: #526078; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 13px; font-size: clamp(2.7rem, 7vw, 5.8rem); line-height: 0.96; letter-spacing: -0.065em; }
.intro-section > p:last-child { max-width: 690px; margin-bottom: 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.17rem); line-height: 1.7; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(380px, 1.08fr);
  gap: 22px;
  align-items: stretch;
}
.control-panel,
.preview-panel,
.results-section,
.correction-section,
.code-section {
  border: 1px solid rgba(17, 24, 39, 0.09);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(37, 47, 68, 0.09);
}
.control-panel { padding: clamp(20px, 4vw, 32px); }
.color-controls { display: grid; grid-template-columns: 1fr 48px 1fr; gap: 12px; align-items: center; }
.color-control { min-width: 0; }
.control-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.control-heading label { font-size: 0.76rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.control-heading input[type="color"] { width: 31px; height: 31px; border: 0; padding: 0; background: none; cursor: pointer; }
.control-heading input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.control-heading input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,.14); border-radius: 50%; }
.hex-field { display: flex; align-items: center; min-height: 58px; padding: 0 15px; border: 1px solid var(--line); border-radius: 15px; background: white; font-family: "Space Mono", monospace; font-size: clamp(1rem, 3vw, 1.25rem); font-weight: 700; }
.hex-field span { opacity: 0.42; }
.hex-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; text-transform: uppercase; }
.swap-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; font-size: 1.3rem; }
.swap-button:hover { transform: rotate(180deg); transition: transform .22s ease; }
.toolbar, .suggestion-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.toolbar { margin-top: 23px; }
.primary-button, .secondary-button {
  min-height: 44px;
  border-radius: 12px;
  padding: 0 16px;
  border: 1px solid var(--line);
  font-weight: 800;
  cursor: pointer;
}
.primary-button { background: var(--ink); border-color: var(--ink); color: white; }
.secondary-button { background: white; }
.primary-button:hover, .secondary-button:hover, .swap-button:hover { box-shadow: 0 8px 24px rgba(17,24,39,.1); }
.status-message { min-height: 19px; margin-top: 12px; color: var(--muted); font-size: 0.78rem; }

.preview-panel { min-height: 410px; overflow: hidden; transition: background-color .18s ease, color .18s ease; }
.preview-topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid rgba(127,127,127,.25); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; }
.preview-topline code { font-family: "Space Mono", monospace; letter-spacing: 0; }
.preview-content { max-width: 570px; padding: clamp(34px, 7vw, 66px); }
.preview-kicker { margin-bottom: 11px; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; opacity: .72; }
.preview-content h2 { margin-bottom: 16px; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.02; letter-spacing: -0.055em; }
.preview-content > p:not(.preview-kicker) { max-width: 520px; line-height: 1.68; opacity: .84; }
.preview-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; margin-top: 26px; }
.preview-actions button { min-height: 44px; padding: 0 18px; border: 2px solid currentColor; border-radius: 12px; background: currentColor; cursor: pointer; font-weight: 800; }
.preview-actions a { font-weight: 800; text-underline-offset: 4px; }
.preview-small { margin-top: 28px; font-size: .75rem; opacity: .67; }

.results-section, .correction-section, .code-section { margin-top: 22px; padding: clamp(22px, 5vw, 38px); }
.results-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.results-heading h2, .section-copy h2 { margin-bottom: 0; font-size: clamp(1.7rem, 4vw, 2.65rem); letter-spacing: -0.045em; }
.ratio-block { text-align: right; }
.ratio-block strong { display: block; font-family: "Space Mono", monospace; font-size: clamp(2rem, 6vw, 4rem); line-height: 1; }
.ratio-block span { display: inline-block; margin-top: 8px; padding: 6px 10px; border-radius: 999px; background: var(--soft); font-size: 0.73rem; font-weight: 800; }
.standards-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 27px; }
.standard-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.standard-name { display: block; min-height: 35px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.standard-card strong { display: block; margin: 7px 0 4px; font-size: 1.05rem; }
.standard-card strong.pass { color: #14752a; }
.standard-card strong.fail { color: #b42318; }
.standard-card small { color: var(--muted); font-size: .67rem; }

.correction-section { display: grid; grid-template-columns: minmax(250px, .75fr) minmax(0, 1.55fr); gap: 24px; }
.section-copy > p:last-child { margin: 15px 0 0; color: var(--muted); line-height: 1.65; }
.target-control { grid-column: 1 / -1; display: inline-flex; width: fit-content; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.target-button { min-height: 38px; border: 0; border-radius: 9px; padding: 0 14px; background: transparent; cursor: pointer; font-size: .78rem; font-weight: 800; }
.target-button.active { background: white; box-shadow: 0 3px 12px rgba(17,24,39,.09); }
.suggestion-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.suggestion-card { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.suggestion-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.suggestion-heading span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.suggestion-heading strong { font-family: "Space Mono", monospace; font-size: 1.25rem; }
.suggestion-swatch { width: 50px; height: 50px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.12); border-radius: 14px; }
.suggestion-card p { min-height: 44px; margin: 18px 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }

.code-section { display: grid; grid-template-columns: minmax(220px, .65fr) minmax(0, 1.35fr); gap: 24px; align-items: start; }
.code-section pre { margin: 0; overflow: auto; padding: 20px; border-radius: 16px; background: #111827; color: #eaf1ff; font-family: "Space Mono", monospace; font-size: .78rem; line-height: 1.65; }

.content-ad { min-height: 120px; margin-top: 22px; border: 1px dashed #c8ced8; border-radius: 18px; padding: 12px; text-align: center; }
.content-ad > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .12em; }
.lab-footer { min-height: 80px; padding-bottom: var(--safe-bottom); display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid rgba(17,24,39,.08); color: var(--muted); font-size: .8rem; }
.lab-footer nav { display: flex; gap: 17px; }
.lab-footer a { text-decoration: none; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { min-height: 380px; }
  .standards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .standard-card:last-child { grid-column: 1 / -1; }
  .correction-section, .code-section { grid-template-columns: 1fr; }
  .suggestion-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .lab-header { min-height: 62px; }
  .lab-nav a:nth-child(2) { display: none; }
  .lab-main { padding-top: 28px; padding-bottom: 55px; }
  h1 { font-size: clamp(2.7rem, 16vw, 4.3rem); }
  .control-panel, .preview-panel, .results-section, .correction-section, .code-section { border-radius: 20px; }
  .color-controls { grid-template-columns: 1fr; }
  .swap-button { justify-self: center; transform: rotate(90deg); }
  .swap-button:hover { transform: rotate(270deg); }
  .toolbar > * { flex: 1 1 calc(50% - 9px); }
  .toolbar .primary-button { flex-basis: 100%; }
  .preview-content { padding: 38px 25px 45px; }
  .results-heading { align-items: flex-start; flex-direction: column; }
  .ratio-block { text-align: left; }
  .standards-grid { grid-template-columns: 1fr 1fr; }
  .standard-card { padding: 14px; }
  .suggestion-actions > * { flex: 1; }
  .lab-footer { align-items: flex-start; flex-direction: column; justify-content: center; padding-top: 20px; padding-bottom: calc(20px + var(--safe-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
