/* ============================================================
   Theme gallery + colour swatches (js/theme-picker.js, js/appearance-settings.js).
   Settings → Appearance and Workspace settings → Theme.
   Cards are small pictures of the app; their colours come in as --p-* custom
   properties from js/themes.js, so a card shows exactly what the theme paints.
   ============================================================ */

/* ---------- gallery ---------- */
.pw-tp {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 12px;
    max-width: 960px;
}
.pw-tp-compact { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 10px; max-width: none; }

.pw-tp-card {
    position: relative;
    border-radius: var(--sl-r-12);
    background: var(--sl-card);
    border: 1px solid var(--sl-hairline);
    padding: 6px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.pw-tp-card:hover { border-color: var(--sl-border-strong); }
.pw-tp-card.is-selected {
    border-color: var(--sl-accent);
    box-shadow: 0 0 0 1px var(--sl-accent);
}
.pw-tp.is-disabled .pw-tp-card { opacity: 0.6; }
.pw-tp.is-disabled .pw-tp-card:hover { border-color: var(--sl-hairline); }

.pw-tp-pick {
    display: block; width: 100%; padding: 0; margin: 0;
    background: none; border: none; color: inherit; text-align: left;
    font: inherit; cursor: pointer; border-radius: 8px;
}
.pw-tp.is-disabled .pw-tp-pick { cursor: default; }
.pw-tp-pick:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 3px; }

.pw-tp-foot {
    display: flex; flex-direction: column; gap: 1px; min-width: 0;
    padding: 7px 62px 1px 4px;
}
.pw-tp-name {
    font-family: var(--sl-font-ui); font-size: 12.5px; font-weight: 600; color: var(--sl-text-1);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pw-tp-sub {
    font-family: var(--sl-font-ui); font-size: 11.5px; color: var(--sl-text-3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pw-tp-card.is-lead .pw-tp-foot { padding-right: 4px; }

/* variant dots: the variant's page colour with its accent in the middle */
.pw-tp-variants {
    position: absolute; right: 10px; bottom: 15px;
    display: flex; gap: 6px;
}
.pw-tp-dot {
    width: 16px; height: 16px; padding: 0; border-radius: 50%; cursor: pointer;
    border: 1px solid var(--sl-border);
    background: radial-gradient(circle at center, var(--d-ac) 0 3.5px, var(--d-bg) 4.5px);
    transition: transform 0.1s ease;
}
.pw-tp-dot:hover { transform: scale(1.15); }
.pw-tp-dot.is-on { box-shadow: 0 0 0 2px var(--sl-card), 0 0 0 3px var(--sl-text-3); }
.pw-tp-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--sl-card), 0 0 0 3.5px var(--sl-accent); }
.pw-tp-dot:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.pw-tp-dot:disabled { cursor: default; transform: none; }

/* ---------- the picture ---------- */
.pw-tp-shot {
    position: relative; overflow: hidden;
    aspect-ratio: 16 / 10; border-radius: 8px;
    background: var(--p-app);
    box-shadow: inset 0 0 0 1px var(--p-hairline);
    font-size: 0;
}
.pw-tp-shot > * { position: absolute; }
.pw-tp-rail {
    left: 0; top: 0; bottom: 0; width: 21%;
    background: var(--p-panel);
    border-right: 1px solid var(--p-hairline);
}
.pw-tp-rail > span { position: absolute; left: 14%; right: 14%; border-radius: 2px; }
.pw-tp-new { top: 9%; height: 9%; background: var(--p-accent); }
.pw-tp-ico { height: 5%; background: var(--p-text3); opacity: 0.55; }
.pw-tp-ico:nth-child(2) { top: 27%; }
.pw-tp-ico:nth-child(3) { top: 37%; left: 8% !important; right: 8% !important; height: 10%; background: var(--p-selected); opacity: 1; }
.pw-tp-ico:nth-child(4) { top: 52%; }
.pw-tp-ico:nth-child(5) { top: 62%; right: 30% !important; }
.pw-tp-main { left: 21%; right: 0; top: 0; bottom: 0; }
.pw-tp-main > * { position: absolute; left: 0; right: 0; }
.pw-tp-bar {
    top: 0; height: 15%;
    background: var(--p-app);
    border-bottom: 1px solid var(--p-hairline);
}
.pw-tp-title { position: absolute; left: 7%; top: 40%; width: 26%; height: 22%; border-radius: 2px; background: var(--p-text2); opacity: 0.8; }
.pw-tp-seg { position: absolute; right: 6%; top: 24%; width: 24%; height: 52%; border-radius: 3px; background: var(--p-control); }
.pw-tp-field {
    top: 15%; bottom: 0;
    background-color: var(--p-field);
    background-image: linear-gradient(var(--p-grid) 1px, transparent 1px), linear-gradient(90deg, var(--p-grid) 1px, transparent 1px);
    background-size: 12px 12px;
}
.pw-tp-field > * { position: absolute; }
.pw-tp-node {
    left: 7%; top: 13%; width: 47%; height: 72%;
    background: var(--p-card);
    border: 1px solid var(--p-border);
    border-radius: 5px;
    box-shadow: 0 3px 8px -4px rgba(0, 0, 0, 0.35);
}
.pw-tp-node > span { position: absolute; left: 10%; border-radius: 2px; }
.pw-tp-node-head { top: 10%; width: 52%; height: 8%; background: var(--p-text1); }
.pw-tp-line { top: 28%; width: 76%; height: 6%; background: var(--p-text3); opacity: 0.7; }
.pw-tp-line.is-short { top: 41%; width: 50%; }
.pw-tp-btn { left: 10% !important; right: 10%; bottom: 10%; height: 17%; background: var(--p-accent); border-radius: 3px !important; }
.pw-tp-node.is-small { left: 67%; top: 22%; width: 27%; height: 40%; }
.pw-tp-node.is-small .pw-tp-node-head { top: 16%; width: 62%; height: 13%; }
.pw-tp-node.is-small .pw-tp-line.is-short { top: 46%; width: 70%; height: 10%; }
.pw-tp-wire { left: 54%; width: 13%; top: 33%; height: 2px; border-radius: 1px; background: var(--p-accent); }
.pw-tp-wire.is-2 { top: 51%; background: var(--p-wire2); opacity: 0.9; }

/* "Each person's own": four themes side by side */
.pw-tp-mix { display: flex; }
.pw-tp-mix > * { position: relative; }
.pw-tp-mix-col { flex: 1; height: 100%; background: var(--p-app); }
.pw-tp-mix-card {
    position: absolute; left: 16%; right: 16%; top: 24%; height: 40%;
    border-radius: 4px; background: var(--p-card); box-shadow: inset 0 0 0 1px var(--p-border);
}
.pw-tp-mix-dot { position: absolute; left: 50%; top: 74%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--p-accent); }

/* ---------- colour swatches ---------- */
.pw-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pw-swatch {
    position: relative; flex: none;
    width: 26px; height: 26px; padding: 0; border-radius: 50%; cursor: pointer;
    background: var(--sw, var(--sl-control));
    border: 1px solid color-mix(in oklab, var(--sl-ink) 18%, transparent);
    box-sizing: border-box;
    transition: transform 0.1s ease;
}
.pw-swatch:hover { transform: scale(1.08); }
.pw-swatch.is-selected { box-shadow: 0 0 0 2px var(--sl-app), 0 0 0 4px var(--sl-text-1); }
.pw-swatch:focus-visible, .pw-swatch:focus-within { outline: 2px solid var(--sl-focus); outline-offset: 3px; }
.pw-swatch input[type="color"] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; border: 0; padding: 0;
}
/* any colour: a colour wheel until one is chosen, then that colour inside the wheel */
.pw-swatch-custom {
    background: conic-gradient(from 0deg, #ef4444, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444);
    border: none;
}
.pw-swatch-custom::after {
    content: ''; position: absolute; inset: 5px; border-radius: 50%;
    background: var(--sl-app);
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--sl-ink) 14%, transparent);
}
.pw-swatch-custom.has-color::after { background: var(--sw); }
.pw-swatch-custom::before {
    content: '+'; position: absolute; inset: 0; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    font: 600 14px/1 var(--sl-font-ui); color: var(--sl-text-2); pointer-events: none;
}
.pw-swatch-custom.has-color::before { content: none; }
/* wires: square-ish so they read as lines' colours, not as the accent row */
.pw-swatch-wire { border-radius: var(--sl-r-6); }
.pw-swatch-wire.is-selected { box-shadow: none; }

/* "Theme": the theme's own colour, as a quiet pill */
.pw-swatch-auto {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    height: 26px; padding: 0 10px 0 5px; border-radius: 13px; cursor: pointer;
    background: var(--sl-quiet); border: 1px solid var(--sl-hairline);
    color: var(--sl-text-2); font-family: var(--sl-font-ui); font-size: 12px; font-weight: 600;
    box-sizing: border-box;
}
.pw-swatch-auto:hover { background: var(--sl-quiet-hover); color: var(--sl-text-1); }
.pw-swatch-auto.is-selected {
    background: var(--sl-selected); color: var(--sl-text-1);
    border-color: var(--sl-text-2);
}
.pw-swatch-auto:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 3px; }
.pw-swatch-auto-dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--sl-ink) 18%, transparent); }

/* ---------- Settings → Appearance layout ---------- */
:is(#settings-overlay, #home-settings-container) .pw-wire-row { gap: 8px; align-items: center; flex-wrap: wrap; }
:is(#settings-overlay, #home-settings-container) .pw-wire-row > .pw-swatches { margin-right: 4px; }
:is(#settings-overlay, #home-settings-container) .pw-icon-btn { width: var(--sl-h); padding: 0; }
:is(#settings-overlay, #home-settings-container) .setting-chip-row .setting-chip { display: inline-flex; align-items: center; gap: 6px; }
:is(#settings-overlay, #home-settings-container) .setting-chip-row .setting-chip svg { flex: none; opacity: 0.85; }
:is(#settings-overlay, #home-settings-container) [data-tab="appearance"] .setting-range,
:is(#settings-overlay, #home-settings-container) [data-tab="appearance"] .setting-slider-head,
:is(#settings-overlay, #home-settings-container) [data-tab="appearance"] .setting-range-ticks { max-width: 420px; }
:is(#settings-overlay, #home-settings-container) .setting-chip:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 1px; }

@media (max-width: 640px) {
    .pw-tp { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .pw-tp-foot { padding-right: 4px; flex-direction: column; gap: 0; }
    .pw-tp-variants { position: static; padding: 6px 4px 0; }
}
