:root {
  --ink: var(--tools-text); --muted: var(--tools-muted); --paper: var(--tools-bg);
  --surface: var(--tools-surface); --surface-soft: var(--tools-surface-soft);
  --line: var(--tools-line); --green: var(--tools-green); --green-dark: var(--tools-green-strong);
  --green-soft: var(--tools-green-soft);
  color: var(--ink); background: var(--paper); font-family: var(--tools-sans); font-synthesis: none;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: hidden; background: radial-gradient(circle at 50% 0, color-mix(in srgb, var(--green) 8%, transparent), transparent 32rem), var(--paper); }
button, input, select { font: inherit; } button { cursor: pointer; touch-action: manipulation; } button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; }
.visually-hidden { position: fixed; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.brand, .footer-home { display: inline-flex; align-items: center; gap: 11px; font-size: .95rem; font-weight: 750; text-decoration: none; }
.brand img { width: 42px; height: 42px; }
main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.hero { max-width: 850px; margin: 42px auto 34px; text-align: center; }
.eyebrow, .step-label { margin: 0 0 10px; color: var(--green-dark); font: 700 .72rem/1.3 var(--tools-mono); letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: 0; font: 500 clamp(2.7rem, 6vw, 4.8rem)/.98 var(--tools-serif); letter-spacing: -.055em; }
.hero-copy { max-width: 690px; margin: 20px auto 0; color: var(--muted); font-size: 1.04rem; line-height: 1.7; }
.workspace, .history-panel, .export-panel, .explanation-panel { border: 1px solid var(--line); border-radius: 24px; background: color-mix(in srgb, var(--surface) 95%, transparent); box-shadow: var(--tools-shadow); }
.workspace { overflow: hidden; }
.workspace-head { padding: 26px 28px 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.workspace h2, .history-panel h2, .export-panel h2 { margin: 0; font: 500 clamp(1.75rem, 3vw, 2.35rem)/1.05 var(--tools-serif); letter-spacing: -.035em; }
.workspace-head p:not(.step-label), .export-panel p:not(.step-label) { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.button { min-height: 46px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font-weight: 750; }
.button-primary { min-height: 52px; padding-inline: 19px; border-color: var(--tools-action); color: var(--tools-on-action); background: var(--tools-action); }
.button svg, .export-card svg, .swatch-actions svg, .count-control svg { width: 18px; height: 18px; display: block; stroke-width: 2; }
kbd { padding: 3px 7px; border: 1px solid rgb(255 255 255 / 35%); border-radius: 6px; background: rgb(0 0 0 / 12%); font-size: .7rem; }
.generator-control { margin: 0; padding: 18px 28px 20px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .38fr); align-items: end; gap: 12px 20px; border: 0; background: color-mix(in srgb, var(--surface) 74%, var(--surface-soft)); }
.generator-control > legend { width: 100%; margin: 0 0 2px; padding: 0; color: var(--ink); font-size: .77rem; font-weight: 800; }
.generator-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.generator-options label { min-height: 68px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.generator-options label.selected { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.generator-options input { width: 17px; height: 17px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--green); }
.generator-options strong, .generator-options small { display: block; }
.generator-options strong { font-size: .82rem; }
.generator-options small { margin-top: 4px; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.theory-select { display: grid; gap: 6px; }
.theory-select > span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.theory-select select { width: 100%; min-height: 46px; padding: 0 38px 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); }
.toolbar { min-height: 70px; padding: 10px 28px; display: flex; align-items: center; gap: 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.format-control { margin: 0; padding: 0; display: flex; align-items: center; gap: 10px; border: 0; }
.format-control legend { float: left; margin-right: 10px; color: var(--muted); font-size: .75rem; font-weight: 750; }
.format-control div { width: max-content; display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.format-control button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: .73rem; font-weight: 800; }
.format-control button.active { color: var(--green-dark); background: var(--green-soft); }
.count-control { display: flex; align-items: center; gap: 8px; }
.count-control button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface); }
.count-control > span { min-width: 65px; color: var(--muted); font-size: .75rem; text-align: center; }
.palette { min-height: 490px; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--color-count), minmax(0, 1fr)); list-style: none; scroll-margin-top: 4px; }
.swatch { min-width: 0; display: grid; grid-template-rows: minmax(310px, 1fr) auto; border-right: 1px solid rgb(0 0 0 / 12%); transition: opacity .15s; }
.swatch:last-child { border-right: 0; }
.swatch.dragging { z-index: 4; opacity: 0; transform: none; }
.swatch-color { position: relative; display: grid; place-items: center; background: var(--swatch); }
.swatch-color > input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.swatch-actions { position: relative; z-index: 1; display: flex; gap: 2px; pointer-events: none; }
.swatch-actions-inline { display: none; }
.swatch-actions button { width: 42px; min-width: 42px; height: 42px; min-height: 42px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 999px; color: var(--swatch-ink); background: transparent; opacity: 0; transform: translateY(5px); transition: opacity .18s, transform .18s, color .18s, background .18s; pointer-events: none; }
.swatch:hover .swatch-actions button, .swatch:focus-within .swatch-actions button { opacity: .62; transform: none; pointer-events: auto; }
.swatch-actions button:hover, .swatch-actions button:focus-visible { background: color-mix(in srgb, var(--swatch-ink) 10%, transparent); opacity: 1 !important; }
.swatch-actions button[aria-pressed="true"] { color: var(--swatch); background: var(--swatch-ink); opacity: 1; transform: none; pointer-events: auto; }
.swatch-actions button > span:last-child:not(:first-child) { display: none; }
.swatch-actions svg { width: 19px; height: 19px; }
.drag-handle { cursor: grab; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.dragging .drag-handle { cursor: grabbing; }
.is-reordering, .is-reordering * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.drag-ghost { position: fixed; z-index: 50; margin: 0; pointer-events: none; transform: translate3d(0, 0, 0); will-change: transform; }
.drag-ghost-preview { width: 100%; height: 100%; overflow: hidden; border: 0; border-radius: 12px; opacity: .78; box-shadow: 0 8px 22px rgb(0 0 0 / 14%); transform: scale(.985); transition: box-shadow .2s, opacity .16s, transform .2s cubic-bezier(.22, 1, .36, 1); pointer-events: none; backface-visibility: hidden; contain: layout paint; }
.drag-ghost.lifted .drag-ghost-preview { opacity: .96; box-shadow: 0 20px 50px rgb(0 0 0 / 25%); transform: scale(1.018) rotate(.18deg); }
.drag-ghost .swatch-actions { display: none !important; }
.drag-ghost.dropping { transition: transform .24s cubic-bezier(.22, 1, .36, 1), width .24s, height .24s; }
.drag-ghost.dropping .drag-ghost-preview { opacity: .82; box-shadow: 0 7px 18px rgb(0 0 0 / 12%); transform: scale(1); }
.swatch-info { min-height: 145px; padding: 18px 12px 12px; background: var(--surface); text-align: center; }
.swatch-info strong { min-height: 2.16em; display: flex; align-items: center; justify-content: center; overflow: hidden; overflow-wrap: anywhere; white-space: normal; font-family: var(--tools-serif); font-size: var(--swatch-name-size, .98rem); line-height: 1.08; }
.swatch-values { margin-top: 7px; display: grid; gap: 2px; }
.swatch-values label { display: block; }
.swatch-info input { width: 100%; min-height: 38px; padding: 0 4px; border: 1px solid transparent; border-radius: 7px; color: var(--muted); background: transparent; font: 700 var(--swatch-code-size, .76rem)/1 var(--tools-mono); text-align: center; text-transform: uppercase; }
.swatch-info input:hover, .swatch-info input:focus { border-color: var(--line); background: var(--surface-soft); }
.workspace-foot { min-height: 70px; padding: 10px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
.workspace-foot p { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .76rem; }
.workspace-foot svg { width: 18px; }
.workspace-foot-actions { display: flex; align-items: center; gap: 8px; }
.workspace-foot-actions .button { min-height: 44px; padding-inline: 13px; font-size: .76rem; }
.history-panel { margin-top: 24px; overflow: hidden; }
.history-heading { padding: 24px 28px 18px; display: flex; align-items: end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.history-heading p:not(.step-label) { margin: 7px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.history-heading > span { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.history-list { margin: 0; padding: 16px 18px 18px; display: flex; gap: 10px; overflow-x: auto; list-style: none; scrollbar-color: var(--line) transparent; }
.history-list li { flex: 0 0 156px; }
.history-list button { position: relative; width: 100%; min-height: 108px; padding: 8px; display: grid; grid-template-rows: 54px auto; gap: 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); text-align: left; }
.history-list button.current { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.history-colors { overflow: hidden; display: grid; grid-template-columns: repeat(var(--history-count), minmax(0, 1fr)); border-radius: 7px; }
.history-colors i { display: block; min-width: 0; }
.history-meta { min-width: 0; display: grid; grid-template-columns: 1fr; }
.history-meta strong, .history-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta strong { font-size: .73rem; }
.history-meta small { margin-top: 2px; color: var(--muted); font-size: .65rem; }
.current-label { position: absolute; top: 13px; right: 13px; padding: 3px 6px; border-radius: 999px; color: var(--tools-green-text); background: var(--green-soft); font-size: .58rem; font-weight: 800; }
.export-panel { margin-top: 24px; padding: clamp(26px, 4vw, 42px); display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.export-actions { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 10px; }
.export-card { min-height: 84px; padding: 14px 18px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface); text-align: left; }
.export-card > svg { width: 25px; height: 25px; color: var(--green-dark); }
.export-card strong, .export-card small { display: block; }
.export-card small { margin-top: 4px; color: var(--muted); line-height: 1.35; }
.explanation-panel { margin-top: 24px; padding: clamp(28px, 5vw, 52px); }
.explanation-heading { max-width: 780px; }
.explanation-heading h2 { margin: 0; font: 500 clamp(1.75rem, 3vw, 2.35rem)/1.05 var(--tools-serif); letter-spacing: -.035em; }
.explanation-heading > p:not(.step-label) { margin: 14px 0 0; color: var(--muted); line-height: 1.65; }
.explanation-points { margin-top: 30px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; }
.explanation-points article { padding-top: 18px; display: flex; gap: 13px; border-top: 1px solid var(--line); }
.explanation-points article > span { padding-top: 3px; color: var(--green-dark); font: 700 .7rem/1 var(--tools-mono); }
.explanation-points h3 { margin: 0; font-size: .9rem; }
.explanation-points p { margin: 7px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.trust-row { margin: 24px 0 54px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface) 78%, transparent); }
.trust-row article { padding: 22px; display: flex; gap: 13px; }
.trust-row article + article { border-left: 1px solid var(--line); }
.trust-row article > span { color: var(--green-dark); font: 700 .7rem/1 var(--tools-mono); }
.trust-row strong { font-size: .85rem; }
.trust-row p { margin: 5px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
footer { width: min(1240px, calc(100% - 40px)); min-height: 82px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.footer-home { color: var(--ink); }
.mobile-action-bar { display: none; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 10px; color: white; background: #171a18; box-shadow: var(--tools-shadow); transform: translateX(-50%); font-size: .8rem; font-weight: 750; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 65%, white); outline-offset: 3px; }
.button,
.count-control button,
.export-card,
.history-list button { transition: transform .16s cubic-bezier(.23, 1, .32, 1), border-color .16s cubic-bezier(.23, 1, .32, 1), background .16s cubic-bezier(.23, 1, .32, 1); }
.button:active:not(:disabled),
.count-control button:active:not(:disabled),
.export-card:active:not(:disabled),
.history-list button:active:not(:disabled) { transform: scale(.97); }
@media (max-width: 900px) {
  .palette { overflow-x: auto; grid-template-columns: repeat(var(--color-count), minmax(210px, 1fr)); }
  .swatch { min-width: 210px; }
  .export-panel { align-items: flex-start; flex-direction: column; }
  .export-actions { width: 100%; }
  .explanation-points { grid-template-columns: 1fr; gap: 18px; }
}
@media (max-width: 620px) {
  body { padding-bottom: calc(71px + env(safe-area-inset-bottom)); }
  main, footer { width: min(100% - 28px, 1240px); }
  .brand { gap: 8px; font-size: .82rem; }
  .brand img { width: 36px; height: 36px; }
  .hero { margin: 30px auto 22px; }
  .hero h1 { font-size: clamp(2.25rem, 11.5vw, 3.2rem); }
  .hero-copy { margin-top: 14px; font-size: .94rem; line-height: 1.55; }
  .workspace, .history-panel, .export-panel, .explanation-panel { border-radius: 18px; }
  .workspace { overflow: hidden; }
  .workspace-head { padding: 20px 18px 18px; align-items: stretch; flex-direction: column; }
  .generate-button { width: 100%; }
  .generator-control { padding: 18px; grid-template-columns: 1fr; }
  .generator-options { grid-template-columns: 1fr; }
  .toolbar { padding: 12px 18px; display: grid; grid-template-columns: 1fr auto; gap: 12px 16px; }
  .format-control { min-width: 0; display: grid; align-items: start; gap: 6px; }
  .format-control legend { float: none; margin: 0; }
  .format-control div { justify-self: start; }
  .count-control { align-self: end; }
  .count-control button { width: 42px; height: 42px; }
  .palette {
    width: 100%;
    height: max(calc(100vh - 71px - env(safe-area-inset-bottom)), var(--mobile-palette-min-height));
    height: max(calc(100svh - 71px - env(safe-area-inset-bottom)), var(--mobile-palette-min-height));
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(var(--color-count), minmax(var(--mobile-row-min), 1fr));
    overflow: visible;
  }
  .swatch {
    position: relative;
    min-width: 0;
    min-height: 104px;
    display: block;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--swatch-ink) 20%, transparent);
    background: var(--swatch);
  }
  .swatch:last-child { border-bottom: 0; }
  .swatch-color { position: absolute; inset: 0; min-height: 0; display: block; }
  .swatch-info {
    position: relative;
    z-index: 2;
    min-width: 0;
    min-height: 100%;
    height: 100%;
    padding: 12px 14px 12px 18px;
    display: grid;
    grid-template: "name actions" auto "value actions" auto / minmax(0, 1fr) auto;
    align-content: center;
    gap: 4px 14px;
    color: var(--swatch-ink);
    background: transparent;
    text-align: left;
    pointer-events: none;
  }
  .swatch-info strong {
    grid-area: name;
    align-self: end;
    min-width: 0;
    min-height: 0;
    display: block;
    justify-content: initial;
    overflow: visible;
    overflow-wrap: anywhere;
    white-space: normal;
    color: var(--swatch-ink);
    font-size: var(--swatch-name-size, .98rem);
    line-height: 1.08;
  }
  .swatch-values { grid-area: value; width: min(100%, 220px); margin: 0; align-self: start; display: grid; gap: 0; pointer-events: auto; }
  .swatch-info input {
    width: auto;
    max-width: 100%;
    min-height: 32px;
    padding: 0;
    border: 0;
    color: var(--swatch-ink);
    background: transparent;
    text-align: left;
  }
  .swatch-info input:hover, .swatch-info input:focus {
    padding-inline: 7px;
    border-color: color-mix(in srgb, var(--swatch-ink) 32%, transparent);
    color: var(--swatch-ink);
    background: color-mix(in srgb, var(--swatch-ink) 10%, transparent);
  }
  .swatch-actions-inline {
    grid-area: actions;
    width: auto;
    margin: 0;
    display: flex;
    align-self: center;
    gap: 0;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  .swatch-actions-inline button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    color: var(--swatch-ink);
    background: transparent;
    opacity: .62;
    transform: none;
    pointer-events: auto;
  }
  .swatch-actions-inline button[aria-pressed="true"] { color: var(--swatch); background: var(--swatch-ink); opacity: 1; }
  .swatch-actions-overlay { display: none; }
  .swatch-actions-inline svg { width: 18px; height: 18px; }
  .workspace-foot { padding: 14px 18px; align-items: stretch; flex-direction: column; }
  .workspace-foot > p { display: none; }
  .workspace-foot-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .workspace-foot-actions .button { width: 100%; }
  .history-heading { padding: 22px 18px 16px; align-items: flex-start; flex-direction: column; gap: 9px; }
  .history-list { padding-inline: 14px; }
  .export-actions { grid-template-columns: 1fr; }
  .explanation-panel { padding: 26px 20px; }
  .trust-row { grid-template-columns: 1fr; }
  .trust-row article + article { border-left: 0; border-top: 1px solid var(--line); }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 7px; }
  .mobile-action-bar { position: fixed; z-index: 18; inset: auto 0 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: block; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 -8px 24px rgb(0 0 0 / 10%); backdrop-filter: blur(14px); overscroll-behavior: contain; }
  .mobile-generate-button { width: 100%; min-height: 50px; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto; transition: none; } .drag-ghost-preview, .drag-ghost.lifted .drag-ghost-preview { transform: none; } }
