/* ==========================================================================
   ColorHunter by Whisser
   Liquid Glass after Apple's HIG: controls float on a glass layer above the
   content (top bar, tab bar, sheet, toast), content stays opaque and calm so
   colors are judged on a neutral ground. Glass is reserved for those few fixed
   layers (backdrop-filter is the costly part), every motion is transform or
   opacity, and the page falls back to solid surfaces for reduced transparency.
   Tokens, Inter and the pill controls follow app4.php.
   ========================================================================== */

:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    --ease: cubic-bezier(0.25, 1, 0.5, 1);
    --spring: cubic-bezier(0.3, 1.22, 0.55, 1);
    --r-xl: 30px;
    --r-lg: 24px;
    --r-md: 18px;
    --r-sm: 12px;
    --bar: 52px;
    --pad: max(16px, env(safe-area-inset-left));
    --shell: 1360px;

    color-scheme: light;
    --bg: #f5f5f7;
    --card: #ffffff;
    --ink: #1d1d1f;
    --ink-2: #5e5e64;
    --ink-3: #8a8a8f;
    --line: rgba(0, 0, 0, 0.08);
    --fill: rgba(118, 118, 128, 0.12);
    --fill-2: rgba(118, 118, 128, 0.2);
    --accent: #007aff;
    --like: #ff2d55;
    --ok: #34c759;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px -16px rgba(0, 0, 0, 0.18);
    --card-lift: 0 2px 4px rgba(0, 0, 0, 0.05), 0 22px 40px -18px rgba(0, 0, 0, 0.28);
    --seg-on: #ffffff;
    --seg-on-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 3px 10px rgba(0, 0, 0, 0.08);

    --glass: rgba(255, 255, 255, 0.56);
    --glass-strong: rgba(250, 250, 252, 0.8);
    --glass-rim: rgba(255, 255, 255, 0.95);
    --glass-edge: rgba(0, 0, 0, 0.07);
    --glass-spec: rgba(255, 255, 255, 0.85);
    --glass-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.05);
    --lens: rgba(0, 0, 0, 0.065);
    --ambient: 0.55;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e0e10;
    --card: #1c1c1e;
    --ink: #f5f5f7;
    --ink-2: #a1a1a8;
    --ink-3: #75757c;
    --line: rgba(255, 255, 255, 0.09);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.36);
    --accent: #0a84ff;
    --like: #ff375f;
    --ok: #30d158;
    --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 12px 28px -16px rgba(0, 0, 0, 0.9);
    --card-lift: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 44px -18px rgba(0, 0, 0, 0.95);
    --seg-on: #636366;
    --seg-on-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);

    --glass: rgba(36, 36, 40, 0.5);
    --glass-strong: rgba(30, 30, 33, 0.82);
    --glass-rim: rgba(255, 255, 255, 0.26);
    --glass-edge: rgba(255, 255, 255, 0.1);
    --glass-spec: rgba(255, 255, 255, 0.14);
    --glass-shadow: 0 14px 36px -12px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
    --lens: rgba(255, 255, 255, 0.12);
    --ambient: 0.3;
}

/* No-JS visitors with a dark system theme */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --bg: #0e0e10; --card: #1c1c1e; --ink: #f5f5f7; --ink-2: #a1a1a8; --ink-3: #75757c;
        --line: rgba(255, 255, 255, 0.09); --fill: rgba(118, 118, 128, 0.24); --fill-2: rgba(118, 118, 128, 0.36);
        --accent: #0a84ff; --seg-on: #636366; --glass: rgba(36, 36, 40, 0.5); --glass-strong: rgba(30, 30, 33, 0.82);
        --glass-rim: rgba(255, 255, 255, 0.26); --glass-edge: rgba(255, 255, 255, 0.1); --glass-spec: rgba(255, 255, 255, 0.14);
        --lens: rgba(255, 255, 255, 0.12); --ambient: 0.3;
        --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 12px 28px -16px rgba(0, 0, 0, 0.9);
    }
}

@view-transition { navigation: auto; }

*,
*::before,
*::after { box-sizing: border-box; }

html {
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 90px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: transparent;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    font-feature-settings: "cv11", "ss01";
    overflow-x: hidden;
}

/* Soft color light behind the glass bars, painted once (fixed layer, no animation) */
body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: 560px;
    z-index: -1;
    pointer-events: none;
    opacity: var(--ambient);
    background:
        radial-gradient(42% 70% at 8% -10%, #ff9e9e, transparent 70%),
        radial-gradient(38% 64% at 50% -18%, #b9a4ff, transparent 72%),
        radial-gradient(40% 70% at 94% -8%, #7cc8ff, transparent 70%);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 18px; height: 18px; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip { position: fixed; left: 16px; top: -60px; z-index: 200; padding: 10px 16px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; }
.skip:focus { top: 16px; }

/* ==========================================================================
   Liquid Glass material
   ========================================================================== */
.glass {
    position: relative;
    background: var(--glass);
    -webkit-backdrop-filter: blur(22px) saturate(185%);
    backdrop-filter: blur(22px) saturate(185%);
    box-shadow: var(--glass-shadow), inset 0 0 0 0.5px var(--glass-edge), inset 0 1px 0 var(--glass-spec);
}

/* Specular rim: light catches the top-left and bottom-right edges */
.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    padding: 1px;
    pointer-events: none;
    background: linear-gradient(155deg, var(--glass-rim), transparent 34%, transparent 66%, var(--glass-rim));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    opacity: 0.7;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass { background: var(--glass-strong); }
}

/* ==========================================================================
   Top bar: three floating capsules
   ========================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px max(var(--pad), calc((100% - var(--shell)) / 2 + 24px)) 10px;
    pointer-events: none;
}

/* Scroll-edge effect: content dissolves under the bar */
.topbar::after {
    content: "";
    position: absolute;
    inset: 0 0 -18px;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(to bottom, var(--bg) 0%, color-mix(in srgb, var(--bg) 70%, transparent) 55%, transparent);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
}

.topbar.is-scrolled::after { opacity: 1; }
.topbar > * { pointer-events: auto; }

.bar {
    display: flex;
    align-items: center;
    height: var(--bar);
    border-radius: 999px;
}

.bar > * { position: relative; z-index: 1; }

.bar-left {
    flex-shrink: 0;
    gap: 10px;
    padding: 0 16px 0 10px;
    view-transition-name: bar-left;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 36px;
    padding: 0 8px 0 2px;
    border-radius: 999px;
    color: var(--accent);
    font-weight: 500;
    font-size: 1.02rem;
    transition: transform 0.2s var(--ease), opacity 0.2s;
}

.back-link .i { width: 22px; height: 22px; stroke-width: 2.4; }
.back-link:hover { opacity: 0.8; }
.back-link:active { transform: scale(0.95); }

.bar-sep { width: 1px; height: 22px; background: var(--line); }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-weight: 800;
    font-size: 1.12rem;
    letter-spacing: -0.035em;
    white-space: nowrap;
}

.brand-logo { width: 28px; height: 28px; flex-shrink: 0; }

.tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    height: var(--bar);
    margin: 0 auto;
    padding: 5px;
    border-radius: 999px;
    view-transition-name: tabs;
}

.tab {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 100%;
    padding: 0 16px;
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s var(--ease), transform 0.35s var(--spring);
}

.tab .i { width: 17px; height: 17px; }
.tab:hover { color: var(--ink); }
.tab:active { transform: scale(0.94); }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .i { color: var(--accent); }

/* The lens: the selected tab sits in a brighter drop of glass; it morphs between pages */
.tab-lens {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--lens);
    box-shadow: inset 0 1px 0 var(--glass-spec);
    view-transition-name: tab-lens;
}

.badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--like);
    color: #fff;
    font: 700 0.68rem/18px var(--font);
    font-style: normal;
    text-align: center;
}

.bar-right {
    flex-shrink: 0;
    gap: 4px;
    padding: 0 6px 0 6px;
    view-transition-name: bar-right;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    height: 40px;
    width: 250px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--fill);
    color: var(--ink-3);
    transition: width 0.4s var(--spring), background 0.2s;
}

.search:focus-within { width: 300px; background: var(--fill-2); }
.search .i { width: 16px; height: 16px; }

.search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    margin-left: 8px;
    border: 0;
    outline: 0;
    background: none;
    color: var(--ink);
    font-size: 0.92rem;
}

.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    color: var(--ink);
    transition: background 0.2s var(--ease), transform 0.35s var(--spring);
}

.icon-btn:hover { background: var(--fill); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn .i { width: 19px; height: 19px; }

.search-open,
.search-close { display: none; }

.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ==========================================================================
   Layout
   ========================================================================== */
.shell {
    display: grid;
    grid-template-columns: 212px minmax(0, 1fr);
    gap: 36px;
    max-width: var(--shell);
    margin: 0 auto;
    padding: 18px 24px 56px;
    padding-inline: max(24px, env(safe-area-inset-left));
}

.shell.no-side { grid-template-columns: minmax(0, 1fr); }

.side {
    position: sticky;
    top: calc(var(--bar) + 34px);
    align-self: start;
    max-height: calc(100vh - var(--bar) - 50px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--fill-2) transparent;
    margin-left: -10px;
    padding: 4px 10px 24px;
    view-transition-name: side;
}

.side-h {
    margin: 18px 10px 6px;
    color: var(--ink-3);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.side-h:first-child { margin-top: 4px; }

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--ink-2);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.side-nav a span { flex: 1; }
.side-nav small { color: var(--ink-3); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.side-nav a:hover { background: var(--fill); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--fill); color: var(--ink); font-weight: 650; }

.dot {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--c);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.main { min-width: 0; }

.hero { padding: 10px 0 18px; }

.hero h1 {
    font-size: clamp(1.9rem, 3.6vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.06;
}

.lede { max-width: 62ch; margin-top: 10px; color: var(--ink-2); font-size: 1.02rem; }

/* ---------- Toolbar: chips + segmented control ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 14px;
    margin-bottom: 18px;
}

.toolbar .count { order: 1; margin: 0 auto 0 4px; }
.toolbar .seg { order: 2; }

.chips {
    display: none;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--fill);
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 550;
    white-space: nowrap;
    scroll-snap-align: start;
    transition: background 0.15s, transform 0.3s var(--spring);
}

.chip:hover { background: var(--fill-2); }
.chip:active { transform: scale(0.95); }
.chip.is-on { background: var(--ink); color: var(--bg); }
.chip .dot { width: 11px; height: 11px; }

/* Segmented control with a sliding thumb (iOS) */
.seg {
    position: relative;
    display: inline-grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    flex-shrink: 0;
    padding: 3px;
    border-radius: 999px;
    background: var(--fill);
}

.seg-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc((100% - 6px) / var(--n));
    border-radius: 999px;
    background: var(--seg-on);
    box-shadow: var(--seg-on-shadow);
    transform: translateX(calc(var(--i) * 100%));
    transition: transform 0.42s var(--spring), opacity 0.2s;
}

.seg.no-sel .seg-thumb { opacity: 0; }

.seg > a,
.seg > button {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 16px;
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s;
}

.seg .i { width: 15px; height: 15px; }
.seg [aria-checked="true"] { color: var(--ink); }
.seg-sm > button { height: 30px; padding: 0 12px; font-size: 0.8rem; }

.count { margin: 0 0 14px; color: var(--ink-3); font-size: 0.86rem; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Palette cards
   ========================================================================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
    gap: 22px;
}

.pc {
    content-visibility: auto;
    contain-intrinsic-size: auto 290px;
    padding: 8px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--card-shadow);
    transition: transform 0.4s var(--spring), box-shadow 0.3s var(--ease);
}

.pc.is-new { animation: rise 0.5s var(--ease) both; }

@media (hover: hover) {
    .pc:hover { transform: translateY(-3px); box-shadow: var(--card-lift); }
}

.pc-colors {
    display: flex;
    flex-direction: column;
    aspect-ratio: 1 / 1.02;
    overflow: hidden;
    border-radius: var(--r-sm);
    isolation: isolate;
}

.pc-c {
    position: relative;
    display: block;
    background: var(--c);
}

.pc-c:nth-child(1) { flex: 36; }
.pc-c:nth-child(2) { flex: 26; }
.pc-c:nth-child(3) { flex: 20; }
.pc-c:nth-child(4) { flex: 18; }

.pc-c b {
    position: absolute;
    left: 8px;
    bottom: 6px;
    padding: 3px 7px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.16);
    color: #fff;
    font: 600 0.74rem/1.2 var(--font);
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.18s, transform 0.25s var(--ease), background 0.15s;
    cursor: copy;
}

.pc-c.is-l b { background: rgba(255, 255, 255, 0.4); color: rgba(0, 0, 0, 0.78); }

@media (hover: hover) {
    .pc-c:hover b { opacity: 1; transform: none; }
    .pc-c b:hover { background: rgba(0, 0, 0, 0.32); }
    .pc-c.is-l b:hover { background: rgba(255, 255, 255, 0.7); }
}

.pc-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 2px 0;
}

.like,
.pc-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    min-width: 32px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--fill);
    color: var(--ink-2);
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s, transform 0.35s var(--spring);
}

.like .i,
.pc-copy .i { width: 16px; height: 16px; }
.like:hover,
.pc-copy:hover { background: var(--fill-2); color: var(--ink); }
.like:active,
.pc-copy:active { transform: scale(0.88); }
.like[aria-pressed="true"] { color: var(--like); }
.like[aria-pressed="true"] .i { fill: currentColor; }
.like.pop .i { animation: pop 0.45s var(--spring); }

/* ---------- Gradient cards ---------- */
.grid-g { grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); }

.gc {
    content-visibility: auto;
    contain-intrinsic-size: auto 250px;
    padding: 8px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--card-shadow);
    transition: transform 0.4s var(--spring), box-shadow 0.3s var(--ease);
}

@media (hover: hover) {
    .gc:hover { transform: translateY(-3px); box-shadow: var(--card-lift); }
}

.gc-fill {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 16 / 11;
    border-radius: var(--r-sm);
    cursor: copy;
}

.gc-fill span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #1d1d1f;
    font-size: 0.8rem;
    font-weight: 650;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.2s, transform 0.35s var(--spring);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.gc-fill span .i { width: 15px; height: 15px; }

@media (hover: hover) {
    .gc-fill:hover span { opacity: 1; transform: none; }
}

.gc-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 2px 1px 4px;
}

.gc-meta { flex: 1; min-width: 0; }
.gc-meta strong,
.gc-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-meta strong { font-size: 0.86rem; font-weight: 650; }
.gc-meta small { color: var(--ink-3); font-size: 0.72rem; font-family: var(--mono); }

/* ---------- Library swatches ---------- */
.libs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }

.lib-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 10px 10px 18px;
    border-radius: var(--r-lg);
    background: var(--card);
    box-shadow: var(--card-shadow);
    transition: transform 0.4s var(--spring), box-shadow 0.3s var(--ease);
}

.lib-card:hover { transform: translateY(-3px); box-shadow: var(--card-lift); }
.lib-strip { display: flex; height: 76px; overflow: hidden; border-radius: 16px; }
.lib-strip i { flex: 1; background: var(--c); }
.lib-body { display: grid; gap: 2px; padding: 0 8px; }
.lib-body strong { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.lib-body small { color: var(--accent); font-size: 0.78rem; font-weight: 600; }
.lib-body span { margin-top: 4px; color: var(--ink-2); font-size: 0.86rem; line-height: 1.45; }
.lib-go { position: absolute; right: 18px; bottom: 18px; color: var(--ink-3); transition: transform 0.3s var(--spring); }
.lib-card:hover .lib-go { transform: translateX(3px); color: var(--accent); }

.sw-group { margin-bottom: 30px; }
.sw-group h2 { margin-bottom: 12px; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }

.sw {
    content-visibility: auto;
    contain-intrinsic-size: auto 112px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 5px 5px 8px;
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--card-shadow);
    text-align: left;
    cursor: copy;
    transition: transform 0.35s var(--spring);
}

.sw:hover { transform: translateY(-2px); }
.sw:active { transform: scale(0.95); }
.sw-chip { display: block; aspect-ratio: 4 / 3; border-radius: 11px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.sw-txt { display: grid; padding: 0 4px; line-height: 1.3; }
.sw-txt b { overflow: hidden; font-size: 0.78rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.sw-txt small { color: var(--ink-3); font-size: 0.7rem; font-family: var(--mono); }

/* ==========================================================================
   Palette detail (page and sheet)
   ========================================================================== */
.crumbs { display: flex; align-items: center; gap: 4px; margin: 6px 0 16px; color: var(--ink-3); font-size: 0.86rem; }
.crumbs a { color: var(--accent); font-weight: 500; }
.i-sep { width: 14px; height: 14px; transform: scaleX(-1); }

.pd {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.pd-colors {
    display: flex;
    flex-direction: column;
    min-height: 460px;
    overflow: hidden;
    padding: 0;
    border-radius: var(--r-lg);
    box-shadow: var(--card-shadow);
}

.pd-c {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 92px;
    padding: 14px 18px;
    background: var(--c);
    color: #fff;
    text-align: left;
    cursor: copy;
    transition: flex-grow 0.45s var(--spring);
}

.pd-c:nth-child(1) { flex-grow: 1.5; }
.pd-c.is-l { color: rgba(0, 0, 0, 0.82); }
.pd-hex { font-size: 1.15rem; font-weight: 750; letter-spacing: 0.01em; }
.pd-name { opacity: 0.72; font-size: 0.86rem; font-weight: 500; }

.pd-hint {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.24);
    font-size: 0.74rem;
    font-weight: 650;
    opacity: 0;
    transition: opacity 0.2s;
}

.pd-hint .i { width: 13px; height: 13px; }
.pd-c.is-l .pd-hint { background: rgba(0, 0, 0, 0.08); }
.pd-c:hover .pd-hint,
.pd-c:focus-visible .pd-hint { opacity: 1; }

@media (hover: hover) {
    .pd-c:hover { flex-grow: 1.9; }
}

.pd-info { display: grid; gap: 18px; min-width: 0; }
.pd-title { font-size: clamp(1.35rem, 2.4vw, 1.8rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.15; }
.pd-title span { display: block; color: var(--ink-3); font-size: 0.6em; font-weight: 600; letter-spacing: -0.01em; }
.pd-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--fill);
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s, transform 0.35s var(--spring);
}

.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(0.95); }
.btn .i { width: 17px; height: 17px; }
.btn.like { height: 40px; padding: 0 16px; font-size: 0.88rem; color: var(--ink); }
.btn.like[aria-pressed="true"] { color: var(--like); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 0.82rem; }
.btn-wide { min-width: 220px; height: 46px; background: var(--ink); color: var(--bg); }
.btn-wide:hover { background: var(--ink); opacity: 0.88; }

.pd-codes { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }

.pd-codes li {
    display: grid;
    grid-template-columns: 26px repeat(3, minmax(0, auto));
    justify-content: start;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--card-shadow);
}

.pd-dot { width: 26px; height: 26px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }

.pd-codes button {
    overflow: hidden;
    height: 30px;
    padding: 0 9px;
    border-radius: 9px;
    color: var(--ink-2);
    font: 500 0.8rem/30px var(--mono);
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: copy;
    transition: background 0.15s, color 0.15s;
}

.pd-codes button:first-of-type { color: var(--ink); font-weight: 650; }
.pd-codes button:hover { background: var(--fill); color: var(--ink); }

.pd-export {
    display: grid;
    gap: 10px;
    justify-items: start;
    padding: 12px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--card-shadow);
}

.pd-export pre {
    width: 100%;
    max-height: 210px;
    margin: 0;
    overflow: auto;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--fill);
    font: 500 0.8rem/1.6 var(--mono);
    tab-size: 2;
}

.pd-tags,
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.block { margin-top: 44px; }
.block-h { margin-bottom: 16px; font-size: 1.3rem; font-weight: 750; letter-spacing: -0.03em; }

/* ---------- Sheet (dialog) ---------- */
.sheet {
    width: min(1040px, calc(100% - 48px));
    max-width: none;
    max-height: min(90vh, 900px);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 34px;
    overflow: hidden;
    color: var(--ink);
    background: var(--glass-strong);
    -webkit-backdrop-filter: blur(40px) saturate(190%);
    backdrop-filter: blur(40px) saturate(190%);
    box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.5), inset 0 0 0 0.5px var(--glass-edge), inset 0 1px 0 var(--glass-spec);
    overscroll-behavior: contain;
}

.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.5s var(--spring) both; }
.sheet.is-closing { animation: sheet-out 0.22s var(--ease) both; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.32); animation: fade-in 0.3s var(--ease) both; }
.sheet.is-closing::backdrop { animation: fade-out 0.22s var(--ease) both; }

.sheet-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 8px 26px;
}

.sheet-head strong { flex: 1; font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.sheet-head .icon-btn { width: 38px; height: 38px; }
.sheet-head .icon-btn::before { opacity: 0.5; }
.grabber { display: none; }

.sheet-body {
    overflow-y: auto;
    padding: 8px 26px 28px;
    overscroll-behavior: contain;
}

.sheet-body .block { margin-top: 30px; }
.sheet-body .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(28px + env(safe-area-inset-bottom));
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: calc(100% - 32px);
    min-height: 46px;
    padding: 0 18px 0 12px;
    border-radius: 999px;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 16px) scale(0.94);
    transition: opacity 0.2s var(--ease), transform 0.45s var(--spring);
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast > * { position: relative; z-index: 1; }
.toast-sw { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; background: var(--c, var(--ok)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.toast-sw .i { width: 14px; height: 14px; margin: 5px; color: #fff; }
.toast span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Load more, empty, SEO, footer ---------- */
.more { display: flex; justify-content: center; margin-top: 34px; }
.more.is-auto .btn { opacity: 0; pointer-events: none; }

.empty {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 60px 20px;
    color: var(--ink-2);
    text-align: center;
}

.empty.is-on { display: flex; }
.empty-i { width: 44px; height: 44px; color: var(--like); }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 1.1rem; }
.v-saved .seg { margin-bottom: 18px; }

.seo { max-width: 860px; margin-top: 64px; color: var(--ink-2); }
.seo h2 { margin: 30px 0 10px; color: var(--ink); font-size: 1.25rem; font-weight: 750; letter-spacing: -0.03em; }
.seo p { line-height: 1.65; }
.seo a:not(.chip) { color: var(--accent); }
.faq { display: grid; gap: 8px; }

.faq details {
    padding: 0 18px;
    border-radius: var(--r-md);
    background: var(--card);
    box-shadow: var(--card-shadow);
}

.faq summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    color: var(--ink);
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--ink-3); font-size: 1.4rem; font-weight: 400; transition: transform 0.3s var(--spring); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding-bottom: 16px; }

.foot {
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 40px 20px calc(40px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    color: var(--ink-3);
    font-size: 0.82rem;
    text-align: center;
}

.foot-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 800; letter-spacing: -0.03em; }
.foot-brand small { color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.foot-logo { width: 24px; height: 24px; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.foot-links a { color: var(--ink-2); font-weight: 500; }
.foot-links a:hover { color: var(--accent); }

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(26px) scale(0.97); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(18px) scale(0.98); } }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.22s; }
::view-transition-group(tab-lens) { animation-duration: 0.45s; animation-timing-function: var(--spring); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) {
    .tab { padding: 0 13px; }
    .search { width: 200px; }
    .search:focus-within { width: 240px; }
}

@media (max-width: 1020px) {
    .shell { grid-template-columns: minmax(0, 1fr); padding-top: 8px; }
    .side { display: none; }
    .chips { display: flex; flex: 1 1 100%; }
}

/* Phone and small tablet: tab bar floats at the bottom like iOS */
@media (max-width: 760px) {
    :root { --bar: 48px; }

    .topbar { gap: 8px; padding: calc(8px + env(safe-area-inset-top)) var(--pad) 8px; }
    .bar-left { flex: 1; min-width: 0; gap: 6px; padding: 0 14px 0 6px; }
    .back-link { padding: 0 2px; }
    .back-link span { display: none; }
    .brand { min-width: 0; font-size: 1.04rem; }
    .brand-name { overflow: hidden; text-overflow: ellipsis; }
    .brand-logo { width: 25px; height: 25px; }
    .bar-right { padding: 0 4px; gap: 0; }

    .search { display: none; }
    .search-open { display: inline-grid; }

    .topbar.is-searching .bar-left,
    .topbar.is-searching #themeBtn,
    .topbar.is-searching .search-open { display: none; }
    .topbar.is-searching .bar-right { flex: 1; padding: 0 4px 0 6px; }
    .topbar.is-searching .search { display: flex; flex: 1; width: auto; animation: rise 0.35s var(--spring); }
    .topbar.is-searching .search-close { display: inline-grid; }

    .tabs {
        position: fixed;
        left: 50%;
        bottom: max(14px, env(safe-area-inset-bottom));
        z-index: 60;
        width: min(400px, calc(100% - 28px));
        height: 64px;
        margin: 0;
        padding: 6px;
        justify-content: space-between;
        transform: translateX(-50%);
        transform-origin: 50% 100%;
        transition: transform 0.5s var(--spring), opacity 0.25s var(--ease);
    }

    .tab {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 0;
        font-size: 0.66rem;
        font-weight: 600;
    }

    .tab .i { width: 22px; height: 22px; }
    .tab-label { transition: opacity 0.25s; }
    .tab .badge { position: absolute; top: 4px; left: calc(50% + 6px); }

    /* Sheets cover the tab bar, as on iOS */
    body:has(.sheet[open]) .tabs { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(20px) scale(0.9); }

    /* Scrolling down shrinks the tab bar out of the way (iOS 26) */
    .tabs.is-min { transform: translateX(-50%) translateY(6px) scale(0.84); }
    .tabs.is-min .tab-label { opacity: 0; }

    .shell { padding: 4px var(--pad) 40px; }
    .hero { padding: 8px 0 14px; }
    .lede { font-size: 0.95rem; }
    .chips { margin-right: calc(var(--pad) * -1); padding-right: 24px; }
    .toolbar .count { order: 3; flex-basis: 100%; margin: -4px 0 0 4px; }
    .seg > a { padding: 0 14px; }

    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .grid-g { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pc, .gc { padding: 6px; border-radius: 16px; }
    .pc-colors, .gc-fill { border-radius: 11px; }
    .pc-bar { padding-top: 6px; }
    .like, .pc-copy { height: 30px; min-width: 30px; padding: 0 8px; }
    .gc-fill span { display: none; }
    .gc-meta small { display: none; }

    .libs { grid-template-columns: minmax(0, 1fr); }
    .sw-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }

    .pd { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .pd-colors { min-height: 0; }
    .pd-c { min-height: 78px; padding: 12px 16px; }
    .pd-hint { opacity: 1; }
    .pd-codes li { grid-template-columns: 26px auto minmax(0, 1fr); }
    .pd-codes button:last-child { display: none; }
    .pd-actions .btn { flex: 1 1 calc(50% - 4px); }

    .sheet {
        width: 100%;
        max-height: 94vh;
        margin: auto 0 0;
        border-radius: 30px 30px 0 0;
    }

    .sheet[open] { animation-name: sheet-up; animation-duration: 0.55s; }
    .sheet.is-closing { animation-name: sheet-down; }
    .grabber { display: block; position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 9px; background: var(--fill-2); }
    .sheet-head { padding: 18px 12px 6px 20px; }
    .sheet-body { padding: 6px 16px calc(24px + env(safe-area-inset-bottom)); }
    .sheet-body .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

    .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
    .foot { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
    .seo { margin-top: 48px; }
}

@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }

@media (max-width: 360px) {
    .brand-name { display: none; }
}

/* ==========================================================================
   Accessibility preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    @view-transition { navigation: none; }
}

@media (prefers-reduced-transparency: reduce) {
    .glass, .sheet { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
    body::before { display: none; }
}

@media (prefers-contrast: more) {
    :root { --glass-edge: rgba(0, 0, 0, 0.4); --line: rgba(0, 0, 0, 0.3); }
    :root[data-theme="dark"] { --glass-edge: rgba(255, 255, 255, 0.5); --line: rgba(255, 255, 255, 0.35); }
    .glass, .sheet { background: var(--card); }
}

@media (forced-colors: active) {
    .glass, .seg-thumb, .tab-lens { border: 1px solid CanvasText; }
}

@media print {
    .topbar, .tabs, .side, .toast, .more, .foot, .pc-bar { display: none !important; }
    body::before { display: none; }
}
