* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for theming */
:root {
    --selection-bg: #dfe9ff;
    --selection-fg: var(--accent);
    --gallery-icon-color: #212121;
    --bg-primary: #f7f7f9;
    --bg-secondary: var(--surface-card);
    --bg-tertiary: var(--surface-sunken);
    --text-accent: var(--accent);
    --border-color: var(--border-subtle);
    --border-hover: var(--border-default);
    --shadow: rgba(11, 11, 12, 0.08);
    --icon-filter: none;
    --toolbar-control-height: 32px;
    --nav-bg-start: var(--surface-overlay);
    --nav-bg-end: var(--surface-overlay);
    --nav-divider-color: var(--border-subtle);
    --nav-border-color: var(--border-subtle);
    --nav-brand-color: var(--text-primary);
    --nav-segment-bg: var(--surface-sunken);
    --nav-segment-text: var(--text-secondary);
    --nav-segment-hover-bg: var(--surface-subtle);
    --nav-segment-active-bg: var(--selection-bg);
    --nav-segment-active-text: var(--selection-fg);
    --nav-input-bg: rgb(0 0 0 / 5.5%);
    --nav-input-bg-focus: rgb(0 0 0 / 7.5%);
    --nav-input-text: var(--text-primary);
    --nav-input-placeholder: #7a7a7f;
    --nav-count-bg: var(--accent);
    --nav-count-text: #ffffff;
    --panel-control-bg: var(--surface-sunken);
    --panel-control-hover-bg: var(--surface-subtle);
    --panel-control-disabled-bg: var(--surface-subtle);
    --panel-cta-bg: var(--accent);
    --panel-cta-bg-hover: var(--accent-hover);
    --panel-preview-control-band-end: 30%;
    --icon-panel-height: clamp(260px, 42vh, 420px);
    --site-footer-height: 48px;
}

html,
body {
    width: 100%;
    max-width: 100%;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --selection-bg: rgba(59, 120, 255, 0.18);
        --selection-fg: var(--accent-hover);
        --gallery-icon-color: #ffffff;
        --bg-primary: var(--surface-base);
        --bg-secondary: var(--surface-card);
        --bg-tertiary: var(--surface-sunken);
        --text-accent: var(--accent);
        --border-color: var(--border-subtle);
        --border-hover: var(--border-default);
        --shadow: rgba(0, 0, 0, 0.35);
        --icon-filter: brightness(0) invert(1);
        --nav-bg-start: var(--surface-overlay);
        --nav-bg-end: var(--surface-overlay);
        --nav-divider-color: var(--border-subtle);
        --nav-border-color: var(--border-subtle);
        --nav-brand-color: var(--text-primary);
        --nav-segment-bg: var(--surface-sunken);
        --nav-segment-text: var(--text-secondary);
        --nav-segment-hover-bg: var(--surface-subtle);
        --nav-segment-active-bg: var(--selection-bg);
        --nav-segment-active-text: var(--selection-fg);
        --nav-input-bg: rgb(255 255 255 / 5.5%);
        --nav-input-bg-focus: rgb(255 255 255 / 7.5%);
        --nav-input-text: var(--text-primary);
        --nav-input-placeholder: #90887d;
        --nav-count-bg: var(--accent);
        --nav-count-text: #ffffff;
        --panel-control-bg: var(--surface-sunken);
        --panel-control-hover-bg: var(--surface-subtle);
        --panel-control-disabled-bg: var(--surface-subtle);
        --panel-cta-bg: var(--accent);
        --panel-cta-bg-hover: var(--accent-hover);
    }
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: var(--site-footer-height);
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
}

::selection {
    background: rgb(11 95 255 / 16%);
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-thumb {
    border-radius: 9px;
    background: rgb(127 127 140 / 40%);
}

html,
body {
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

.container {
    flex: 1 0 auto;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: visible;
}

.noscript-page {
    display: grid;
    min-height: calc(100vh - 72px);
    padding: 48px 24px;
    place-items: center;
}

.noscript-card {
    width: min(100%, 720px);
    padding: clamp(28px, 6vw, 56px);
    border-radius: 18px;
    background: var(--surface-card);
    box-shadow: var(--shadow-lg);
}

.noscript-mark {
    display: grid;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    color: var(--accent);
    background: var(--accent-subtle);
    place-items: center;
}

.noscript-mark svg {
    width: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.noscript-eyebrow {
    margin: 24px 0 8px;
    color: var(--accent);
    font: 600 0.76rem/1.2 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.noscript-card h1 {
    margin: 0;
    font-size: clamp(2.2rem, 8vw, 4.5rem);
    letter-spacing: -0.05em;
    line-height: 0.95;
}

.noscript-card h2 {
    margin: 32px 0 10px;
    font-size: 1.1rem;
}

.noscript-card p,
.noscript-card li {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.65;
}

.noscript-card ul {
    display: grid;
    margin: 0;
    padding-left: 1.25rem;
    gap: 7px;
}

.noscript-card a,
.site-footer-copy a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.noscript-card a:hover,
.site-footer-copy a:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.site-footer {
    position: fixed;
    z-index: 190;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    min-height: 48px;
    padding: 12px 24px;
    align-items: center;
    justify-content: center;
    background: var(--surface-subtle);
    border-top: 1px solid var(--nav-border-color);
}

.site-footer-copy {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 0.25em;
    max-width: calc(100% - 56px);
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.footer-copy-part {
    white-space: nowrap;
}

.footer-repo-link {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.app-update-banner {
    position: -webkit-sticky;
    position: sticky;
    top: 64px;
    z-index: 190;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) auto;
    grid-template-areas: "title message actions";
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    padding: 10px 20px;
    color: var(--text-primary);
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.app-update-banner[hidden] {
    display: none;
}

.app-update-banner:not([hidden]) {
    animation: app-update-banner-in 180ms var(--ease-out);
}

.app-update-title {
    grid-area: title;
    font-size: 0.82rem;
}

.app-update-message {
    grid-area: message;
    min-width: 0;
    overflow: hidden;
    color: var(--text-secondary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-update-actions {
    grid-area: actions;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    align-self: start;
    justify-self: end;
    white-space: nowrap;
}

.app-update-banner.is-stacked {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title actions"
        "message actions";
    column-gap: 12px;
    row-gap: 4px;
    padding-top: 6px;
}

.app-update-banner.is-stacked .app-update-message {
    font-size: 0.82rem;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

.app-update-banner.is-stacked .app-update-actions {
    gap: 6px;
}

.app-update-banner.is-stacked .app-update-dismiss {
    flex-basis: 20px;
    width: 20px;
    height: 20px;
    font-size: 18px;
}

.app-update-banner.is-stacked .app-update-refresh-label {
    display: none;
}

@keyframes app-update-banner-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-update-refresh,
.app-update-dismiss {
    border: none;
    cursor: pointer;
}

.app-update-refresh {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    border-radius: 6px;
    color: #ffffff;
    background: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
}

.app-update-refresh-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.app-update-refresh:hover {
    background: var(--accent-hover);
}

.app-update-dismiss {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    color: var(--text-secondary);
    background: transparent;
    font-size: 20px;
    line-height: 1;
}

.app-update-dismiss:hover {
    color: var(--text-primary);
    background: var(--surface-subtle);
}

.top-bar {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 64px;
    padding: 10px 20px;
    background: transparent;
    box-shadow: none;
    border-bottom: 1px solid var(--nav-border-color);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.top-bar-row {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(320px, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.brand-search {
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr);
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--nav-brand-color);
    margin: 0;
    white-space: nowrap;
    line-height: 1;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.brand-logo svg {
    width: 100%;
    height: 100%;
    fill: var(--accent);
}

.top-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toolbar-scroll-region {
    --toolbar-fade-width: 72px;
    --toolbar-fade-quarter: 18px;
    --toolbar-fade-half: 36px;
    --toolbar-fade-three-quarter: 54px;
    position: relative;
    min-width: 0;
}

.toolbar-scroll-region--panel {
    width: 100%;
}

.toolbar-scroll-cue {
    position: absolute;
    z-index: 1;
    top: 0;
    bottom: 0;
    display: flex;
    width: 44px;
    align-items: center;
    pointer-events: none;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}

.toolbar-scroll-cue svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.toolbar-scroll-cue--left {
    left: 0;
    justify-content: flex-start;
    background: transparent;
}

.toolbar-scroll-cue--right {
    right: 0;
    justify-content: flex-end;
    background: transparent;
}

.top-controls.has-overflow-left ~ .toolbar-scroll-cue--left,
.panel-toolbar.has-overflow-left ~ .toolbar-scroll-cue--left,
.top-controls.has-overflow-right ~ .toolbar-scroll-cue--right,
.panel-toolbar.has-overflow-right ~ .toolbar-scroll-cue--right {
    opacity: 1;
}

.top-controls.has-overflow-left,
.panel-toolbar.has-overflow-left {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.156) var(--toolbar-fade-quarter),
        rgba(0, 0, 0, 0.5) var(--toolbar-fade-half),
        rgba(0, 0, 0, 0.844) var(--toolbar-fade-three-quarter),
        #000 var(--toolbar-fade-width),
        #000 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.156) var(--toolbar-fade-quarter),
        rgba(0, 0, 0, 0.5) var(--toolbar-fade-half),
        rgba(0, 0, 0, 0.844) var(--toolbar-fade-three-quarter),
        #000 var(--toolbar-fade-width),
        #000 100%
    );
}

.top-controls.has-overflow-right,
.panel-toolbar.has-overflow-right {
    -webkit-mask-image: linear-gradient(
        to right,
        #000 0,
        #000 calc(100% - var(--toolbar-fade-width)),
        rgba(0, 0, 0, 0.844) calc(100% - var(--toolbar-fade-three-quarter)),
        rgba(0, 0, 0, 0.5) calc(100% - var(--toolbar-fade-half)),
        rgba(0, 0, 0, 0.156) calc(100% - var(--toolbar-fade-quarter)),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        #000 0,
        #000 calc(100% - var(--toolbar-fade-width)),
        rgba(0, 0, 0, 0.844) calc(100% - var(--toolbar-fade-three-quarter)),
        rgba(0, 0, 0, 0.5) calc(100% - var(--toolbar-fade-half)),
        rgba(0, 0, 0, 0.156) calc(100% - var(--toolbar-fade-quarter)),
        transparent 100%
    );
}

.top-controls.has-overflow-left.has-overflow-right,
.panel-toolbar.has-overflow-left.has-overflow-right {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.156) var(--toolbar-fade-quarter),
        rgba(0, 0, 0, 0.5) var(--toolbar-fade-half),
        rgba(0, 0, 0, 0.844) var(--toolbar-fade-three-quarter),
        #000 var(--toolbar-fade-width),
        #000 calc(100% - var(--toolbar-fade-width)),
        rgba(0, 0, 0, 0.844) calc(100% - var(--toolbar-fade-three-quarter)),
        rgba(0, 0, 0, 0.5) calc(100% - var(--toolbar-fade-half)),
        rgba(0, 0, 0, 0.156) calc(100% - var(--toolbar-fade-quarter)),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.156) var(--toolbar-fade-quarter),
        rgba(0, 0, 0, 0.5) var(--toolbar-fade-half),
        rgba(0, 0, 0, 0.844) var(--toolbar-fade-three-quarter),
        #000 var(--toolbar-fade-width),
        #000 calc(100% - var(--toolbar-fade-width)),
        rgba(0, 0, 0, 0.844) calc(100% - var(--toolbar-fade-three-quarter)),
        rgba(0, 0, 0, 0.5) calc(100% - var(--toolbar-fade-half)),
        rgba(0, 0, 0, 0.156) calc(100% - var(--toolbar-fade-quarter)),
        transparent 100%
    );
}

.repo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--toolbar-control-height);
    height: var(--toolbar-control-height);
    flex: 0 0 var(--toolbar-control-height);
    border-radius: 9999px;
    color: var(--nav-segment-text);
    background: var(--nav-segment-bg);
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.repo-link:hover {
    background: var(--nav-segment-hover-bg);
    color: var(--nav-brand-color);
}

.repo-link:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.repo-link svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.segmented-control {
    display: inline-flex;
    align-items: center;
    height: var(--toolbar-control-height);
    box-sizing: border-box;
    border-radius: 980px;
    overflow: hidden;
    border: none;
    background: var(--nav-segment-bg);
}

.icon-set-picker {
    min-width: 0;
    width: clamp(164px, 22vw, 320px);
}

.icon-group-picker {
    min-width: 0;
    width: clamp(132px, 16vw, 228px);
}

.icon-group-picker[hidden] {
    display: none;
}

.style-filter {
    width: 134px;
    min-width: 134px;
    max-width: 134px;
}

.style-filter .segment-btn {
    flex: 1 1 0;
    height: 100%;
    padding: 0;
    min-width: 0;
}

.segment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-right: 2px solid var(--nav-divider-color);
    background: transparent;
    color: var(--nav-segment-text);
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.segment-btn:last-child {
    border-right: none;
}

.icon-mode-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.style-mode-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    position: relative;
}

.regular-icon {
    border: 2px solid currentColor;
    background: transparent;
}

.filled-icon {
    border: 2px solid currentColor;
    background: currentColor;
}

.color-icon {
    border: 2px solid currentColor;
    background: linear-gradient(to right, #ffb900 0 33%, #00bcf2 33% 66%, #e74856 66% 100%);
}

.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;
}

.segment-btn:hover:not(.active):not(.disabled) {
    background: var(--nav-segment-hover-bg);
}

.segment-btn.active {
    background: var(--nav-segment-active-bg);
    color: var(--nav-segment-active-text);
}

.segment-btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.set-subtitle {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 8px 20px 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.set-subtitle-label {
    color: var(--text-primary);
    font-weight: 600;
}

.set-source-list {
    min-width: 0;
    overflow-wrap: anywhere;
}

.set-source-list a {
    color: inherit;
    text-decoration-color: var(--nav-divider-color);
    text-underline-offset: 2px;
}

.set-source-list a:hover {
    color: var(--accent);
}

.set-source-list a:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: 2px;
}

#searchInput {
    width: 100%;
    min-width: 0;
    height: var(--toolbar-control-height);
    box-sizing: border-box;
    padding: 0 calc(var(--search-count-width, 22px) + var(--search-clear-reserve, 0px) + 13px) 0 34px;
    line-height: 1;
    font-size: 14px;
    border: none;
    border-radius: 9999px;
    outline: none;
    transition: background-color var(--dur-fast) var(--ease-out);
    background-color: var(--nav-input-bg);
    color: var(--nav-input-text);
}

#searchInput:focus {
    outline: none;
    background-color: var(--nav-input-bg-focus);
    box-shadow: none;
}

#searchInput::placeholder {
    color: var(--nav-input-placeholder);
}

.search-wrap {
    position: relative;
    width: 100%;
    max-width: 442px;
    min-width: 0;
    justify-self: center;
}

.search-wrap.has-search-value {
    --search-clear-reserve: 26px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--nav-input-placeholder);
    pointer-events: none;
}

.search-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.search-wrap:focus-within .search-icon {
    color: var(--nav-input-text);
}

.search-clear-button {
    position: absolute;
    right: calc(var(--search-count-width, 22px) + 9px);
    top: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--nav-input-placeholder);
    font: inherit;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.search-clear-button[hidden] {
    display: none;
}

.search-clear-button:hover {
    background: var(--nav-segment-hover-bg);
    color: var(--nav-input-text);
}

.search-clear-button:focus-visible {
    outline: none;
    color: var(--nav-input-text);
    box-shadow: var(--ring);
}

.search-clear-button span {
    transform: translateY(-1px);
}

.search-count-pill {
    position: absolute;
    right: 5px;
    top: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--nav-count-bg);
    color: var(--nav-count-text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.icon-grid {
    padding: 20px 20px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    grid-auto-rows: 90px;
    justify-content: start;
    gap: 8px;
}

.icon-card {
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 18px;
    color: var(--gallery-icon-color);
    width: 90px;
    height: 90px;
    padding: 15px;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
}

@supports (corner-shape: squircle) {
    .icon-card {
        border-radius: 999px;
        corner-shape: squircle;
    }
}

.icon-card.is-hidden {
    display: none !important;
}

.icon-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.icon-card.is-selected {
    box-shadow: var(--shadow-sm);
    background: var(--selection-bg);
    color: var(--selection-fg);
}

.icon-view {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.icon-view svg {
  width: 100%;
  height: 100%;
  display: block;
}

.icon-view img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.icon-large {
  width: 150px;
  height: 150px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Gallery icon size override */
.icon-card .icon-view {
    width: 60px;
    height: 60px;
    margin: 0;
    background: none;
    border-radius: 0;
}

.icon-view.preview-theme-color {
    color: #000;
}

.icon-view.preview-theme-color img {
    filter: brightness(0);
}
.icon-card .icon-view svg {
    width: 100%;
    height: 100%;
}
.icon-card .icon-view img {
    width: 100%;
    height: 100%;
}

.icon-card .icon-view:not(.has-color-variant) svg:not([fill="none"]) {
    fill: currentColor;
}

.gallery-icon-mask {
    display: block;
    width: 100%;
    height: 100%;
    background: currentColor;
    -webkit-mask: var(--gallery-icon-source) center / contain no-repeat;
    mask: var(--gallery-icon-source) center / contain no-repeat;
}

/* Apply filter to non-color SVGs in dark mode */
@media (prefers-color-scheme: dark) {
    .icon-view svg,
    .icon-view img {
        filter: var(--icon-filter);
    }
    .icon-view.has-color-variant svg,
    .icon-view.has-color-variant img {
        filter: none !important;
    }

    .icon-view.has-color-variant.preview-theme-color img {
        filter: brightness(0) invert(1) !important;
    }

    .icon-card.is-selected .icon-view:not(.has-color-variant) svg {
        filter: none;
    }
}

.icon-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    word-break: break-word;
    color: var(--text-primary);
}

.icon-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}

/* Variant chips in icon cards (flex row) */
.icon-variants {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}
/* Tighter badge padding for icon card chips */
.icon-card .icon-variants .variant-badge {
    /* inherit base padding/radius, just adjust font-size a bit smaller in cards */
    font-size: 11px;
}

.variant-badge {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 9999px; /* pill shape */
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 0 0 1px var(--border-color) inset;
}

.variant-badge.regular {
    background: #e1f5fe;
    color: #0277bd;
}

@media (prefers-color-scheme: dark) {
    .variant-badge.regular {
        background: #0d47a1;
        color: #81d4fa;
    }
}

.variant-badge.filled {
    background: #f3e5f5;
    color: #7b1fa2;
}

@media (prefers-color-scheme: dark) {
    .variant-badge.filled {
        background: #4a148c;
        color: #ce93d8;
    }
}

.variant-badge.color {
    background: #e0f7fa;
    color: #00796b;
}

@media (prefers-color-scheme: dark) {
    .variant-badge.color {
        background: #004d40;
        color: #80cbc4;
    }
}

.modal {
    position: fixed;
    z-index: 180;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(12px + var(--site-footer-height));
    width: auto;
    height: var(--icon-panel-height);
    background: var(--surface-overlay);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    display: none;
    overflow: hidden;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    transform: translate3d(0, var(--panel-swipe-offset, 0px), 0);
}

@media (prefers-color-scheme: dark) {
    .modal {
        box-shadow: 0 10px 26px rgba(0, 0, 0, 0.48);
    }
}

.modal.is-open {
    display: block;
}

.modal-content {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    border: none;
    border-radius: inherit;
    overscroll-behavior: contain;
}

.modal.is-swipe-dragging {
    transition: none;
    user-select: none;
    will-change: transform;
}

.modal.is-swipe-settling,
.modal.is-swipe-dismissing {
    transition: transform 160ms var(--ease-out);
    user-select: none;
    will-change: transform;
}

.modal-header.panel-meta,
.panel-meta-details {
    overscroll-behavior: contain;
}

@supports (corner-shape: squircle) {
    .modal,
    .modal-content {
        border-radius: 48px;
        corner-shape: squircle;
    }
}

.panel-layout {
    display: grid;
    grid-template-columns: clamp(200px, 42%, 480px) minmax(0, 1fr);
    width: 100%;
    height: 100%;
}

@media (min-width: 601px) and (max-width: 740px) {
    .panel-layout {
        grid-template-columns: minmax(160px, 42%) minmax(390px, 1fr);
    }

    .panel-preview .panel-actions-group {
        margin-left: 8px;
    }
}

.modal-header.panel-meta {
    padding: 16px 16px 14px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    min-width: 0;
}

.modal-header.panel-meta h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-primary);
    padding-right: 0;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.panel-title-trigger {
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

.panel-title-trigger:disabled {
    cursor: default;
    opacity: 1;
}

.panel-meta-details p {
    color: var(--text-secondary);
    line-height: 1.45;
    font-size: 13px;
    margin-bottom: 12px;
}

.panel-meta-details .panel-meta-full-title {
    color: var(--text-primary);
    font-weight: 650;
    line-height: 1.25;
    margin-bottom: 8px;
}

.panel-preview {
    padding: 16px;
    overflow-y: auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
}

@media (prefers-color-scheme: dark) {
    .panel-preview {
        background: transparent;
    }
}

.panel-preview-header {
    display: flex;
    justify-content: flex-start;
    padding-right: 0;
    box-sizing: border-box;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.panel-toolbar::-webkit-scrollbar {
    display: none;
}

.panel-variant-tabs {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    background: var(--panel-control-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.panel-variant-tabs .segment-btn {
    flex: 0 0 40px;
    width: 40px;
    height: var(--toolbar-control-height);
    padding: 0;
    border-right: 2px solid var(--nav-divider-color);
    color: var(--nav-segment-text);
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.panel-variant-tabs .segment-btn:last-child {
    border-right: none;
}

.panel-variant-tabs .segment-btn.is-last-visible {
    border-right: none;
}

.panel-variant-tabs .segment-btn:hover:not(.active):not(.disabled) {
    background: var(--nav-segment-hover-bg);
}

.panel-variant-tabs .segment-btn.active {
    background: var(--nav-segment-active-bg);
    color: var(--nav-segment-active-text);
}

.panel-variant-tabs .segment-btn:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--nav-bg-start) 44%, transparent 56%);
}

.panel-size-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    border-radius: 9999px;
    flex: 0 0 auto;
}

.panel-size-button {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    height: var(--toolbar-control-height);
    min-width: 62px;
    width: 62px;
    padding: 0 10px 0 12px;
    border: none;
    border-radius: 9999px;
    background: var(--nav-segment-bg);
    color: var(--nav-segment-active-text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    outline: none;
    transition: background-color var(--dur-fast) var(--ease-out), border-radius var(--dur-fast) var(--ease-out);
}

.panel-size-button:hover:not(:disabled) {
    background: var(--nav-segment-hover-bg);
}

.panel-size-button:focus-visible {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--nav-bg-start) 44%, transparent 56%);
}

.panel-size-wrap.is-open .panel-size-button {
    border-radius: 16px 16px 0 0;
}

.panel-size-chevron {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    background-color: var(--nav-segment-text);
    -webkit-mask: url("icons/chevron_down_regular.svg") center / contain no-repeat;
    mask: url("icons/chevron_down_regular.svg") center / contain no-repeat;
    transition: transform var(--dur-fast) var(--ease-out);
}

.panel-size-wrap.is-open .panel-size-chevron {
    transform: rotate(180deg);
}

.panel-size-wrap.disabled {
    opacity: 0.45;
}

.panel-size-button:disabled {
    cursor: not-allowed;
}

.panel-size-menu {
    position: fixed;
    z-index: 220;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    background: var(--nav-segment-bg);
    border: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transform: translateY(-2px);
    transform-origin: top;
    pointer-events: none;
    transition:
        clip-path 110ms var(--ease-out),
        opacity 90ms linear,
        transform 110ms var(--ease-out);
    will-change: clip-path, opacity, transform;
}

.panel-size-menu.is-open {
    opacity: 1;
    clip-path: inset(0);
    transform: translateY(0);
    pointer-events: auto;
}

.panel-size-menu[hidden] {
    display: none;
}

.panel-size-option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: var(--toolbar-control-height);
    padding: 0 12px;
    border: none;
    background: transparent;
    color: var(--nav-segment-text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-align: left;
}

.panel-size-option:hover,
.panel-size-option:focus-visible {
    background: var(--nav-segment-hover-bg);
    outline: none;
}

.panel-size-option[aria-selected="true"] {
    background: var(--nav-segment-active-bg);
    color: var(--nav-segment-active-text);
}

.panel-size-option:last-child {
    border-radius: 0 0 16px 16px;
}

.panel-icon-toggle {
    flex: 0 0 auto;
    width: var(--toolbar-control-height);
    height: var(--toolbar-control-height);
    border: none;
    border-radius: 9999px;
    background: var(--nav-segment-bg);
    color: var(--nav-segment-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.panel-icon-toggle:hover {
    background: var(--nav-segment-hover-bg);
}

.panel-icon-toggle.active {
    background: var(--nav-segment-active-bg);
    color: var(--nav-segment-active-text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.panel-icon-toggle.disabled,
.panel-icon-toggle:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--nav-segment-bg);
    color: var(--nav-segment-text);
}

.panel-icon-toggle svg.currentcolor-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.panel-icon-toggle .bounds-toggle-icon {
    overflow: visible;
}

.panel-actions-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: clamp(8px, 5vw, 50px);
    flex: 0 0 auto;
}

.panel-action-btn {
    width: var(--toolbar-control-height);
    height: var(--toolbar-control-height);
    border-radius: 9999px;
    border: none;
    background: var(--panel-cta-bg);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.panel-action-btn:hover:not(:disabled) {
    background: var(--panel-cta-bg-hover);
}

.panel-action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.panel-action-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2.35;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.panel-action-btn svg.fluent-toolbar-icon {
    fill: currentColor;
    stroke: none;
}

.panel-action-btn.is-success {
    background: #107c10;
}

.panel-action-btn.is-error {
    background: #a4262c;
}

.panel-variants {
    flex: 1;
    min-height: 0;
    display: flex;
}

.variant {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    border-radius: 12px;
    background: transparent;
    border: none;
    box-shadow: none;
    min-height: 0;
    overflow: hidden;
}

.variant .icon-view {
    width: 100%;
    height: 100%;
    max-height: 260px;
    margin: 0;
    background: none;
    border-radius: 0;
}

@media (prefers-color-scheme: dark) {
    .icon-view.preview-theme-color {
        color: #fff;
    }

    .icon-view.preview-theme-color img {
        filter: brightness(0) invert(1);
    }
}

.metaphors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 7px;
    align-content: flex-start;
}

.metaphor-tag {
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    margin: 0;
}

@media (prefers-color-scheme: dark) {
    .metaphor-tag {
        background: var(--accent-subtle);
        color: var(--accent-hover);
    }
}

@media (max-width: 600px) {
    .modal,
    .modal-content {
        overflow: visible;
    }

    .panel-layout {
        grid-template-columns: 1fr;
    }

    .modal-header.panel-meta {
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 52px;
        display: flex;
        align-items: baseline;
        justify-content: center;
        gap: 8px;
        overflow: visible;
        white-space: nowrap;
    }

    .modal-header.panel-meta h2 {
        font-size: 1.05rem;
        margin: 0;
        padding-right: 0;
        flex: 0 0 auto;
    }

    .modal.has-promoted-actions .modal-header.panel-meta {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        justify-content: stretch;
        gap: 12px;
        padding: 12px 14px;
    }

    .modal.has-promoted-actions .modal-header.panel-meta h2 {
        min-width: 0;
        overflow: hidden;
        flex: none;
    }

    .modal.has-promoted-actions .panel-title-trigger {
        display: block;
        width: 100%;
        padding-bottom: 4px;
        overflow: hidden;
        text-align: left;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .modal.has-promoted-actions .modal-header.panel-meta > .panel-actions-group {
        justify-self: end;
        margin-left: 0;
    }

    .panel-title-trigger.has-meta-details {
        cursor: pointer;
        text-decoration: underline dotted color-mix(in srgb, currentColor 45%, transparent 55%);
        text-underline-offset: 4px;
    }

    .panel-meta-details {
        position: absolute;
        top: auto;
        right: auto;
        bottom: calc(100% + 10px);
        left: 50%;
        z-index: 7;
        width: fit-content;
        min-width: min(280px, calc(100% + 2px));
        max-width: calc(100% + 2px);
        max-height: min(210px, calc(100vh - var(--icon-panel-height) - 40px));
        padding: 12px 14px;
        overflow-y: auto;
        white-space: normal;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
        transform: translateX(-50%);
    }

    @supports (corner-shape: squircle) {
        .panel-meta-details {
            border-radius: 24px;
            corner-shape: squircle;
        }
    }

    .panel-meta-details[hidden] {
        display: none;
    }

    .panel-meta-details p {
        margin-bottom: 12px;
    }

    .panel-preview .panel-preview-header {
        justify-content: center;
        padding-right: 0;
    }

    .panel-preview .toolbar-scroll-region--panel {
        width: max-content;
        max-width: 100%;
    }

    .panel-preview .panel-toolbar {
        width: max-content;
        max-width: 100%;
    }

    .panel-preview {
        background: transparent;
        padding-top: 12px;
        border-bottom-right-radius: 17px;
        border-bottom-left-radius: 17px;
    }

    .panel-toolbar {
        flex-wrap: nowrap;
    }

    .panel-actions-group {
        margin-left: 8px;
    }
}

body.icon-panel-open .icon-grid {
    padding-bottom: calc(20px + var(--icon-panel-height) + var(--site-footer-height) + 12px);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.cache-loader {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 1400px;
    margin: 12px auto 0;
    padding: 0 24px;
    color: var(--text-secondary);
    font-family: "Fira Code", monospace;
    font-size: 0.75rem;
}

.cache-loader[hidden] {
    display: none;
}

.cache-loader-track {
    width: 112px;
    height: 4px;
    overflow: hidden;
    background: var(--border-color);
}

.cache-loader-progress {
    width: 0;
    height: 100%;
    background: #295DF2;
    transition: width 160ms ease;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-update-banner {
        padding: 10px 12px;
    }

    .container {
        padding: 0;
    }

    .cache-loader {
        padding: 0 16px;
    }

    .set-subtitle {
        padding: 8px 12px 0;
    }

    .brand-title {
        font-size: 0.95rem;
    }

    .top-bar {
        padding: 8px 12px;
    }

    .top-bar-row {
        grid-template-columns: minmax(220px, 1fr) auto;
        gap: 8px;
    }

    .brand-search {
        gap: 10px;
    }

    .icon-grid {
        padding: 12px 12px 12px;
        grid-auto-rows: 90px;
        gap: 6px;
    }

    .modal-content {
        width: 100%;
        margin: 0;
    }

    .modal-header.panel-meta,
    .modal-body.panel-preview {
        padding: 14px;
    }

    .panel-preview-header {
        justify-content: flex-start;
    }

    .panel-toolbar {
        justify-content: flex-start;
        flex-wrap: nowrap;
    }
}

@media (max-width: 620px) {
    .top-bar-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .brand-search {
        grid-template-columns: minmax(0, 1fr);
    }

    .brand-title {
        display: none;
    }

    .search-wrap {
        max-width: none;
    }

    #searchInput {
        min-width: 0;
    }

    .top-controls {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .top-controls::-webkit-scrollbar {
        display: none;
    }

    .toolbar-scroll-region--top {
        width: 100%;
    }
}

@media (max-width: 768px) {
    body.icon-panel-open .icon-grid {
        padding-bottom: calc(12px + var(--icon-panel-height) + var(--site-footer-height) + 8px);
    }
}

@media (max-width: 480px) {
    .icon-grid {
        grid-auto-rows: 90px;
    }
}

@media (max-width: 290px) {
    .top-controls {
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 239px) {
    .search-count-pill {
        display: none;
    }

    #searchInput {
        padding-right: 16px;
    }

    .search-wrap.has-search-value #searchInput {
        padding-right: 34px;
    }

    .search-clear-button {
        right: 5px;
    }
}

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