:root {
    color-scheme: light;
    --canvas: #fff;
    --surface: #fff;
    --text: #000;
    --muted: #626262;
    --border: #e2e2e2;
    --soft: #f7f7f7;
    --hover: #f2f2f2;
    --selected: #edf6f4;
    --accent: #0f766e;
    --accent-hover: #0b5f59;
    --accent-text: #fff;
    --dot: #dedede;
    --radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
}
:root[data-theme='dark'], :root[data-theme='dark2'] {
    color-scheme: dark;
    --canvas: #000;
    --surface: #111;
    --text: #fff;
    --muted: #b0b0b0;
    --border: #424242;
    --soft: #191919;
    --hover: #242424;
    --selected: #102d29;
    --accent: #5eead4;
    --accent-hover: #99f6e4;
    --accent-text: #001313;
    --dot: #333;
}
:root[data-theme='light2'], :root:not([data-theme]) {
    --canvas: #f7f8fb;
    --canvas-soft: #eef7f4;
    --text: #15171c;
    --muted: #555;
    --border: #d8dde6;
    --soft: #f1f5f6;
    --hover: #edf0f4;
    --selected: #e6f3ef;
    --dot: #d8dde6;
    --accent-strong: #2563eb;
    --radius: 16px;
    --fancy-wash: rgba(15, 118, 110, .14);
    --fancy-wash-strong: rgba(37, 99, 235, .12);
    --fancy-glass: rgba(255, 255, 255, .94);
    --fancy-shadow: 0 16px 48px rgba(31, 41, 55, .10);
}
:root[data-theme='dark2'] {
    --canvas: #08090d;
    --canvas-soft: #10131a;
    --surface: #141822;
    --text: #f6f8fb;
    --border: #3e4656;
    --soft: #1b222d;
    --hover: #242a36;
    --selected: #153832;
    --dot: #3e4656;
    --accent-strong: #38bdf8;
    --accent-text: #03151a;
    --radius: 16px;
    --fancy-wash: rgba(94, 234, 212, .14);
    --fancy-wash-strong: rgba(56, 189, 248, .12);
    --fancy-glass: rgba(20, 24, 34, .94);
    --fancy-shadow: 0 16px 48px rgba(0, 0, 0, .24);
}
/* Follow the system defaults before JavaScript loads or when it is unavailable. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --canvas: #08090d;
        --canvas-soft: #10131a;
        --surface: #141822;
        --text: #f6f8fb;
        --muted: #b0b0b0;
        --border: #3e4656;
        --soft: #1b222d;
        --hover: #242a36;
        --selected: #153832;
        --dot: #3e4656;
        --accent: #5eead4;
        --accent-hover: #99f6e4;
        --accent-strong: #38bdf8;
        --accent-text: #03151a;
        --fancy-wash: rgba(94, 234, 212, .14);
        --fancy-wash-strong: rgba(56, 189, 248, .12);
        --fancy-glass: rgba(20, 24, 34, .94);
        --fancy-shadow: 0 16px 48px rgba(0, 0, 0, .24);
    }
}
:root:not([data-theme]) .theme-control { visibility: hidden; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--canvas); color: var(--text); line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: right 22px center, right 16px center; background-size: 6px 6px; background-repeat: no-repeat; }
@media (forced-colors: active) {
    select { appearance: auto; background-image: none; }
}
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--selected); color: var(--accent); }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.page-width { width: calc(100% - 48px); margin-inline: auto; }
.view-layout { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.view-content { position: relative; min-height: 0; overflow-y: auto; margin-inline: -6px; padding: 0 6px 24px; scroll-padding: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -80px; left: 20px; padding: 12px 20px; background: var(--surface); z-index: 5; }
.skip-link:focus { top: 12px; }
[data-ui-icon] { display: inline-flex; align-items: center; justify-content: center; }
[data-ui-icon] svg { width: 18px; height: 18px; }
.library-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); position: relative; z-index: 2; }
.search-field { display: flex; align-items: center; gap: 10px; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; background: var(--surface); }
.search-field:focus-within { border-color: var(--accent); }
.search-field > span { color: var(--muted); }
.search-field input { height: 42px; width: 100%; min-width: 0; border: 0; background: transparent; outline: none; }
.search-field input::placeholder { color: var(--muted); }
kbd { border: 1px solid var(--border); border-radius: 4px; width: 22px; flex-shrink: 0; text-align: center; color: var(--muted); font-size: 11px; }
.category-select { min-width: 0; height: 42px; border: 1px solid var(--border); border-radius: var(--radius); background-color: var(--surface); padding: 0 40px 0 10px; font-size: 12px; }
.theme-control { display: inline-flex; align-items: center; gap: 7px; height: 42px; border: 1px solid var(--border); border-radius: 999px; padding: 0 10px 0 12px; background: var(--surface); }
.theme-control:has(select:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-control:has(select:focus-visible) select { outline: none; }
.theme-control > span { color: var(--muted); font-size: 11px; }
.theme-control select { font-size: 12px; font-weight: 600; border: none; background-color: transparent; padding: 5px 40px 5px 0; }
.library-nav { display: flex; align-items: center; justify-self: end; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.library-nav a { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 999px; color: var(--muted); }
.library-nav a:hover, .library-nav a[aria-current='page'] { color: var(--accent); background: var(--selected); }
.library-nav a[aria-current='page'] { box-shadow: inset 0 0 0 1px currentColor; }
.library-nav svg, .agent-tools svg, .search-field > svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.search-field > svg { width: 18px; height: 18px; color: var(--muted); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; border-radius: 6px; background: transparent; color: var(--muted); padding: 8px; }
.icon-button:hover { color: var(--accent); background: var(--selected); }
.collection-heading { padding: 6px 0 12px; }
.collection-heading h1 { font-size: 12px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.count { font-size: 10px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.icon-card { position: relative; height: 104px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px 5px; }
.icon-card svg { width: 28px; height: 28px; }
.icon-card-label { font-size: 11px; color: var(--muted); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.icon-card:hover { background: var(--hover); border-color: var(--accent); }
.icon-card[aria-pressed='true'] { color: var(--accent); background: var(--selected); border-color: var(--accent); }
.icon-card[aria-pressed='true'] .icon-card-label { color: var(--accent); }
.inspector { width: min(360px, calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); overflow-y: auto; }
.inspector::backdrop { background: #0008; }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.inspector-heading h2 { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.icon-tags { margin-bottom: 12px; color: var(--muted); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.icon-preview { height: 132px; border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; background-color: var(--soft); background-image: radial-gradient(var(--dot) .8px, transparent .8px); background-size: 12px 12px; }
.icon-preview svg { width: var(--preview-size, 48px); height: var(--preview-size, 48px); }
.export-options { margin: 12px 0; font-size: 11px; color: var(--muted); }
.export-options summary { padding: 5px 0; }
.export-options summary span { float: right; font-size: 10px; }
.preview-controls { display: flex; gap: 18px; padding: 12px 0 4px; }
.preview-controls label { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 6px; }
.select-wrap { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; font-size: 10px; }
.select-wrap select { width: 68px; background-color: transparent; color: var(--text); border: none; height: 32px; padding: 0 40px 0 7px; font-size: 11px; }
.format-switch { display: flex; gap: 2px; padding: 3px; background: var(--soft); border: 1px solid var(--border); border-radius: 7px; }
.format-switch button { flex: 1; min-height: 32px; font-size: 12px; padding: 6px 8px; border: none; border-radius: 4px; background: transparent; color: var(--muted); }
.format-switch button[aria-pressed='true'] { color: var(--text); background: var(--surface); font-weight: 600; }
.code-output { display: block; background: var(--soft); color: var(--accent); font: 11px/1.85 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--border); border-radius: 7px; width: 100%; height: 120px; resize: vertical; padding: 12px; margin: 12px 0; tab-size: 4; }
.copy-actions { display: flex; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 10px 14px; font-size: 12px; font-weight: 600; }
.button:hover { background: var(--hover); }
.agent-tools.button { width: 44px; height: 44px; padding: 0; justify-self: end; border-radius: 999px; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); flex: 1; }
.primary:hover { background: var(--accent-hover); }
.license-note { margin-top: 14px; text-align: center; font-size: 10px; color: var(--muted); }
.license-note a:hover { text-decoration: underline; }
.empty-state { text-align: center; padding: 64px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state h2 { font-size: 16px; color: var(--text); margin-bottom: 7px; }
.empty-state p { font-size: 12px; margin-bottom: 18px; }
.toast { padding: 10px; margin-top: 12px; border-radius: 6px; background: var(--selected); color: var(--accent); text-align: center; font-size: 12px; }
.noscript-note { padding: 25px; background: var(--selected); }

.template-library .collection-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.template-contrast[aria-pressed='true'] { color: var(--accent); background: var(--selected); border-color: var(--accent); }
.inspector .template-contrast { margin-top: 10px; }
.template-library .icon-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.template-library .icon-card { height: 260px; padding: 20px; gap: 16px; }
.template-library .icon-card svg { width: 100%; height: 174px; }
.template-library .icon-card-label { font-size: 12px; flex-shrink: 0; }
.template-library .inspector { width: min(680px, calc(100% - 32px)); }
.template-library .icon-preview { height: auto; min-height: 120px; padding: 18px; }
.template-library .icon-preview svg { display: block; width: 100%; height: auto; max-height: 300px; }
.template-artwork {
    --surface: #fff;
    --border: #e2e2e2;
    --soft: #f7f7f7;
    --selected: #edf6f4;
    --text: #000;
    --muted: #626262;
    --accent: #0f766e;
}
[data-template-tone='dark'] .template-artwork {
    --surface: #111;
    --border: #424242;
    --soft: #191919;
    --selected: #102d29;
    --text: #fff;
    --muted: #b0b0b0;
    --accent: #5eead4;
}
:root:is([data-theme='light2'], [data-theme='dark2']) .template-artwork {
    --border: #d8dde6;
    --soft: #f1f5f6;
    --selected: #e6f3ef;
    --text: #15171c;
    --muted: #555;
}
:root:is([data-theme='light2'], [data-theme='dark2']) [data-template-tone='dark'] .template-artwork {
    --surface: #141822;
    --border: #3e4656;
    --soft: #1b222d;
    --selected: #153832;
    --text: #f6f8fb;
    --muted: #b0b0b0;
}
.template-open { display: block; width: fit-content; padding: 10px 0 0; color: var(--accent); font-size: 12px; }
.template-open:hover { text-decoration: underline; }
.template-description { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.template-library .export-options p { margin: 8px 0 12px; }
#template-fields { margin: 0; }
#template-fields dt { color: var(--text); font-family: ui-monospace, monospace; margin-top: 10px; overflow-wrap: anywhere; }
#template-fields dd { margin: 3px 0 0; }

/* Light2 and Dark2 retain Jot and Clock's optional glass and static light washes. */
:root:is([data-theme='light2'], [data-theme='dark2'], :not([data-theme])) body {
    isolation: isolate;
    background-image:
        linear-gradient(120deg, var(--fancy-wash), transparent 38%),
        linear-gradient(240deg, var(--fancy-wash-strong), transparent 42%),
        linear-gradient(145deg, var(--canvas), var(--canvas-soft));
    background-attachment: fixed;
}
:root:is([data-theme='light2'], [data-theme='dark2'], :not([data-theme])) body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .14;
    background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 72%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 72%, transparent);
}
:root:is([data-theme='light2'], [data-theme='dark2'], :not([data-theme])) .inspector { box-shadow: var(--fancy-shadow); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    :root:is([data-theme='light2'], [data-theme='dark2'], :not([data-theme])) .inspector {
        background: var(--fancy-glass);
        -webkit-backdrop-filter: blur(20px) saturate(1.2);
        backdrop-filter: blur(20px) saturate(1.2);
    }
}
:root:is([data-theme='light2'], [data-theme='dark2'], :not([data-theme])) .primary { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
:root:is([data-theme='light2'], [data-theme='dark2'], :not([data-theme])) .primary:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent-strong)); }
@media (max-width: 740px) {
    .page-width { width: calc(100% - 28px); }
    .library-tools { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 0; }
    .search-field { grid-column: 1 / -1; }
    .theme-control { gap: 5px; padding: 0 7px; }
    .theme-control > span { display: none; }
    .theme-control select { font-size: 11px; }
    .library-nav { justify-self: start; }
    .category-select { font-size: 11px; }
    .icon-grid { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; }
    .icon-card { height: 94px; }
    .icon-card-label { font-size: 10px; }
}
