/* NV Palette — an artist's studio: cotton canvas paper, painted swatches, ink lettering. Fonts: IBM Plex (SIL OFL). */
@font-face { font-family: 'Plex Mono'; src: url('./fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Condensed'; src: url('./fonts/ibm-plex-sans-condensed-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Condensed'; src: url('./fonts/ibm-plex-sans-condensed-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
:root {
  --paper: #f4efe6; --paper-2: #ebe3d6; --card: #fbf8f2; --ink: #22201c; --muted: #6f685d; --line: rgba(34, 32, 28, 0.13); --accent: #b4532a;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Plex Condensed', 'Arial Narrow', system-ui, sans-serif; --mono: 'Plex Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 500 16px/1.45 var(--sans);
  background: repeating-linear-gradient(45deg, rgba(34, 32, 28, 0.015) 0 2px, transparent 2px 6px), linear-gradient(var(--paper), var(--paper-2)) fixed;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
.atelier { width: min(1100px, calc(100% - 32px)); margin: clamp(16px, 4vw, 40px) auto; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 14px; }
.brand { margin: 0; font-size: 12px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--accent); }
.brand span { color: var(--ink); font-weight: 600; }
h1 { margin: 2px 0 0; font: 600 clamp(28px, 5vw, 40px)/1.05 var(--serif); }
h2 { margin: 0 0 10px; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }
h2 small { letter-spacing: 0; text-transform: none; color: var(--muted); font-size: 13px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.base input { width: 46px; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--card); cursor: pointer; }
.hex { width: 104px; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 6px 10px; font: 400 15px var(--mono); text-transform: lowercase; }
.hex[aria-invalid='true'] { border-color: #c0392b; }
.controls select { min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 6px 10px; }
.btn { min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.btn--ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.palette { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); min-height: 280px; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 50px -26px rgba(34, 32, 28, 0.55), 0 0 0 1px var(--line); }
.swatch { position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 14px; border: 0; cursor: pointer; text-align: left; transition: flex 0.2s; }
.swatch[aria-pressed='true']::after { content: ''; position: absolute; left: 14px; right: 14px; top: 12px; height: 3px; border-radius: 3px; background: currentColor; opacity: 0.8; }
.swatch b { font: 400 18px var(--mono); letter-spacing: 0.02em; }
.swatch small { font-size: 12px; opacity: 0.85; }
.lock { position: absolute; top: 22px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.22); cursor: pointer; font-size: 15px; }
.lock[aria-pressed='true'] { background: rgba(255, 255, 255, 0.85); }
.hint { margin: -6px 0 0; font-size: 13px; color: var(--muted); }
kbd { font: 400 11px var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--card); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--card); border-radius: 16px; padding: 16px 18px; box-shadow: 0 0 0 1px var(--line); min-width: 0; }
.codes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.codes button { width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px 12px; cursor: pointer; }
.codes button:hover { border-color: var(--ink); }
.codes span { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.codes code { font: 400 14px var(--mono); overflow-wrap: anywhere; text-align: right; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f { display: grid; gap: 3px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.f select, .f input { min-height: 38px; border-radius: 9px; border: 1px solid var(--line); background: #fff; padding: 4px 8px; font: 400 14px var(--mono); letter-spacing: 0; text-transform: none; color: var(--ink); }
.f--inline { grid-auto-flow: column; align-items: center; gap: 8px; }
.sample { margin-top: 10px; padding: 14px 16px; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.sample p { margin: 0; }
.sample__big { font: 600 24px/1.25 var(--serif); margin-bottom: 4px !important; }
.ratio { margin: 10px 0 6px; font: 400 26px var(--mono); }
.badges { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badges li { font-size: 13px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.badges .pass { background: #e3f2e6; border-color: #9fd0aa; color: #1f5a2c; }
.badges .fail { background: #f8e3df; border-color: #e3a79c; color: #8a2b1d; }
.scale { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.scale button { width: 100%; min-height: 86px; border: 0; padding: 8px 6px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; cursor: pointer; text-align: left; }
.scale b { font: 600 12px var(--sans); }
.scale small { font: 400 11px var(--mono); overflow-wrap: anywhere; }
.export-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.export-head h2 { margin: 0 auto 0 0; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected='true'] { background: var(--ink); color: var(--paper); }
.code { margin: 0; padding: 14px; border-radius: 12px; background: #22201c; color: #f4efe6; font: 400 13px/1.55 var(--mono); overflow: auto; max-height: 320px; }
.saved { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.saved li { display: grid; grid-template-columns: 1fr auto; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); background: #fff; }
.saved .load { display: flex; border: 0; padding: 0; height: 52px; cursor: pointer; background: none; }
.saved .load span { flex: 1; }
.saved .del { border: 0; background: #fff; width: 40px; cursor: pointer; color: var(--muted); }
.saved .del:hover { color: #8a2b1d; }
.saved .empty { grid-column: 1 / -1; color: var(--muted); font: italic 400 16px var(--serif); box-shadow: none; background: none; }
.foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); }
@media (max-width: 820px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .scale { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .palette { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .swatch { min-height: 76px; }
  .pair { grid-template-columns: minmax(0, 1fr); }
  .scale { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
