:root {
  color-scheme: dark;
  --bg: #0c0e11;
  --panel: rgb(20, 22, 26);
  --surface: #1c1f25;
  --surface-2: #242830;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e6e8ec;
  --muted: #8b919c;
  --accent: #7aa2f7;
  --danger: #e5484d;
  --radius: 12px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --tp-bg: #16181d; --tp-surface: #1f2229; --tp-border: rgba(255,255,255,.09); --tp-accent: #7aa2f7;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--text); color: var(--bg); padding: 10px 14px;
  border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 12px; outline: 3px solid var(--accent); outline-offset: 2px; }
#panel-start:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dim { color: var(--muted); }
.mono { font-family: var(--mono); }
h2 { margin: 0; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ── Map ─────────────────────────────────────────────────────────────── */
.map { position: fixed; inset: 0; touch-action: none; cursor: grab; outline: none; }
.map:focus-visible::after { content: ""; position: absolute; inset: 3px; border: 3px solid var(--accent); border-radius: 6px; pointer-events: none; }
.map.dragging { cursor: grabbing; }
.map canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.frame { position: absolute; pointer-events: none; border: 1.5px solid rgba(255, 255, 255, .75); border-radius: 2px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .38); }
.frame-handle { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .85); background: rgba(12, 14, 17, .5); cursor: grab; pointer-events: auto; touch-action: none; }
.frame-handle:active { cursor: grabbing; }
.frame-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.status-strip { position: fixed; left: 50%; top: 78px; transform: translateX(-50%); z-index: 8; color: var(--muted); font: 11px var(--mono);
  white-space: nowrap; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.status-strip:empty { display: none; }
.map-loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px; font-size: 12.5px; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 30; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.map-error { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 420px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); z-index: 5; }

.floating { position: fixed; z-index: 10; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
 }

/* ── Top bar: logo, search, wallpaper/contour controls, all in one row ── */
/* Its own stacking context, above the panel/zoom/scale/footer (all z-index
   10 via .floating): position+z-index traps descendants in the ancestor's
   stacking context regardless of their own z-index, so without this, the
   search results and "more contour settings" popovers — both nested inside
   the topbar — could never paint above the panel next to them. */
.topbar { left: 14px; right: 14px; top: 14px; height: 56px; z-index: 15; display: flex; align-items: center; gap: 10px; padding: 0 8px 0 10px; overflow: visible; }
.brand { display: inline-flex; align-items: center; gap: 7px; flex: none; color: var(--text); font-weight: 650; font-size: 13.5px; }
.brand:hover { text-decoration: none; }
.wordmark { display: inline-block; }
.logo { width: 18px; height: 18px; border-radius: 5px; flex: none; background:
  repeating-radial-gradient(circle at 30% 70%, transparent 0 2px, #7aa2f7 2px 3px); box-shadow: inset 0 0 0 1px var(--border); }
.search-wrap { position: relative; flex: 1 1 320px; min-width: 120px; max-width: 320px; }
#search-form { display: flex; min-width: 0; }
#search { width: 100%; min-width: 0; background: var(--surface); border: 1px solid rgba(255, 255, 255, .16); border-radius: 8px; padding: 0 10px;
  font-size: 13.5px; height: 32px; }
#search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#search::placeholder { color: var(--muted); }
#search-go { position: absolute; right: 2px; top: 1px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.icon-btn svg { width: 18px; height: 18px; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; list-style: none; margin: 0; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: min(420px, 60vh); overflow: auto; }
.results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: grid; gap: 1px; }
.results li[aria-selected="true"], .results li:hover { background: var(--surface-2); }
.results .r-name { font-weight: 550; }
.results .r-detail { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-note { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; color: var(--muted); font-size: 12px; }
.results-note:not(:empty) { padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Wallpaper/contour controls, inline in the top bar ──────────────────── */
.tb-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.tb-field { position: relative; display: flex; align-items: center; gap: 5px; min-height: 30px; }
.tb-label { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.tb-field select { width: auto; min-width: 0; height: 30px; padding: 0 6px; font-size: 12.5px; }
.tb-field input[type="number"] { height: 30px; min-height: 0; padding: 0 6px; }
.tb-field input[type="range"] { width: 62px; height: 30px; }
.tb-field .value-edit input { width: 44px; }
.tb-field .stepper input { height: 30px; min-height: 0; width: 38px; }
.tb-field .stepper .btn.small { min-width: 24px; padding: 4px 6px; }
.tb-field .btn.small { min-height: 30px; }
.tb-field:hover .tooltip, .tb-field:focus-within .tooltip { opacity: 1; visibility: visible; }
.btn.toggle[aria-pressed="true"] { background: var(--accent); color: #0c0e11; border-color: transparent; }
.tooltip { position: absolute; left: 0; top: calc(100% + 8px); z-index: 25; width: max-content; max-width: 240px;
  background: #0a0b0e; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  font-size: 12px; line-height: 1.4; box-shadow: var(--shadow); opacity: 0; visibility: hidden; transition: opacity .1s; pointer-events: none; }
#interval-field.locked input[type="range"], #interval-field.locked input[type="number"] { opacity: .45; pointer-events: none; }
#custom-size.popover-body { top: calc(100% + 6px); left: 0; display: flex; align-items: center; gap: 6px; width: max-content; padding: 10px 12px; }
#custom-size input[type="number"] { width: 68px; }
#contours-popover.popover-body { right: 0; left: auto; top: calc(100% + 8px); width: 220px; }
/* Inside the popover there's no need to mimic the topbar's cramped single
   row — label above control, full width, like the sidebar's own fields. */
#contours-popover .tb-field { flex-direction: column; align-items: stretch; gap: 5px; min-height: 0; }
#contours-popover .tb-field select,
#contours-popover .tb-field input[type="range"],
#contours-popover .tb-field .stepper { width: 100%; }
#contours-popover .tb-field .value-edit { justify-content: flex-end; }
#hide-ui-btn { flex: none; }

/* ── Zoom stack, scale + coordinates ─────────────────────────────────── */
/* Zoom lives bottom-right of the canvas, out of the way of the search bar,
   the panel and the wallpaper selection; drag-to-pan and the arrow keys
   cover panning, so there's no directional pad to take up space. */
.zoomstack { right: 348px; bottom: 46px; width: 36px; display: grid; overflow: hidden; }
.zoomstack button { width: 36px; height: 27px; border: 0; border-top: 1px solid var(--border); background: transparent; cursor: pointer;
  font-size: 15px; color: var(--text); display: grid; place-items: center; }
.zoomstack button:first-child { border-top: 0; }
.zoomstack button:hover { background: var(--surface-2); }
.zoomstack button:focus-visible { outline-offset: -3px; }
.zoomstack svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* A small pan pad next to the zoom stack — same compact card look, just a
   plus-shaped cross of 4 buttons (no diagonals, no empty filler corners). */
.pad-mini { right: 394px; bottom: 46px; width: 84px; height: 83px; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); overflow: hidden; }
.pad-mini button { border: 0; background: transparent; cursor: pointer; color: var(--text); display: grid; place-items: center; }
.pad-mini button:hover { background: var(--surface-2); }
.pad-mini button:focus-visible { outline-offset: -3px; }
.pad-mini svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pad-up { grid-column: 2; grid-row: 1; border-bottom: 1px solid var(--border); }
.pad-left { grid-column: 1; grid-row: 2; border-right: 1px solid var(--border); }
.pad-right { grid-column: 3; grid-row: 2; border-left: 1px solid var(--border); }
.pad-down { grid-column: 2; grid-row: 3; border-top: 1px solid var(--border); }

.scalebar { position: fixed; left: 14px; bottom: 46px; z-index: 10; display: flex; align-items: center; gap: 10px; height: 24px; padding: 0 10px;
  background: rgba(12, 14, 17, .55); border-radius: 999px; font: 11px var(--mono); color: var(--text); }
.scale { display: flex; align-items: center; gap: 6px; }
.scale-bar { height: 5px; width: 0; border: 1.5px solid var(--text); border-top: 0; }
#cursor { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 4px; }
#cursor:hover, #cursor:focus-visible { color: var(--accent); }
#cursor:empty { display: none; }
.bottom-bar { left: 0; right: 0; bottom: 0; padding: 5px 14px; font-size: 11.5px; color: #a3a9b3; background: rgb(12, 14, 17);
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.attribution { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.attribution a, .sources-inline a { color: #c3c8d0; text-decoration: underline; text-underline-offset: 2px; display: inline-block; padding: 4px 0; }
.attribution a:hover, .sources-inline a:hover { color: var(--text); }

.sources-inline { display: contents; }
.sources-inline .more { position: relative; margin: 0; }
.sources-inline .more > summary { color: #a3a9b3; font-size: 11.5px; text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer; list-style: none; padding: 4px 0; white-space: nowrap; }
.sources-inline .more > summary::-webkit-details-marker { display: none; }
.sources-inline .more > summary::before { content: none; }
.sources-inline .more > summary:hover { color: var(--text); }
.sources-inline .more[open] > summary { color: var(--text); }
.popover-body {
  position: absolute; z-index: 20; max-height: 70vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; gap: 10px; font-size: 13px; color: var(--text);
}
.sources-inline .more .popover-body { bottom: calc(100% + 10px); left: 0; width: max-content; max-width: min(380px, calc(100vw - 40px)); }
.banner { left: 50%; top: 14px; transform: translateX(-50%); padding: 7px 8px 7px 14px; display: flex; gap: 10px; align-items: center; }

/* ── Side panel ──────────────────────────────────────────────────────── */
/* No backdrop-filter here: it would make the color picker's fixed popover clip inside the panel. */
.panel { right: 14px; top: 78px; bottom: 46px; width: 320px; display: flex; flex-direction: column; overflow: hidden;
  backdrop-filter: none; background: rgb(20, 22, 26); }
.panel-scroll { overflow-y: auto; overflow-x: hidden; flex: 1; }
.panel-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 14px; border: 0;
  background: transparent; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text); flex: none; }
.panel-toggle:hover { background: var(--surface-2); }
.panel:not(.collapsed) .panel-toggle { border-bottom: 1px solid var(--border); }
.panel-toggle span[aria-hidden] { transition: transform .12s; }
.panel.collapsed .panel-toggle span[aria-hidden] { transform: rotate(-90deg); }
.panel.collapsed .panel-scroll, .panel.collapsed .panel-actions { display: none; }
.panel-actions { flex: none; display: grid; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); background: rgb(20, 22, 26); }
.group { padding: 14px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.group:last-child { border-bottom: 0; }
.collapsible { display: grid; gap: 0; }
.collapsible > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; padding: 4px 0;
  font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary::before { content: "▸"; font-size: 10px; transition: transform .12s; flex: none; }
.collapsible[open] > summary::before { transform: rotate(90deg); }
.collapsible[open] > summary { margin-bottom: 8px; }
.collapsible-body { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.spread { justify-content: space-between; }
.field { display: grid; gap: 6px; }
.hint { color: var(--muted); font-size: 11.5px; }
.hint.error { color: #ff8a8e; }

.btn { font: 500 12.5px system-ui, sans-serif; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: rgba(255, 255, 255, .22); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 9px; min-width: 28px; min-height: 28px; }
.btn.primary { background: var(--accent); color: #0c0e11; border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wide { width: 100%; }
.btn[aria-pressed="true"] { background: var(--accent); color: #0c0e11; border-color: transparent; }

select, input[type="number"], input[type="text"], input[type="url"] {
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .38); border-radius: 8px; padding: 6px 8px; min-width: 0; min-height: 30px; }
select:focus, input[type="number"]:focus, input[type="text"]:focus, input[type="url"]:focus { border-color: var(--accent); }
select { width: 100%; }
input[type="number"] { font: 12px var(--mono); }
input[type="range"] { accent-color: var(--accent); width: 100%; margin: 0; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid rgba(255, 255, 255, .38); border-radius: 8px; padding: 2px; }
.segmented button { border: 1px solid transparent; background: none; color: #a3a9b3; border-radius: 6px; padding: 4px 8px; min-height: 28px; cursor: pointer; font-size: 12.5px; }
.segmented button[aria-checked="true"] { background: #3a4150; color: var(--text); border-color: rgba(255, 255, 255, .5); font-weight: 600; }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); cursor: pointer; }
.value-edit { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.value-edit input { width: 70px; text-align: right; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper input { width: 50px; text-align: center; }

.segmented.small button { padding: 3px 7px; font-size: 12px; min-height: 28px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.swatch { position: relative; aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .14); cursor: pointer; padding: 0; }
.swatch:hover { transform: scale(1.08); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.swatches.removing .swatch::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 16px;
  color: #fff; background: rgba(0, 0, 0, .45); border-radius: 5px; }
.swatches .empty-note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
#mine-name { flex: 1; margin-left: 8px; }
/* A dashed divider (not just a gap) and a visible caption mark this off from
   the swatches grid above it: it's the "pick a new color" control, not one
   more already-in-the-scheme swatch. */
#swatch-edit-row { flex-wrap: wrap; row-gap: 10px; margin-top: 2px; padding-top: 12px; border-top: 1px dashed var(--border); }
#swatch-edit-row > span.row { flex-wrap: wrap; }
.add-color-field { display: inline-flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.add-color-field > .dim { font-size: 10.5px; }
.scheme-card .delete { float: right; }
.colors-detail { border-top: 1px solid var(--border); padding-top: 10px; }
.sub-heading { margin: 0; font-size: 12px; font-weight: 650; color: var(--text); }
.scheme-button { display: grid; gap: 7px; width: 100%; text-align: left; padding: 8px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; }
.scheme-button:hover { border-color: rgba(255, 255, 255, .22); }
.scheme-button .name { font-weight: 600; }
.strip { display: grid; grid-template-columns: repeat(16, 1fr); height: 8px; border-radius: 3px; overflow: hidden; }
.strip.small { height: 6px; border-radius: 0; }

details.more > summary { cursor: pointer; color: #a3a9b3; font-size: 12px; list-style: none; display: flex; align-items: center; gap: 6px; min-height: 28px; border-radius: 6px; }
details.more > summary::before { content: "▸"; font-size: 10px; transition: transform .12s; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 10px; }
.tier { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tier-title { font-weight: 600; font-size: 12px; margin: 0; }
.stop { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.stop .at { width: 72px; font: 12px var(--mono); }
.slider-row { display: grid; grid-template-columns: 64px 1fr 58px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.slider-row output { font: 12px var(--mono); color: var(--text); text-align: right; }
.slider-row label { color: var(--muted); }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.sources { display: grid; gap: 4px; font-size: 12px; }
.source-line { display: grid; grid-template-columns: 70px 1fr; gap: 8px; }
.source-line b { font-weight: 550; color: var(--muted); }
.sources a, .privacy a { text-decoration: underline; text-underline-offset: 2px; display: inline-block; padding: 4px 0; }
.custom-source { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.privacy { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; display: grid; gap: 4px; }

.code { margin: 0; padding: 10px 12px; background: #0a0b0e; border: 1px solid var(--border); border-radius: 8px;
  font: 11.5px/1.5 var(--mono); color: #c9ced6; white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; }

/* ── Dialogs ─────────────────────────────────────────────────────────── */
dialog { color: var(--text); background: #14161a; border: 1px solid var(--border); border-radius: 16px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h3 { margin: 0; font-size: 15px; flex: 1; }

#schemes { width: min(1180px, calc(100vw - 32px)); height: min(860px, calc(100vh - 32px)); }
#schemes[open] { display: flex; flex-direction: column; }
.scheme-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dialog-head h2 { margin: 0; font-size: 15px; flex: 1; letter-spacing: normal; text-transform: none; color: var(--text); font-weight: 650; }
.scheme-controls { display: grid; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.scheme-controls .row { flex-wrap: wrap; }
#scheme-search { flex: 1; min-width: 180px; }
.tabs { display: inline-flex; gap: 4px; }
.tag-groups { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.tag-group { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; color: #a3a9b3; background: transparent; border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px; padding: 2px 10px;
  min-height: 28px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, .22); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--text); border-color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-red { background: #e06c6c; } .dot-orange { background: #e5a050; } .dot-yellow { background: #dccb62; }
.dot-green { background: #7fbf6a; } .dot-cyan { background: #5cc3c8; } .dot-blue { background: #6f9ce8; }
.dot-purple { background: #a98be0; } .dot-pink { background: #e088b8; } .dot-gray { background: #9aa0a8; }
.scheme-grid { flex: 1; overflow-y: auto; padding: 14px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: max-content; gap: 12px; align-content: start; }
.scheme-card { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0; overflow: hidden; cursor: pointer; }
.scheme-card:hover { border-color: var(--accent); }
.scheme-card:focus-visible { border-color: var(--accent); outline: 3px solid var(--accent); outline-offset: 2px; }
.scheme-card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.scheme-card canvas { display: block; width: 100%; aspect-ratio: 16 / 10; background: #0a0b0e; }
.scheme-card .meta { padding: 7px 9px 9px; display: grid; gap: 1px; }
.scheme-card .name { font: 12.5px var(--mono); }
.scheme-card .title, .scheme-card .tags { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 30px; text-align: center; grid-column: 1 / -1; }

#export { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
#export[open] { display: flex; flex-direction: column; }
.export-body { overflow: auto; padding: 16px; display: grid; gap: 14px; }
.export-preview { display: grid; place-items: center; min-height: 200px; background:
  repeating-conic-gradient(#111317 0 25%, #0e1013 0 50%) 0 0 / 24px 24px; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.export-preview img { display: block; max-width: 100%; max-height: 52vh; }
.export-status { margin: 0; color: var(--muted); text-align: center; }
.export-status:empty { display: none; }

#shortcuts { width: min(420px, calc(100vw - 32px)); }
.shortcuts-body { padding: 12px 16px 16px; display: grid; gap: 10px; }
.shortcut-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.shortcut-row span { color: var(--muted); }
kbd { font: 11.5px var(--mono); background: var(--surface); border: 1px solid rgba(255, 255, 255, .3); border-bottom-width: 2px;
  border-radius: 5px; padding: 2px 6px; color: var(--text); }

/* Hide-UI mode (H key or the eye button): fade all panel chrome for an
   unobstructed preview. Map, wallpaper frame and its handle stay put and
   interactive so panning/zooming and dragging the frame still work. The
   hide-UI button itself always stays put and clickable — it's the only way
   back, so it can never be one of the things that fades away. */
body.ui-hidden .status-strip, body.ui-hidden .panel, body.ui-hidden .pad-mini,
body.ui-hidden .zoomstack, body.ui-hidden .scalebar, body.ui-hidden .bottom-bar, body.ui-hidden .frame-handle,
body.ui-hidden .topbar > *:not(#hide-ui-btn) {
  opacity: 0; pointer-events: none; transition: opacity .15s; }
body.ui-hidden .topbar { background: transparent; border-color: transparent; box-shadow: none; }
body.ui-hidden .frame { box-shadow: none; }
body:not(.ui-hidden) .topbar, body:not(.ui-hidden) .status-strip, body:not(.ui-hidden) .panel, body:not(.ui-hidden) .pad-mini,
body:not(.ui-hidden) .zoomstack, body:not(.ui-hidden) .scalebar, body:not(.ui-hidden) .bottom-bar,
body:not(.ui-hidden) .topbar > * {
  transition: opacity .15s, background .15s, border-color .15s, box-shadow .15s; }
#hide-ui-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }

.toast { position: fixed; bottom: 42px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid rgba(255, 255, 255, .3);
  padding: 4px 4px 4px 14px; border-radius: 9px; box-shadow: var(--shadow); font-size: 12.5px; z-index: 50; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 8px; }
.toast-close { width: 30px; height: 30px; }
.toast-close svg { width: 14px; height: 14px; }
.toast.error { border-color: var(--danger); }
.drop-hint { position: fixed; inset: 12px; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 16px;
  background: rgba(12, 14, 17, .8); font-size: 16px; pointer-events: none; z-index: 40; }

/* ── Small screens: the panel becomes a bottom sheet, the top bar shows
   only search + create (everything else moves into the contours popover,
   via JS — see layoutTopbar in app.js) ──────────────────────────────── */
@media (max-width: 760px) {
  .panel { left: 8px; right: 8px; top: auto; bottom: 14px; width: auto; max-height: 82vh; }
  .topbar { left: 8px; right: 8px; padding: 0 4px 0 8px; gap: 5px; }
  .wordmark { display: none; }
  .search-wrap { flex: 1 1 auto; max-width: none; }
  .status-strip { display: none; }
  .zoomstack { top: 82px; bottom: auto; right: 12px; }
  .pad-mini { top: 82px; bottom: auto; right: 58px; }
  .scalebar { display: none; }
  /* The pan/zoom cluster lives top-right below the bar; open the "more
     contour settings" popover from the left instead so the two never
     fight over the same corner. */
  #contours-popover.popover-body { left: 8px; right: auto; width: min(220px, calc(100vw - 16px)); }

  /* The attribution/sources footer moves into the drawer (see layoutFooter
     in app.js) instead of sitting as its own fixed bar: there's no room for
     a persistent footer on a phone, and it belongs with the other settings
     anyway. #h-sources loses its sr-only treatment here so it reads as a
     normal section heading, matching WALLPAPER/COLORS above it. */
  #bottom-bar.docked {
    position: static; z-index: auto; background: transparent; display: block;
    padding: 14px 16px 4px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 12px;
  }
  #bottom-bar.docked .attribution { flex-wrap: wrap; padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
  #bottom-bar.docked .sources-inline { display: block; }
  #bottom-bar.docked #h-sources { margin-bottom: 8px; }
  #bottom-bar.docked .sources-inline .more { position: static; margin-bottom: 6px; }
  #bottom-bar.docked .sources-inline .more > summary { text-decoration: none; }
  #bottom-bar.docked .sources-inline .more .popover-body {
    position: static; width: auto; max-width: none; box-shadow: none; border: 0; background: transparent; padding: 8px 0 4px; margin: 0;
  }
}

@media (max-width: 400px) {
  .hide-compact { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Windows high contrast and other forced-color modes: keep state and boundaries visible. */
@media (forced-colors: active) {
  .card, .segmented, .chip, .swatch, .scheme-card, .btn, select, input { border: 1px solid CanvasText; }
  .segmented button[aria-checked="true"], .chip[aria-pressed="true"], .btn[aria-pressed="true"] { border: 2px solid Highlight; }
  .swatch { forced-color-adjust: none; }
  .swatch[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: 2px; }
  .scheme-card[aria-current="true"] { outline: 3px solid Highlight; }
  .frame { border-color: CanvasText; }
}
