/* Palette — page styles. Shared tokens come from ../assets/css/tools.css */
.pal { --bar: 74px; --hint: 46px; height: calc(100vh - var(--hdr)); height: calc(100svh - var(--hdr)); min-height: 520px; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.pal-bar { height: var(--bar); flex: none; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 var(--g) 12px; }
.pal-id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pal-id .label { font-size: 10.5px; }
.pal-id h1 { font-size: 34px; line-height: .9; white-space: nowrap; }
.pal-id h1 em { color: var(--soft); }
.pal-ctl { display: flex; align-items: center; gap: 6px; }
.pal-ctl .vr { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.harm { display: flex; align-items: center; gap: 10px; }
.harm .mono { color: var(--muted); font-size: 10.5px; }
.harm select.inp { width: auto; min-width: 150px; padding: 8px 32px 8px 14px; border-radius: 99px; font-size: 13px; background-color: transparent; border-color: var(--line2); cursor: pointer; }
.harm select.inp:hover { border-color: var(--muted); }
.harm select option { background: var(--bg2); color: var(--ink); }
.btn.gold svg { transition: transform .7s var(--ease); }
.btn.gold.spin svg { transform: rotate(180deg); }
.btn.on-save { color: var(--accent); border-color: rgba(15,154,150,.5); }
.btn.on-save svg { fill: var(--accent); }
@media (max-width: 1360px) { .pal-ctl .btn.lbl span { display: none; } .pal-ctl .btn.lbl { width: 36px; height: 36px; padding: 0; } }
@media (max-width: 1100px) { .harm .mono { display: none; } }

/* ---------- stage & columns ---------- */
.pal-stage { position: relative; flex: 1; min-height: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.pal-stage.cvd-protanopia .cols { filter: url(#cvd-protanopia); }
.pal-stage.cvd-deuteranopia .cols { filter: url(#cvd-deuteranopia); }
.pal-stage.cvd-tritanopia .cols { filter: url(#cvd-tritanopia); }
.pal-stage.cvd-achromatopsia .cols { filter: url(#cvd-achromatopsia); }
.cols { position: absolute; inset: 0; display: flex; }
.col { --fs: 26px; position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 0 8px 9vh; overflow: hidden;
  transition: flex-grow .55s var(--ease), background-color .7s var(--ease), color .5s var(--ease), opacity .4s, transform .38s var(--ease); }
.col.out { opacity: 0; pointer-events: none; }
.noanim .col { transition: none !important; }
.col.dragging { z-index: 5; transition: none; box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 30px 80px rgba(0,0,0,.55); cursor: grabbing; }
.cols.sorting .col:not(.dragging) { transition: transform .38s var(--ease), background-color .7s var(--ease); }

.tools { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 26px; }
.tools button { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: inherit; opacity: 0; transform: translateY(8px); transition: opacity .35s var(--ease), transform .45s var(--ease), background-color .25s; }
.tools button:hover { background: color-mix(in srgb, currentColor 13%, transparent); }
.tools button:active { transform: scale(.92); }
.tools svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.col:hover .tools button, .col:focus-within .tools button { opacity: .82; transform: none; }
.col:hover .tools button:hover { opacity: 1; }
.tools button[data-a=lock].on { opacity: 1; transform: none; }
.tools button:nth-child(1) { transition-delay: .00s; } .tools button:nth-child(2) { transition-delay: .025s; } .tools button:nth-child(3) { transition-delay: .05s; } .tools button:nth-child(4) { transition-delay: .075s; } .tools button:nth-child(5) { transition-delay: .1s; }
.tools .grip { cursor: grab; touch-action: none; }
.tools .grip:active { cursor: grabbing; }

.meta { display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.hex { font-family: var(--mono); font-size: var(--fs); font-weight: 400; letter-spacing: .02em; line-height: 1.1; padding: 6px 10px; border-radius: 10px; transition: background-color .25s; cursor: text; white-space: nowrap; }
.hex:hover { background: color-mix(in srgb, currentColor 11%, transparent); }
.hex i { font-style: normal; opacity: .38; margin-right: .06em; }
.nm { font-family: var(--serif); font-style: italic; font-size: calc(var(--fs) * .62 + 3px); opacity: .72; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 6px; }
.lockmark { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0; transition: opacity .3s; }
.col.locked .lockmark { opacity: .55; }

/* add-between buttons */
.adds { position: absolute; inset: 0; pointer-events: none; }
.az { position: absolute; top: 0; bottom: 0; width: 56px; transform: translateX(-50%); pointer-events: auto; display: grid; place-items: center; }
.az button { width: 44px; height: 44px; border-radius: 50%; background: #faf8f3; color: #141312; display: grid; place-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.35); opacity: 0; transform: scale(.6); transition: opacity .25s, transform .4s var(--ease); }
.az button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.az:hover button { opacity: 1; transform: none; }
.az button:hover { background: var(--accent); }
.adds.hide .az, .sorting ~ .adds .az { display: none; }

/* shades overlay */
.shades { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; animation: shIn .45s var(--ease); }
.shades button { flex: 1; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; transition: flex-grow .3s var(--ease); position: relative; }
.shades button span { opacity: 0; transition: opacity .2s; }
.shades button:hover { flex-grow: 1.6; }
.shades button:hover span, .shades button.cur span { opacity: 1; }
.shades button.cur::before { content: ""; position: absolute; left: 14px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
@keyframes shIn { from { clip-path: inset(50% 0 50% 0); } to { clip-path: inset(0 0 0 0); } }

/* ---------- hint bar ---------- */
.pal-hints { height: var(--hint); flex: none; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 var(--g); color: var(--muted); }
.keys { display: flex; align-items: center; gap: 18px; font-size: 10.5px; white-space: nowrap; overflow: hidden; }
.keys span { display: inline-flex; align-items: center; gap: 7px; }
.keys .kbd { font-weight: 400; }
.keys .k-click { color: var(--faint); text-transform: none; letter-spacing: .02em; font-family: var(--sans); font-size: 12.5px; }
.keys .k-click svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.vision { display: flex; align-items: center; gap: 10px; font-size: 10.5px; }
.seg.sm { padding: 3px; }
.seg.sm button { padding: 4px 10px; font-size: 11.5px; font-family: var(--sans); text-transform: none; letter-spacing: 0; }
@media (max-width: 1200px) { .keys .k-click { display: none; } }

/* ---------- popovers ---------- */
.pop { position: fixed; z-index: 120; width: 300px; background: rgba(17,17,15,.96); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line2); border-radius: 18px; padding: 14px; box-shadow: 0 30px 90px rgba(0,0,0,.6); color: var(--ink); animation: popIn .35s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.ed-top { display: flex; gap: 12px; align-items: stretch; margin-bottom: 14px; }
.ed-sw { position: relative; width: 74px; height: 74px; border-radius: 12px; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.ed-sw input[type=color] { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; border-radius: 0; cursor: pointer; }
.ed-sw::after { content: "Pick"; position: absolute; right: 6px; bottom: 5px; font-family: var(--mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; color: var(--k, #fff); opacity: .7; }
.ed-nm { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.ed-nm b { font-weight: 400; font-size: 24px; line-height: 1; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-nm span { color: var(--muted); font-size: 10.5px; }
.ed-sl { display: grid; gap: 6px; margin-bottom: 12px; }
.ed-sl .fl { font-size: 10px; }
.ed-sl input[type=range] { height: 16px; }
.ed-sl input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: var(--track); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.ed-sl input[type=range]::-moz-range-track { height: 10px; border-radius: 99px; background: var(--track); }
.ed-sl input[type=range]::-webkit-slider-thumb { width: 16px; height: 16px; margin-top: -3px; background: #faf8f3; box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.4); }
.ed-sl input[type=range]:active::-webkit-slider-thumb { background: #faf8f3; transform: scale(1.15); }
.ed-sl input[type=range]::-moz-range-thumb { width: 16px; height: 16px; background: #faf8f3; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }
.ed-f { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.ed-f label { display: grid; gap: 4px; }
.ed-f .fl { font-size: 9.5px; }
.ed-f .inp { padding: 7px 8px; font-family: var(--mono); font-size: 12px; border-radius: 8px; text-transform: uppercase; -moz-appearance: textfield; }
.ed-f .inp::-webkit-inner-spin-button { -webkit-appearance: none; }
.ed-act { justify-content: space-between; }

/* ---------- drawer ---------- */
.drawer-bg { position: fixed; inset: 0; z-index: 140; background: rgba(5,5,4,.5); opacity: 0; visibility: hidden; transition: opacity .4s, visibility .4s; }
.drawer-bg.on { opacity: 1; visibility: visible; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 141; width: min(430px, 100%); background: var(--bg2); border-left: 1px solid var(--line2); display: flex; flex-direction: column; transform: translateX(102%); transition: transform .55s var(--ease); }
.drawer.on { transform: none; box-shadow: -40px 0 120px rgba(0,0,0,.5); }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer header h2 { font-weight: 400; font-size: 32px; line-height: 1; }
.drawer header h2 em { color: var(--muted); }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px 30px; scrollbar-width: thin; }
.d-intro { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.pk { display: block; width: 100%; text-align: left; padding: 12px; margin: 0 -12px 6px; width: calc(100% + 24px); border-radius: 16px; transition: background .3s; position: relative; }
.pk:hover { background: var(--bg3); }
.strip { display: flex; height: 62px; border-radius: 11px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.strip i { flex: 1; transition: flex-grow .45s var(--ease); }
.pk:hover .strip i:hover { flex-grow: 2.2; }
.pk-t { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 10px; }
.pk-t b { font-family: var(--serif); font-weight: 400; font-size: 21px; line-height: 1.1; }
.pk-t .mono { color: var(--faint); font-size: 10px; }
.pk p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.pk .del { position: absolute; top: 18px; right: 18px; width: 30px; height: 30px; border-radius: 50%; background: rgba(20, 19, 18,.75); display: grid; place-items: center; opacity: 0; transition: opacity .25s; color: var(--ink); }
.pk .del svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.pk:hover .del { opacity: 1; }
.pk .del:hover { background: var(--bad); color: #141312; }
.empty { text-align: center; padding: 50px 10px; color: var(--muted); }
.empty b { display: block; font-family: var(--serif); font-weight: 400; font-style: italic; font-size: 28px; color: var(--ink); margin-bottom: 6px; }
.menu-list { display: grid; gap: 6px; }
.menu-list button { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; text-align: left; font-size: 15px; }
.menu-list button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.menu-list .field { margin: 10px 0 0; }

/* ---------- modals (page specific) ---------- */
.modal .box.wide { width: min(980px, 100%); }
.modal .box.mid { width: min(860px, 100%); }
.modal .box header h2 em { color: var(--muted); }
.x-prev { display: flex; height: 54px; border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.x-prev i { flex: 1; }
.x-share { display: flex; gap: 8px; margin-bottom: 20px; }
.x-share .inp { font-family: var(--mono); font-size: 12px; color: var(--soft); }
.x-code-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.x-code { max-height: 230px; min-height: 150px; }
.x-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.x-files button { display: grid; gap: 4px; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 14px; transition: border-color .3s, background .3s; }
.x-files button:hover { border-color: var(--muted); background: var(--bg3); }
.x-files b { font-weight: 400; font-size: 14.5px; color: var(--ink); }
.x-files span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.x-sub { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.x-sub:first-of-type { margin-top: 0; }

/* image extraction */
.img-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.img-wrap { position: relative; border-radius: 12px; overflow: hidden; background: var(--bg3); line-height: 0; touch-action: none; }
.img-wrap canvas { width: 100%; height: auto; max-height: 62vh; object-fit: contain; }
.mk { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 2.5px solid #faf8f3; box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.45); cursor: grab; touch-action: none; transition: transform .25s var(--ease); }
.mk:hover, .mk.on { transform: scale(1.18); }
.mk.drag { cursor: grabbing; transform: scale(1.3); transition: none; }
.img-side { display: grid; gap: 14px; }
.img-sw { display: grid; gap: 4px; }
.img-sw div { display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 10px; transition: background .2s; }
.img-sw div.on { background: var(--bg3); }
.img-sw i { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.img-sw b { font-family: var(--mono); font-weight: 400; font-size: 12.5px; }
.img-sw span { color: var(--muted); font-size: 12px; font-family: var(--serif); font-style: italic; font-size: 15px; display: block; line-height: 1.1; }
.img-drop { padding: 70px 20px; }
.img-drop svg { width: 34px; height: 34px; fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.img-drop p { font-size: 13px; }

/* contrast */
.cv-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.cv-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 12px; }
.cv-row .mono { color: var(--muted); font-size: 10px; }
.cv-row .mono small { display: block; color: var(--faint); font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 11.5px; margin-top: 2px; }
.cv-row .strip { height: 38px; border-radius: 9px; }
.mx-wrap { overflow: auto; margin: 0 -4px; padding: 4px; }
.mx { border-collapse: separate; border-spacing: 4px; min-width: 100%; }
.mx th { font-weight: 400; }
.mx thead th i, .mx tbody th i { display: block; width: 100%; min-width: 46px; height: 26px; border-radius: 7px; }
.mx tbody th i { width: 26px; min-width: 26px; height: 100%; min-height: 54px; }
.mx td { border-radius: 9px; height: 58px; min-width: 58px; text-align: center; vertical-align: middle; position: relative; }
.mx td b { display: block; font-family: var(--serif); font-weight: 400; font-size: 20px; line-height: 1; }
.mx td span { display: block; font-family: var(--mono); font-size: 10px; margin-top: 3px; }
.mx td em { position: absolute; top: 5px; right: 6px; font-style: normal; font-family: var(--mono); font-size: 8px; letter-spacing: .06em; padding: 1px 4px; border-radius: 4px; background: rgba(0,0,0,.28); color: #fff; }
.mx td.fail { opacity: .3; }
.mx td.self { background: transparent !important; opacity: 1; }
.mx td.self::after { content: ""; position: absolute; inset: 50% 30%; height: 1px; background: var(--line2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend em { font-style: normal; font-family: var(--mono); font-size: 9px; padding: 1px 5px; border-radius: 4px; background: var(--bg3); color: var(--soft); margin-right: 5px; }

/* ---------- below the fold ---------- */
.pal-about { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; padding-top: 70px; padding-bottom: 40px; }
.ab .mono { color: var(--muted); }
.ab .mono i { font-style: normal; color: var(--accent); margin-right: 8px; }
.ab h2 { font-weight: 400; font-size: clamp(30px, 3vw, 42px); line-height: 1; margin: 14px 0 12px; letter-spacing: -.01em; }
.ab h2 em { color: var(--soft); }
.ab p { color: var(--muted); max-width: 360px; }

.cvd-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.pal-mbar { display: none; }

/* ---------- touch: always show tools ---------- */
@media (hover: none) {
  .tools button { opacity: .78; transform: none; }
  .az { display: none; }
}

/* ---------- mobile: rows ---------- */
@media (max-width: 760px) {
  .pal { --bar: 62px; height: calc(100svh - var(--hdr) - 76px - env(safe-area-inset-bottom)); min-height: 440px; }
  .pal-bar { padding-bottom: 10px; }
  .pal-id h1 { font-size: 28px; }
  .pal-ctl > :not(.harm) { display: none; }
  .harm select.inp { min-width: 0; font-size: 12.5px; padding: 7px 28px 7px 12px; }
  .pal-hints { display: none; }
  .cols { flex-direction: column; }
  .col { flex-direction: row; justify-content: space-between; align-items: center; padding: 0 10px 0 18px; }
  .meta { align-items: flex-start; flex: 1; min-width: 0; }
  .hex { --fs: 21px; font-size: 21px; padding: 4px 6px; margin-left: -6px; }
  .nm { font-size: 15px; padding: 0; margin-top: 0; }
  .tools { flex-direction: row-reverse; margin: 0; gap: 0; order: 2; }
  .tools button { width: 38px; height: 38px; opacity: .78; transform: none; }
  .tools svg { width: 18px; height: 18px; }
  .lockmark { display: none; }
  .adds { display: none; }
  .shades { flex-direction: row; }
  .shades button span { display: none; }
  .shades button.cur::before { left: 50%; top: auto; bottom: 10px; margin-left: -3px; }
  .pal-mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; gap: 6px; align-items: center; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: rgba(20, 19, 18,.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .mb { width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line2); color: var(--soft); transition: transform .25s var(--ease); }
  .mb:active { transform: scale(.94); }
  .mb[disabled] { opacity: .35; }
  .mb svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .mb.gen { flex: 1; width: auto; border-radius: 99px; display: flex; gap: 10px; justify-content: center; background: var(--accent); border-color: var(--accent); color: #141312; font-size: 15px; font-weight: 400; }
  .mb.gen svg { transition: transform .7s var(--ease); }
  .mb.gen.spin svg { transform: rotate(180deg); }
  .pal-about { grid-template-columns: 1fr; gap: 34px; padding-top: 50px; }
  .foot { padding-bottom: 110px; }
  .toast { bottom: 96px; }
  .img-grid { grid-template-columns: 1fr; }
  .pop { width: calc(100vw - 24px); }
  .cv-row { grid-template-columns: 1fr; gap: 6px; }
  .modal .box .body { padding: 16px; }
}

/* update 72 (brand guide v4): these buttons sit on whatever colours you pick, so the 2 px Paper ring gets a Carbon band behind it and shows on any swatch */
.tools button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px var(--bg); }
