:root { color-scheme: dark; --ui: #111214; --border: #343639; --muted: #969aa0; --white: #f9f9f7; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--white); background: var(--ui); }
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .3; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#app { width: 100%; height: 100%; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { flex: none; min-height: 67px; padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--ui); }
.brand { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand strong { font-size: 19px; font-weight: 900; letter-spacing: -.075em; line-height: 1.1; }
.brand span { color: var(--muted); font: 700 10px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.header-actions .tool { flex: none; min-height: 42px; padding-inline: 13px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid transparent;
  border-radius: 11px; background: transparent; color: inherit; font-size: 25px; line-height: 1; }
.icon-button:not(:disabled):active, .tool:active { background: #343639; }
.generate, .primary { min-height: 44px; border: 0; padding: 0 12px; border-radius: 11px;
  background: var(--white); color: #0e0f11; font-size: 13px; font-weight: 800; }
.generate:active, .primary:active { transform: scale(.97); }
.shuffle-icon { font-size: 19px; margin-right: 3px; vertical-align: -1px; }
#palette { --columns: 5; --count: 5; flex: 1; min-height: 0; overflow: hidden; display: grid;
  grid-template-columns: 1fr; grid-template-rows: repeat(var(--count), minmax(0,1fr)); }
.swatch { --ink: #111; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: row;
  align-items: flex-end; justify-content: space-between; gap: 4px; padding: 5px 12px; color: var(--ink); background: var(--swatch);
  transition: background-color .2s ease; isolation: isolate; }
.swatch-label { display: flex; align-items: center; justify-content: flex-start; gap: 8px; min-width: 0; }
.swatch-number, .hex-button { font: 800 10px/1 ui-monospace, monospace; letter-spacing: .06em; opacity: .7; }
.hex-button { display: inline-flex; align-items: center; gap: 5px; min-height: 39px; padding: 0 3px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink); white-space: nowrap; }
.hex-button .copy-glyph { font: inherit; opacity: .65; }
.hex-button.copied { outline: 2px solid currentColor; outline-offset: -2px; }
.hex-button:active { transform: scale(.95); }
.swatch-actions { z-index: 1; align-self: flex-end; display: flex; gap: 0; }
.swatch-actions button { min-width: 39px; min-height: 39px; padding: 0 5px; border: 1px solid currentColor;
  border-color: color-mix(in srgb,currentColor 13%,transparent); border-radius: 9px;
  background: color-mix(in srgb,currentColor 5%,transparent); color: var(--ink);
  font-weight: 800; font-size: 16px; opacity: .58; }
.swatch-actions button:active, .swatch-actions button.active { border-color: color-mix(in srgb,currentColor 50%,transparent);
  background: color-mix(in srgb,currentColor 12%,transparent); opacity: .78; }
.swatch-actions button:disabled { opacity: .42; }
.swatch-actions .edit-button { font-size: 10px; letter-spacing: .035em; }
.swatch-label, .swatch-actions { opacity: 0; pointer-events: none; transition: opacity .24s ease; }
.swatch.revealed .swatch-label, .swatch.revealed .swatch-actions { opacity: 1; pointer-events: auto; }
#palette.dense .swatch { padding-block: 2px; }
#palette.dense .swatch-actions button { min-width: 29px; min-height: 29px; padding-inline: 3px; border-radius: 6px; }
#palette.dense .hex-button { min-height: 29px; }
#palette.dense .swatch-label { gap: 4px; }
.desktop-arrow { display: none; }
.bottom-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 7px;
  min-height: 66px; padding: 7px 12px max(7px, env(safe-area-inset-bottom)); background: var(--ui); }
.bottom-left, .bottom-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bottom-left .icon-button { width: 42px; height: 44px; }
.bottom-right .tool { flex: none; padding-inline: 12px; }
.tool { border: 1px solid var(--border); border-radius: 12px; color: var(--white); background: #202124;
  min-height: 46px; min-width: 0; flex: 1; padding: 0 8px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.tool.active { color: #111; background: #fff; border-color: #fff; }
#savedCount { opacity: .6; }
#shade { position: fixed; z-index: 8; inset: 0; background: #0009; }
#shade[hidden] { display: none; }
#panel { position: fixed; z-index: 9; left: 0; right: 0; bottom: 0; height: min(77dvh,800px); display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); border-radius: 19px 19px 0 0;
  background: #191a1d; border: 1px solid #424346; box-shadow: 0 -9px 50px #0008; pointer-events: none; }
#panel.open { transform: translateY(0); pointer-events: auto; }
.panel-header, .editor-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 18px 12px; }
.panel-header small, .editor-heading small { font: 750 10px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .12em; color: #999; }
h2 { margin: 3px 0 0; font-size: 25px; line-height: 1.1; letter-spacing: -.06em; }
#panelBody { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px max(20px, env(safe-area-inset-bottom)); }
.pane[hidden] { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 8px; font-size: 12px; font-weight: 700; }
select, .edit-hex input { width: 100%; min-height: 47px; color: white; background: #292b2e; border: 1px solid #45474a; border-radius: 10px; padding: 0 12px; }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E"); background-size: 13px; background-repeat: no-repeat; background-position: right 11px center; }
.count-control { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; font-size: 13px; font-weight: 800; }
.stepper { display: flex; align-items: center; gap: 2px; background: #292b2e; border: 1px solid #45474a; border-radius: 12px; overflow: hidden; }
.stepper button { height: 43px; width: 46px; background: transparent; color: white; border: 0; font-size: 22px; }
.stepper button:active { background: #444; }
.stepper output { min-width: 31px; text-align: center; font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: #3a3b3f; margin: 20px 0; }
.range-field { margin: 0 0 18px; }
.range-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 9px; font-size: 12px; font-weight: 750; }
.range-top output { color: #c2c3c6; font: 700 12px/1 ui-monospace, monospace; }
input[type=range] { display: block; width: 100%; height: 27px; margin: 0; padding: 0; appearance: none; background: transparent; cursor: pointer; touch-action: pan-x; }
input[type=range]::-webkit-slider-runnable-track { height: 13px; border-radius: 20px; background: #62666b; box-shadow: inset 0 1px 2px #0006; }
input[type=range]::-webkit-slider-thumb { appearance: none; margin-top: -6px; width: 25px; height: 25px; border: 3px solid #191a1d; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #999; }
input[type=range]::-moz-range-track { height: 13px; border-radius: 20px; background: #62666b; }
input[type=range]::-moz-range-thumb { width: 21px; height: 21px; border: 2px solid #191a1d; border-radius: 50%; background: #fff; }
#hue::-webkit-slider-runnable-track, #editH::-webkit-slider-runnable-track { background: linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red); }
#hue::-moz-range-track, #editH::-moz-range-track { background: linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red); }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 6px 0 16px; }
.secondary { min-height: 43px; border: 1px solid #55585c; border-radius: 11px; background: #26282b; color: white; padding: 0 13px; font-size: 12px; font-weight: 750; }
.secondary:active, .export-action:active { background: #3b3d41; }
.saved-heading { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 14px; font-size: 13px; font-weight: 750; }
.saved-heading small { color: var(--muted); font-size: 11px; font-weight: 500; }
.saved-item { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 10px 0; border-bottom: 1px solid #333; }
.saved-load { padding: 0; border: 0; background: transparent; text-align: left; color: inherit; }
.saved-strip, .export-preview { display: flex; overflow: hidden; border-radius: 8px; height: 48px; }
.saved-strip i, .export-preview i { flex: 1; min-width: 0; }
.saved-meta { display: block; color: #a5a7ab; margin-top: 5px; font: 650 10px/1.3 ui-monospace, monospace; }
.saved-delete { width: 44px; background: transparent; color: #ddd; border: 1px solid #444; border-radius: 10px; font-size: 21px; }
.empty { padding: 40px 10px; color: #aaa; text-align: center; font-size: 13px; }
.section-caption { margin: 10px 0 13px; color: #aeb0b4; font: 750 11px/1 ui-monospace, monospace; letter-spacing: .08em; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 26px; }
.export-action { min-height: 62px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #292b2e; color: white; border: 1px solid #45474a; border-radius: 11px; padding: 12px; font-size: 12px; font-weight: 750; text-align: left; }
.export-action span { font-size: 19px; color: #a4a8ad; }
.preview-caption { margin: 8px 0 10px; font-size: 12px; font-weight: 750; }
.export-preview { height: 115px; border: 1px solid #555; }
#editor { position: fixed; inset: auto 0 0; width: 100%; max-width: 500px; max-height: min(90dvh,820px);
  margin: auto auto 0; padding: 0; overflow-y: auto; background: #1c1d20; border: 1px solid #4a4b4e;
  border-radius: 19px 19px 0 0; color: white; box-shadow: 0 15px 60px #0009; }
#editor::backdrop { background: #000a; }
#editForm { padding: 0 18px max(20px, env(safe-area-inset-bottom)); }
.editor-heading { padding: 18px 0; }
#editPreview { display: grid; place-items: center; height: 90px; border-radius: 11px; margin-bottom: 14px; background: #5b8cef; }
#colorPicker { width: 50px; height: 50px; appearance: none; border: 2px solid #fff; border-radius: 50%; background: transparent; padding: 0; overflow: hidden; cursor: pointer; }
#colorPicker::-webkit-color-swatch-wrapper { padding: 0; }
#colorPicker::-webkit-color-swatch { border: 0; border-radius: 50%; }
.edit-hex { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; color: #aab0b5; font-size: 12px; font-weight: 800; }
.edit-hex input { font: 800 16px/1 ui-monospace, monospace; text-transform: uppercase; }
.edit-hex input.invalid { border-color: #ff7777; }
.editor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.editor-actions button { min-height: 50px; }
@media (min-width: 700px) {
  .topbar { padding: 12px 22px; min-height: 76px; }
  .brand strong { font-size: 23px; }
  #palette { grid-template-columns: repeat(var(--columns),minmax(0,1fr)); grid-template-rows: repeat(var(--rows),minmax(0,1fr)); }
  .swatch { padding: 18px 11px; flex-direction: column; justify-content: flex-end; align-items: stretch; }
  .swatch-label { align-self: flex-start; }
  .swatch-number, .hex-button { font-size: 12px; }
  .swatch-actions { align-self: center; flex-wrap: wrap; justify-content: center; }
  #palette.dense .swatch-actions button { min-width: 39px; min-height: 39px; padding-inline: 5px; }
  #palette.dense .hex-button { min-height: 39px; }
  .mobile-arrow { display: none; }
  .desktop-arrow { display: inline; }
  .bottom-bar { gap: 12px; min-height: 70px; padding-inline: 22px; }
  #panel { left: auto; top: 0; bottom: 0; right: 0; width: min(420px,40vw); height: 100dvh;
    border-radius: 0; border-top: 0; border-bottom: 0; transform: translateX(105%); }
  #panel.open { transform: translateX(0); }
  #editor { inset: 0; margin: auto; border-radius: 19px; max-height: 90dvh; }
}
@media (max-width: 360px) { .topbar { padding-inline: 9px; } .brand strong { font-size: 17px; }
  .header-actions .tool { padding-inline: 9px; }
  .bottom-bar { padding-inline: 5px; gap: 4px; }
  .bottom-left, .bottom-right { gap: 2px; }
  .bottom-left .icon-button { width: 42px; }
  .bottom-right .tool { padding-inline: 8px; }
  .generate { padding: 0 7px; font-size: 11px; }
  .shuffle-icon { font-size: 15px; margin-right: 1px; }
  .swatch { padding-inline: 9px; } .swatch-actions button { min-width: 35px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; } }
