/* styles.css — Color Shades · Mono / Receipt aesthetic */

:root {
  --bg: #FFFFFF;
  --fg: #0A0A0A;
  --muted: #F4F4F2;
  --muted-fg: #888;
  --border: #C0C0C0;
  --primary: #E8092A;
  --ring: #E8092A;
  --soft-bg: #F4F4F2;
  --radius: 0px;
  --radius-sm: 0px;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: 0 4px 32px rgba(0,0,0,.14);
  --font-sans: "IBM Plex Mono", ui-monospace, "Courier New", monospace;
  --font-mono: "IBM Plex Mono", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background .2s, color .2s;
}
body.dark {
  --bg: #0B0B0B;
  --fg: #F0F0F0;
  --muted: #161616;
  --muted-fg: #666;
  --border: #2E2E2E;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

/* ── Page ──────────────────────────────────────────────── */
.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot {
  width: 26px; height: 26px;
  border: 1px solid rgba(0,0,0,.12);
  transition: background .25s; flex-shrink: 0;
}
body.dark .brand-dot { border-color: rgba(255,255,255,.1); }
.brand-name { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-sub  { font-size: 9px; color: var(--muted-fg); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }

/* ── Topbar tabs ───────────────────────────────────────── */
.topbar-tabs {
  display: flex; align-items: stretch;
  position: absolute; left: 50%; transform: translateX(-50%);
  border: 1px solid var(--border); overflow: hidden;
}
.topbar-tab {
  padding: 7px 20px;
  font-size: 10px; font-weight: 700;
  color: var(--muted-fg);
  letter-spacing: 0.1em; text-transform: uppercase;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  transition: background .1s, color .1s;
}
.topbar-tab:last-child { border-right: none; }
.topbar-tab:hover { color: var(--fg); background: var(--muted); }
.topbar-tab.active { background: var(--fg); color: var(--bg); }

/* ── Buttons ───────────────────────────────────────────── */
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn-ghost {
  height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; gap: 5px;
  color: var(--muted-fg); border: 1px solid var(--border);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  transition: background .1s, color .1s, border-color .1s;
}
.btn-ghost.sm { height: 28px; padding: 0 9px; }
.btn-ghost:hover { background: var(--muted); color: var(--fg); border-color: var(--fg); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 32px;
  background: var(--fg); color: var(--bg);
  border: 1px solid var(--fg);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: opacity .12s;
}
.btn-primary.sm { height: 28px; padding: 0 10px; }
.btn-primary:hover { opacity: .8; }
.btn-primary:active { opacity: .65; }

/* ── Palette view ──────────────────────────────────────── */
.palette-view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.palette-toolbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
}
.palette-space-hint { font-size: 10px; color: var(--muted-fg); letter-spacing: 0.06em; text-transform: uppercase; }
.palette-space-hint kbd {
  display: inline-block; padding: 2px 6px;
  border: 1px solid var(--border); border-bottom-width: 2px;
  background: var(--muted); font-family: var(--font-mono);
  font-size: 10px; color: var(--fg); line-height: 1.4;
}
.palette-cols { flex: 1; display: flex; min-height: 480px; }
.palette-col {
  flex: 1; position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 24px 28px;
  transition: flex .28s cubic-bezier(.2,.8,.2,1);
  border-right: 1px solid rgba(0,0,0,.1);
}
body.dark .palette-col { border-right-color: rgba(255,255,255,.06); }
.palette-col:last-child { border-right: none; }
.palette-col:hover { flex: 1.18; }

.palette-col-actions {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
.palette-col:hover .palette-col-actions { opacity: 1; pointer-events: auto; }
.pal-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.32);
  backdrop-filter: blur(8px);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, transform .1s;
}
.pal-btn:hover { background: rgba(255,255,255,.35); transform: scale(1.06); }
body.dark .pal-btn { background: rgba(0,0,0,.28); border-color: rgba(255,255,255,.14); }

.palette-lock-badge { position: absolute; top: 14px; right: 14px; opacity: .6; }

.palette-add-btn {
  position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
  z-index: 5; width: 28px; height: 28px;
  background: var(--bg); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg); opacity: 0; transition: opacity .15s, transform .15s;
}
.palette-col:hover .palette-add-btn { opacity: 1; }
.palette-add-btn:hover { transform: translateY(-50%) scale(1.1); }

.palette-col-label { display: flex; flex-direction: column; gap: 4px; }
.palette-hex-label {
  font-family: var(--font-mono); font-size: 18px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; opacity: .9; cursor: text; line-height: 1;
}
.palette-hex-label:hover { opacity: 1; }
.palette-hex-edit { display: flex; align-items: baseline; gap: 2px; font-family: var(--font-mono); }
.palette-hex-hash { font-size: 18px; font-weight: 700; opacity: .5; line-height: 1; }
.palette-hex-input {
  border: none; outline: none; background: transparent;
  font-family: var(--font-mono); font-size: 18px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  width: 120px; border-bottom: 2px solid currentColor; padding-bottom: 1px; line-height: 1;
}
.palette-color-name {
  font-size: 10px; font-weight: 600; opacity: .55;
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Palette placeholder ───────────────────────────────── */
.palette-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; }
.placeholder-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 48px 56px;
  border: 1px solid var(--border); background: var(--muted); text-align: center;
}
.placeholder-icon {
  width: 48px; height: 48px; border: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.placeholder-dot { width: 22px; height: 22px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: background .25s; }
.placeholder-title { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.placeholder-sub { margin: 0; font-size: 10px; color: var(--muted-fg); max-width: 260px; line-height: 1.6; letter-spacing: 0.02em; }

/* ── Main content ──────────────────────────────────────── */
.main {
  max-width: 1240px; width: 100%;
  margin: 0 auto; padding: 28px 28px 60px;
  display: flex; flex-direction: column; gap: 24px;
}
.panel { background: var(--bg); border: 1px solid var(--border); padding: 20px 20px 22px; overflow: hidden; }
.panel-head, .controls-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: -20px -20px 20px; padding: 14px 20px;
  background: var(--muted); border-bottom: 1px solid var(--border);
}
.h-title { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.h-sub { margin: 4px 0 0; font-size: 10px; color: var(--muted-fg); letter-spacing: 0.04em; }

/* ── Steps control ─────────────────────────────────────── */
.steps-control { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.steps-control > label { font-size: 10px; color: var(--muted-fg); letter-spacing: 0.08em; text-transform: uppercase; }
.steps-control .steps-sep { padding-left: 6px; border-left: 1px solid var(--border); }
.steps-control .steps-posdisplay { font-size: 10px; color: var(--muted-fg); font-family: var(--font-mono); }
.steps-input-wrap {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border); overflow: hidden;
}
.steps-btn {
  width: 28px; height: 28px; color: var(--muted-fg);
  font-size: 15px; line-height: 1; font-weight: 500; transition: background .1s, color .1s;
}
.steps-btn:hover { background: var(--muted); color: var(--fg); }
.steps-input-wrap input {
  width: 40px; height: 28px; border: none; outline: none;
  background: transparent; color: var(--fg);
  font-family: var(--font-mono); font-size: 12px;
  text-align: center; font-weight: 700; -moz-appearance: textfield;
}
.steps-input-wrap input::-webkit-outer-spin-button,
.steps-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Segmented algo ────────────────────────────────────── */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border); margin-bottom: 20px; overflow: hidden;
}
.seg-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 10px 14px; border-right: 1px solid var(--border);
  color: var(--muted-fg); transition: background .1s, color .1s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--fg); background: var(--muted); }
.seg-btn.active { background: var(--fg); color: var(--bg); }
.seg-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.seg-sub { font-size: 10px; margin-top: 3px; opacity: .65; letter-spacing: 0.02em; }

/* ── Tint control ──────────────────────────────────────── */
.tint-control { border: 1px solid var(--border); padding: 14px 16px; background: var(--muted); margin-bottom: 20px; }
.tint-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.tint-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.tint-sub { font-size: 10px; color: var(--muted-fg); margin-top: 2px; letter-spacing: 0.02em; }
.tint-val { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--muted-fg); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.tint-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.tint-end { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--muted-fg); }
.tint-end-sw { width: 16px; height: 16px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
body.dark .tint-end-sw { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.tint-end-hex { letter-spacing: 0.06em; text-transform: uppercase; }

.tint-slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: linear-gradient(to right,
    var(--primary) 0%, var(--primary) var(--tint-pct, 50%),
    color-mix(in srgb, var(--fg) 15%, transparent) var(--tint-pct, 50%),
    color-mix(in srgb, var(--fg) 15%, transparent) 100%);
  outline: none;
}
.tint-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  background: var(--bg); border: 2px solid var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.15); cursor: pointer;
}
.tint-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--bg); border: 2px solid var(--primary); cursor: pointer;
}

@media (max-width: 560px) {
  .tint-row { grid-template-columns: 1fr; }
  .tint-end { justify-content: space-between; }
}

/* ── Color tabs ────────────────────────────────────────── */
.color-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.color-tabs-list { display: flex; flex-wrap: wrap; border: 1px solid var(--border); }
.color-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: var(--bg);
  border-right: 1px solid var(--border);
  cursor: pointer; transition: background .1s; user-select: none;
}
.color-tab:last-of-type { border-right: none; }
.color-tab:hover { background: var(--muted); }
.color-tab.active { background: var(--muted); box-shadow: inset 0 -2px 0 0 var(--fg); }
.color-tab-sw { width: 14px; height: 14px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); flex-shrink: 0; }
body.dark .color-tab-sw { box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.color-tab-name { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.color-tab-name-input {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  border: none; outline: none; background: transparent; color: var(--fg);
  width: 90px; border-bottom: 1px solid var(--border);
}
.color-tab-hex { font-family: var(--font-mono); font-size: 10px; color: var(--muted-fg); letter-spacing: 0.04em; }
.color-tab-hex-wrap {
  display: inline-flex; align-items: center; gap: 1px;
  padding: 1px 3px; border: 1px solid transparent;
  transition: border-color .12s; cursor: text;
}
.color-tab-hex-wrap:hover { border-color: var(--border); }
.color-tab-hex-wrap:focus-within { border-color: var(--ring); }
.color-tab-hex-wrap.invalid { border-color: #DC2626; }
.color-tab-hex-hash { font-family: var(--font-mono); font-size: 10px; color: var(--muted-fg); }
.color-tab-hex-input {
  border: none; outline: none; background: transparent;
  font-family: var(--font-mono); font-size: 10px; color: var(--muted-fg); font-weight: 700;
  width: 55px; letter-spacing: 0.05em; text-transform: uppercase;
}
.color-tab-x {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted-fg); opacity: .4; transition: opacity .1s, color .1s;
}
.color-tab-x:hover { opacity: 1; color: var(--fg); }
.color-tab-add {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px dashed var(--border);
  font-size: 10px; font-weight: 700; color: var(--muted-fg);
  letter-spacing: 0.08em; text-transform: uppercase;
  transition: border-color .1s, color .1s, background .1s; margin-left: 6px;
}
.color-tab-add:hover { border-color: var(--fg); color: var(--fg); border-style: solid; background: var(--muted); }

/* ── Layout switcher ───────────────────────────────────── */
.controls-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.layout-switcher { display: inline-flex; border: 1px solid var(--border); overflow: hidden; }
.layout-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; font-size: 10px; color: var(--muted-fg);
  border-right: 1px solid var(--border); transition: background .1s, color .1s;
}
.layout-btn:last-child { border-right: none; }
.layout-btn:hover { color: var(--fg); background: var(--muted); }
.layout-btn.active { background: var(--fg); color: var(--bg); }
.layout-btn svg { width: 12px; height: 12px; }

/* ── Shade strip ───────────────────────────────────────── */
.strip-wrap { margin-bottom: 20px; }
.strip {
  display: flex; flex-direction: row; flex-wrap: nowrap;
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fg) 25%, transparent) transparent;
}
.strip::-webkit-scrollbar { height: 6px; }
.strip::-webkit-scrollbar-track { background: transparent; }
.strip::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--fg) 22%, transparent); }
.tile {
  position: relative; flex: 1 0 auto; min-width: 72px;
  width: calc((100% - (var(--tile-count, 1) - 1) * 1px) / var(--tile-count, 1));
  height: 128px; padding: 10px 10px 10px 12px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer; transition: filter .12s;
}
.tile:hover { filter: brightness(1.04); z-index: 2; }
.tile:active { filter: brightness(.92); }
.tile.selected { outline: 3px solid var(--fg); outline-offset: -3px; z-index: 3; }
.tile.base::before {
  content: ''; position: absolute; inset: 3px;
  border: 1px dashed currentColor; opacity: .38; pointer-events: none;
}
.tile-base-dot { position: absolute; top: 6px; right: 6px; width: 5px; height: 5px; background: currentColor; opacity: .6; }
.tile-top {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; opacity: .8;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; gap: 4px;
}
.tile-idx { letter-spacing: 0.06em; font-weight: 700; }
.tile-dots {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: .45; transition: opacity .1s, background .1s; flex-shrink: 0;
}
.tile-dots:hover { opacity: 1; background: rgba(255,255,255,.18); }
.tile.selected .tile-dots { opacity: .75; }
.tile-bot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-family: var(--font-mono); letter-spacing: 0.04em; gap: 4px; min-width: 0;
}
.tile-hex { opacity: .9; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-copied {
  font-family: var(--font-sans); font-weight: 700; font-size: 9px;
  background: rgba(255,255,255,.26); padding: 2px 6px;
  letter-spacing: 0.06em; text-transform: uppercase; flex-shrink: 0;
}

.strip-axis {
  margin-top: 8px; display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted-fg); padding: 0 2px; letter-spacing: 0.04em;
}
.strip-axis span:nth-child(2) { opacity: .55; }

/* — Vertical — */
.strip-vertical { flex-direction: column; overflow-x: hidden; overflow-y: auto; max-height: 70vh; }
.strip-vertical .tile {
  width: 100%; min-width: 0; height: auto; min-height: 52px;
  padding: 10px 16px; flex-direction: row;
  align-items: center; justify-content: space-between; gap: 16px;
}
.strip-vertical .tile-top { flex: 0 0 auto; gap: 10px; }
.strip-vertical .tile-bot { flex: 1 1 auto; justify-content: flex-end; }
.layout-vertical .strip-axis { display: none; }

/* — Grid — */
.strip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); overflow: visible; max-height: none; }
.strip-grid .tile { width: auto; min-width: 0; height: 90px; }
.layout-grid .strip-axis { display: none; }

/* ── Selected card ─────────────────────────────────────── */
.selected-card {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px;
  border: 1px solid var(--border); padding: 14px; background: var(--muted);
}
.selected-card.empty {
  grid-template-columns: 1fr; text-align: center;
  padding: 22px; color: var(--muted-fg);
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
}
.sc-swatch { min-height: 108px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.sc-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sc-label { font-size: 9px; color: var(--muted-fg); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
.sc-hex { font-family: var(--font-mono); font-size: 18px; font-weight: 700; letter-spacing: 0.02em; margin-top: 2px; }
.sc-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.sc-field {
  display: grid; grid-template-columns: 44px 1fr 16px;
  align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 11px; text-align: left; transition: background .1s;
}
.sc-field:hover { background: color-mix(in srgb, var(--fg) 4%, var(--bg)); }
.sc-k { font-size: 9px; font-weight: 700; color: var(--muted-fg); letter-spacing: 0.1em; text-transform: uppercase; }
.sc-v { font-family: var(--font-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-ico { color: var(--muted-fg); display: inline-flex; }

/* ── Modals ────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-width: 780px; width: 100%; max-height: calc(100vh - 48px);
  overflow: hidden; display: flex; flex-direction: column;
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.detail-swatch { position: relative; height: 200px; display: flex; align-items: flex-end; padding: 20px 24px; }
.detail-swatch-label .detail-idx { font-size: 9px; opacity: .7; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
.detail-swatch-label .detail-hex { font-family: var(--font-mono); font-size: 28px; font-weight: 700; letter-spacing: 0.02em; margin-top: 4px; }
.detail-swatch-label .detail-named { font-size: 11px; opacity: .7; margin-top: 4px; letter-spacing: 0.02em; }

.modal-nav, .modal-close {
  position: absolute; top: 14px; width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3);
  color: #fff; transition: background .12s;
}
.modal-nav.left  { left: 14px; }
.modal-nav.right { left: 52px; }
.modal-close { right: 14px; }
.modal-close.static {
  position: static; background: var(--muted); border: 1px solid var(--border);
  color: var(--muted-fg); width: 32px; height: 32px;
}
.modal-close.static:hover { color: var(--fg); }
.modal-nav:hover, .modal-close:hover { background: rgba(255,255,255,.35); }

.detail-body { padding: 20px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.detail-section-label { font-size: 9px; font-weight: 700; color: var(--muted-fg); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 10px; }
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.detail-field {
  display: grid; grid-template-columns: 56px 1fr 16px;
  align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--border); background: var(--bg);
  text-align: left; transition: background .1s;
}
.detail-field:hover { background: var(--muted); }
.df-k { font-size: 9px; font-weight: 700; color: var(--muted-fg); letter-spacing: 0.1em; text-transform: uppercase; }
.df-v { font-family: var(--font-mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-ico { color: var(--muted-fg); display: inline-flex; }

.contrast-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contrast-cell { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); background: var(--muted); }
.contrast-sample { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.contrast-meta { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.contrast-label { font-size: 10px; color: var(--muted-fg); letter-spacing: 0.04em; }
.contrast-ratio { display: flex; align-items: center; gap: 8px; }
.cr-val { font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
.cr-grade { font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 5px; }
.cr-grade.pass { background: #DCFCE7; color: #166534; }
.cr-grade.warn { background: #FEF3C7; color: #854D0E; }
.cr-grade.fail { background: #FEE2E2; color: #991B1B; }
body.dark .cr-grade.pass { background: #052E16; color: #86EFAC; }
body.dark .cr-grade.warn { background: #422006; color: #FDE047; }
body.dark .cr-grade.fail { background: #450A0A; color: #FCA5A5; }

.named-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); background: var(--muted); }
.named-sw { width: 18px; height: 18px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.named-name { font-weight: 700; font-size: 12px; }
.named-hex { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted-fg); letter-spacing: 0.04em; }

/* ── Export modal ──────────────────────────────────────── */
.modal.export { max-width: 720px; }
.export-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.export-tabs { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.export-tab {
  padding: 9px 14px; font-size: 10px; font-weight: 700; color: var(--muted-fg);
  letter-spacing: 0.08em; text-transform: uppercase;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-right: 1px solid var(--border); transition: color .1s, border-color .1s;
}
.export-tab:hover { color: var(--fg); }
.export-tab.active { color: var(--fg); border-bottom-color: var(--fg); }
.export-tabs .btn-primary.sm { margin: 6px 8px; }
.export-code {
  margin: 0; padding: 18px 22px; background: var(--muted);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.65;
  overflow: auto; max-height: 440px; color: var(--fg); flex: 1; min-height: 240px;
}

/* ── UI Check view ─────────────────────────────────────── */
.ui-check-view {
  max-width: 1240px; width: 100%;
  margin: 0 auto; padding: 28px 28px 60px;
  display: flex; flex-direction: column; gap: 28px;
}
.ui-check-block { display: flex; flex-direction: column; gap: 12px; }
.ui-check-block-label { display: flex; align-items: center; gap: 10px; }
.ui-check-block-sw { width: 18px; height: 18px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); flex-shrink: 0; }
body.dark .ui-check-block-sw { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.ui-check-block-name { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.ui-check-block-hex { font-family: var(--font-mono); font-size: 10px; color: var(--muted-fg); letter-spacing: 0.06em; }

/* ── UI Preview ────────────────────────────────────────── */
.preview {
  background: var(--p-bg); color: var(--p-text);
  border: 1px solid var(--border); padding: 20px;
  transition: background .2s, color .2s;
}
.pv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px; background: var(--p-border); border: 1px solid var(--p-border); margin-top: 1px;
}
.pv-card { background: var(--p-surface); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pv-card-head { display: flex; align-items: center; gap: 10px; }
.pv-avatar { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.pv-card-title { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.pv-card-sub { font-size: 10px; color: var(--p-muted); margin-top: 1px; letter-spacing: 0.02em; }
.pv-chip { margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 6px; background: var(--p-text); color: var(--p-bg); }
.pv-card-body { display: flex; flex-direction: column; gap: 8px; }
.pv-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; }
.pv-row.small { font-size: 10px; color: var(--p-muted); letter-spacing: 0.02em; }
.pv-bar-wrap { height: 3px; background: var(--p-accent); overflow: hidden; }
.pv-bar { height: 100%; background: var(--p-primary); }
.pv-card-foot { display: flex; gap: 6px; justify-content: flex-end; }
.pv-btn { padding: 6px 12px; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid transparent; transition: filter .1s; font-family: var(--font-sans); }
.pv-btn.ghost { background: transparent; color: var(--p-text); border-color: var(--p-border); }
.pv-btn.ghost:hover { background: var(--p-accent); }
.pv-btn.primary { background: var(--p-primary); color: var(--p-primary-fg); }
.pv-btn.primary:hover { filter: brightness(1.08); }

.pv-label { font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--p-muted); }
.pv-input { width: 100%; padding: 7px 9px; border: 1px solid var(--p-border); background: var(--p-bg); color: var(--p-text); font-size: 11px; outline: none; font-family: var(--font-sans); }
.pv-input:focus { border-color: var(--p-primary); }
.pv-seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--p-border); overflow: hidden; }
.pv-seg-btn { padding: 5px; font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--p-muted); border-right: 1px solid var(--p-border); transition: background .1s, color .1s; font-family: var(--font-sans); }
.pv-seg-btn:last-child { border-right: none; }
.pv-seg-btn.active { background: var(--p-primary); color: var(--p-primary-fg); }

.pv-checks { display: flex; flex-direction: column; gap: 6px; }
.pv-check { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.pv-box { width: 13px; height: 13px; border: 1px solid var(--p-border); background: var(--p-bg); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pv-box.checked { background: var(--p-primary); border-color: var(--p-primary); position: relative; }
.pv-box.checked::after { content: ''; width: 6px; height: 3px; border-left: 1.5px solid var(--p-primary-fg); border-bottom: 1.5px solid var(--p-primary-fg); transform: rotate(-45deg) translate(0, -1px); }

.pv-stat { display: flex; flex-direction: column; gap: 2px; }
.pv-stat-lbl { font-size: 9px; color: var(--p-muted); letter-spacing: 0.1em; text-transform: uppercase; }
.pv-stat-val { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.pv-stat-delta { font-size: 10px; color: var(--p-muted); }
.pv-stat-delta.up { color: var(--p-primary); }
.pv-sparkline { margin: 2px 0; }
.pv-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.pv-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 6px; border: 1px solid var(--p-border); color: var(--p-muted); }
.pv-tag.filled { background: var(--p-primary); color: var(--p-primary-fg); border-color: transparent; }

/* — Nav bar — */
.pv-nav { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--p-surface); border: 1px solid var(--p-border); margin-bottom: 14px; }
.pv-nav-logo { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.pv-nav-links { display: flex; align-items: center; flex: 1; border-left: 1px solid var(--p-border); }
.pv-nav-link { padding: 4px 10px; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--p-muted); border-right: 1px solid var(--p-border); transition: background .1s, color .1s; }
.pv-nav-link.active { background: var(--p-primary); color: var(--p-primary-fg); }
.pv-nav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pv-nav-search { padding: 4px 9px; font-size: 10px; border: 1px solid var(--p-border); background: var(--p-bg); color: var(--p-muted); }
.pv-nav-avatar { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; }

/* — Notifications — */
.pv-notif { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--p-border); font-size: 11px; }
.pv-notif:last-child { border-bottom: none; }
.pv-notif-dot { width: 7px; height: 7px; flex-shrink: 0; }
.pv-notif-text { flex: 1; }
.pv-notif-time { font-size: 9px; color: var(--p-muted); letter-spacing: 0.04em; white-space: nowrap; }

/* — Team — */
.pv-member { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--p-border); }
.pv-member:last-child { border-bottom: none; }
.pv-member-av { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; flex-shrink: 0; }
.pv-member-info { flex: 1; min-width: 0; }
.pv-member-name { font-size: 11px; font-weight: 700; }
.pv-member-role { font-size: 9px; color: var(--p-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 1px; }
.pv-member-status { width: 7px; height: 7px; flex-shrink: 0; }

/* — Preferences — */
.pv-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--p-border); font-size: 11px; }
.pv-toggle-row:last-child { border-bottom: none; }
.pv-toggle-label { flex: 1; }
.pv-toggle { width: 30px; height: 16px; position: relative; flex-shrink: 0; transition: background .15s; }
.pv-toggle-knob { position: absolute; top: 2px; width: 12px; height: 12px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }

/* ── Tints Panel ───────────────────────────────────────── */
.tints-panel .tint-control { margin-bottom: 16px; }
.tints-source { display: inline-flex; align-items: center; gap: 6px; padding: 2px 7px 2px 4px; background: var(--muted); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 10px; color: var(--fg); vertical-align: middle; margin-left: 2px; }
.tints-source.is-selected { border-color: var(--primary); }
.tints-source-sw { width: 14px; height: 14px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); flex-shrink: 0; }
body.dark .tints-source-sw { box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.tints-source-label { font-family: var(--font-sans); font-size: 10px; color: var(--muted-fg); letter-spacing: 0.02em; }
.tints-source-hex { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.tints-hint { color: var(--muted-fg); font-style: italic; }
.tints-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tints-steps { display: flex; align-items: center; gap: 10px; }
.tints-steps > label { font-size: 10px; color: var(--muted-fg); letter-spacing: 0.08em; text-transform: uppercase; }

.tints-grid { display: grid; gap: 1px; border: 1px solid var(--border); background: var(--border); overflow: hidden; }
.tints-layout-horizontal { grid-template-columns: repeat(var(--tcount, 10), minmax(0, 1fr)); }
.tints-layout-vertical { grid-template-columns: 1fr; overflow-y: auto; max-height: 70vh; }
.tints-layout-vertical .tint-tile { height: auto; min-height: 44px; flex-direction: row; align-items: center; justify-content: space-between; padding: 8px 14px; }
.tints-layout-vertical .tint-tile-hex { text-align: right; }
.tints-layout-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); overflow: visible; }
.tints-layout-grid .tint-tile { height: 80px; }

.tint-tile {
  position: relative; height: 100px;
  padding: 9px 10px 9px 11px;
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: left; cursor: pointer; font-family: var(--font-mono); transition: filter .12s;
}
.tint-tile:hover { filter: brightness(1.05); z-index: 2; }
.tint-tile:active { filter: brightness(.92); }
.tint-tile-idx { font-size: 9px; opacity: .8; letter-spacing: 0.08em; font-weight: 700; font-variant-numeric: tabular-nums; }
.tint-tile-hex { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tint-tile-copied { position: absolute; top: 7px; right: 7px; font-family: var(--font-sans); font-size: 9px; font-weight: 700; background: rgba(255,255,255,.28); padding: 2px 6px; letter-spacing: 0.06em; text-transform: uppercase; }

@media (max-width: 860px) { .tints-layout-horizontal { grid-template-columns: repeat(min(var(--tcount, 10), 6), minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .tints-layout-horizontal { grid-template-columns: repeat(min(var(--tcount, 10), 4), minmax(0, 1fr)); }
  .tints-layout-horizontal .tint-tile { height: 76px; }
}

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 10px 16px 10px 18px;
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg);
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap; animation: toast-in .18s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.toast-close { font-size: 16px; line-height: 1; opacity: .5; color: inherit; transition: opacity .1s; padding: 0 2px; }
.toast-close:hover { opacity: 1; }

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
  text-align: center; padding: 28px 28px 48px;
  font-size: 10px; color: var(--muted-fg);
  letter-spacing: 0.08em; text-transform: uppercase;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--fg); text-decoration: none; font-weight: 700; border-bottom: 1px solid var(--border); transition: border-color .12s, color .12s; }
.site-footer a:hover { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 860px) { .main { padding: 20px 18px 48px; } }

@media (max-width: 720px) {
  .controls-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .controls-head-actions { justify-content: space-between; flex-wrap: nowrap; }
  .h-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .panel-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .tints-head-actions { justify-content: space-between; flex-wrap: nowrap; }
  .selected-card { grid-template-columns: 1fr; }
  .sc-swatch { min-height: 80px; }
  .sc-fields { grid-template-columns: 1fr; }
  .detail-fields { grid-template-columns: 1fr; }
  .contrast-grid { grid-template-columns: 1fr; }
  .tile { height: 84px; padding: 8px 8px 8px 10px; }
  .segmented { grid-template-columns: 1fr; }
  .seg-btn { border-right: none; border-bottom: 1px solid var(--border); }
  .seg-btn:last-child { border-bottom: none; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px 0; gap: 0; }
  .brand { flex: 1; min-width: 0; order: 1; }
  .top-actions { flex-shrink: 0; order: 2; gap: 6px; }
  .brand-sub { display: none; }
  .topbar-tabs { order: 3; position: static; transform: none; flex: 0 0 100%; width: calc(100% + 32px); margin: 8px -16px 0; border: none; border-top: 1px solid var(--border); }
  .topbar-tab { flex: 1; text-align: center; padding: 9px 8px; font-size: 10px; }
  .topbar-tab.active { background: var(--fg); color: var(--bg); }
}

@media (max-width: 600px) {
  .main { padding: 12px 12px 40px; }
  .panel { padding: 14px 14px 16px; }
  .controls-head { margin: -14px -14px 14px; padding: 12px 14px; }
  .panel-head { margin: -14px -14px 14px; padding: 12px 14px; }
  .steps-control { flex-wrap: wrap; gap: 6px 8px; }
  .steps-control .steps-sep { padding-left: 0; border-left: none; flex-basis: 100%; }
  .steps-control .steps-posdisplay { display: none; }
  .tile { height: 76px; padding: 8px; }
  .sc-swatch { min-height: 76px; }
  .detail-swatch { height: 150px; }
  .detail-swatch-label .detail-hex { font-size: 22px; }
}
