/* NowUTC - UTC Clock Widget Styles */

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

:root {
    --bg-color: #000000;
    --text-color: #FFFFFF;
    --accent-color: #4A90D9; /* rgba(74, 144, 217) variants also use this base color */

    /* Light/dark mode tokens. Dark is the default; html[data-mode="light"]
       swaps them. --ink is the RGB of lines and tints (rgba(var(--ink), a)).
       On the clock screen applyColors() sets --ink inline from the site
       background's luminance, so borders stay visible on any color. */
    --ink: 255, 255, 255;
    --fg: #FFFFFF;
    --page-bg: #000000;
    --surface: #0a0a0a;
    --surface-2: #1a1a1a;
    --code-color: #67e8f9;
    --ok-color: #4ade80;
    --ok2-color: #a3e635;
    --warn-color: #fbbf24;
    --err-color: #f87171;
    --muted-color: #999;
    --link-color: #7cb8f0;
    color-scheme: dark;
}

html[data-mode="light"] {
    --ink: 0, 0, 0;
    --fg: #111111;
    --page-bg: #F7F7F8;
    --surface: #FFFFFF;
    --surface-2: #FFFFFF;
    --code-color: #0e7490;
    --ok-color: #15803d;
    --ok2-color: #4d7c0f;
    --warn-color: #b45309;
    --err-color: #b91c1c;
    --muted-color: #555;
    --link-color: #1d4ed8;
    color-scheme: light;
}

/* One logo per mode: white globe on black for dark, navy on white for light */
.logo-for-light { display: none !important; }
html[data-mode="light"] .logo-for-light { display: inline-block !important; }
html[data-mode="light"] .logo-for-dark { display: none !important; }

/* Sun/moon switch: shows the mode you would switch TO */
.mode-toggle {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
}
.mode-icon-moon { display: none; }
html[data-mode="light"] .mode-icon-sun { display: none; }
html[data-mode="light"] .mode-icon-moon { display: inline-block; }

/* "Dark mode" / "Light mode" badge beside Settings headings */
.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(var(--ink), 0.2);
    background: rgba(var(--ink), 0.06);
    color: inherit;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
}
.mode-badge-swap { font-size: 0.65rem; opacity: 0.6; margin-left: 0.15rem; }
.mode-badge:hover { background: rgba(var(--ink), 0.14); border-color: rgba(var(--ink), 0.4); }
.mode-badge:focus-visible { outline: 2px solid #3B82F6; outline-offset: 2px; }
.mode-badge .mode-icon-moon { display: inline-block; }
.mode-badge .mode-icon-sun { display: none; }
html[data-mode="light"] .mode-badge .mode-icon-moon { display: none; }
html[data-mode="light"] .mode-badge .mode-icon-sun { display: inline-block; }

.mode-note {
    font-size: 0.82rem;
    opacity: 0.75;
    margin: -0.25rem 0 0.75rem;
}

.mode-warning {
    display: none;
    margin: 0.6rem 0 0;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--warn-color);
    border: 1px solid color-mix(in srgb, var(--warn-color) 45%, transparent);
    background: color-mix(in srgb, var(--warn-color) 10%, transparent);
}

/* Light mode: the few blue-tinted controls that were tuned for black */
html[data-mode="light"] .btn-share { color: #1d4ed8; }
html[data-mode="light"] .btn-danger { color: #b91c1c; border-color: rgba(185, 28, 28, 0.35); }
html[data-mode="light"] .btn-danger:hover { color: #fff; background: #b91c1c; }
html[data-mode="light"] .btn-share:hover { color: #0b2e7a; }
html[data-mode="light"] .about-link,
html[data-mode="light"] .site-nav-link[aria-current="page"] { color: #1d4ed8; }
html[data-mode="light"] .ref-code { background: #f1f5f9; }
/* Not .theme-preview: a `background` shorthand there wiped the theme image (config.js
   sets the preview's color inline). */
html[data-mode="light"] .config-section { background: #FFFFFF; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Screen-reader only utility */
.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;
}

/* Initial hidden state (flash prevention -- must load before body render) */
#countdown-display,
#format-tray,
#converter,
#desktop-container,
#desktop-countdown,
#desktop-pinned-bar,
#desktop-empty,
#desktop-format-tray,
#desktop-converter,
#utc-conv-tz-list,
#desktop-utc-conv-tz-list,
#view-toggle,
.wizard-overlay,
.wizard-step ~ .wizard-step,
.shortcut-overlay,
.tile-modal-overlay,
.tile-color-overlay {
    display: none;
}

/* ==========================================================================
   Widget page
   ========================================================================== */

[data-page="widget"] {
    overflow: hidden;
}

[data-page="widget"] #clock-container {
    text-align: center;
    user-select: none;
    max-width: 100vw;
    max-height: 100vh;
    padding: 0;
}

#utc-date {
    font-size: clamp(0.8rem, min(8vw, 11vh), 4rem);
    opacity: 0.5;
    line-height: 1.2;
}

#utc-time {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(2rem, min(28vw, 50vh), 40rem);
    font-weight: bold;
    cursor: pointer;
    line-height: 0.85;
    margin: -0.02em 0 -0.05em;
}

#utc-time:hover {
    opacity: 0.85;
}

#utc-time,
.desktop-utc-tile .tile-time {
    white-space: nowrap;
}

/* 12h: AM/PM rides smaller next to the digits so the clock stays on one line */
.utc-meridiem {
    font-size: 0.42em;
    margin-left: 0.1em;
    letter-spacing: 0;
}

/* 12h without seconds: "10:56 PM" is about 3.9em wide, so 28vw overflows a phone */
#utc-time.utc-time-12h {
    font-size: clamp(2rem, min(24vw, 50vh), 40rem);
}

/* HH:MM:SS (and h:MM:SS PM) is 8+ monospace characters; 28vw would overflow */
#utc-time.utc-time-long {
    font-size: clamp(2rem, min(17vw, 50vh), 40rem);
}

#tz-label {
    font-size: clamp(0.55rem, min(4vw, 5.5vh), 2.2rem);
    opacity: 0.6;
    letter-spacing: 0.05em;
    margin-top: 0.1em;
    white-space: nowrap;
}

/* Timezone row with arrows */
#tz-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.3rem, 1.5vw, 2rem);
}

#secondary-tz {
    font-size: clamp(0.85rem, min(8vw, 12vh), 4rem);
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 150ms ease;
}

.tz-arrow {
    font-size: clamp(0.5rem, min(5vw, 7vh), 3rem);
    opacity: 0.3;
    cursor: pointer;
    transition: opacity 200ms ease;
    user-select: none;
    line-height: 1;
}

.tz-arrow:hover,
.tz-arrow:focus-visible {
    opacity: 0.7;
}

/* Epoch timestamp */
#epoch-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.55rem, min(3.5vw, 5vh), 1.5rem);
    opacity: 0.45;
    cursor: pointer;
    margin-top: 0.2em;
    transition: opacity 200ms ease;
}

#epoch-display:hover {
    opacity: 0.7;
}

#epoch-ms-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.55rem, min(3.5vw, 5vh), 1.5rem);
    opacity: 0.45;
    cursor: pointer;
    transition: opacity 200ms ease;
}

#epoch-ms-display:hover {
    opacity: 0.7;
}

.epoch-sep {
    opacity: 0.25;
    font-size: clamp(0.45rem, min(2.5vw, 4vh), 1rem);
    user-select: none;
}

/* Countdown timer */
#countdown-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.6rem, min(5vw, 7vh), 2.5rem);
    opacity: 0.7;
    margin-top: 0.15em;
    letter-spacing: 0.05em;
}

#countdown-display.countdown-reached {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Copied notification */
#copied-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 40, 0.92);
    border: 1px solid rgba(59, 29, 192, 0.75);
    color: #ffffff;
    padding: 0.5em 1.5em;
    border-radius: 8px;
    font-size: clamp(1rem, 3vw, 2.5rem);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
    z-index: 300;
}

#copied-msg.visible {
    opacity: 1;
}

/* Widget popup link */
#widget-link {
    position: fixed;
    bottom: .75rem;
    right: 4.0rem;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 1.5rem;
    text-decoration: none;
    transition: opacity 200ms ease;
}

#widget-link:hover {
    opacity: 1.0;
}

/* Settings gear */
#settings-link {
    position: fixed;
    bottom: .75rem;
    right: 1.05rem;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 1.5rem;
    text-decoration: none;
    transition: opacity 200ms ease;
}

#settings-link:hover {
    opacity: 1.0;
}

/* Footer (widget page - fixed bottom) */
footer {
    position: fixed;
    bottom: 0.5rem;
    left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.footer-sep {
    opacity: 0.4;
}

.footer-link {
    color: inherit;
    text-decoration: none;
    transition: opacity 200ms ease;
}

.footer-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ==========================================================================
   Config page
   ========================================================================== */

/* Content pages share the RJL desktop frame: 105rem wide, 1rem / 1.5rem / 2rem
   side padding. Wide screens lay the sections out in a grid instead of one
   narrow column. */
[data-page="config"],
[data-page="reference"],
[data-page="about"] {
    background-color: var(--page-bg);
    color: var(--fg);
    justify-content: flex-start;
    padding: 1.5rem 0 2rem;
}

/* Same box as .site-header-inner and #desktop-container (border-box, padding
   inside the 105rem), so page content lines up under the header logo. */
[data-page="config"] main,
[data-page="reference"] main,
[data-page="about"] main {
    max-width: 105rem;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    [data-page="config"] main, [data-page="reference"] main, [data-page="about"] main { padding: 0 1.5rem; }
}
@media (min-width: 1024px) {
    [data-page="config"] main, [data-page="reference"] main, [data-page="about"] main { padding: 0 2rem; }
}

[data-page="config"] h1,
[data-page="reference"] h1,
[data-page="about"] h1 {
    margin-bottom: 0;
    font-size: 1.6rem;
}

/* Config: two independent columns of cards on desktop. Each column stacks on
   its own, so a short card is never stretched to its neighbor's height (a
   shared grid row did exactly that). Below 1100px the columns dissolve and
   the cs-order-N classes put the cards back in reading order. */
.config-sections {
    display: flex;
    flex-direction: column;
}

.config-col {
    display: contents;
}

.cs-order-1 { order: 1; }
.cs-order-2 { order: 2; }
.cs-order-3 { order: 3; }
.cs-order-4 { order: 4; }
.cs-order-5 { order: 5; }
.cs-order-6 { order: 6; }

@media (min-width: 1100px) {
    .config-sections {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 1.25rem;
        align-items: start;
    }
    .config-col {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }
    .config-col > .config-section { order: 0; }
}

/* Site Colors explainer: what the colors apply to, at a glance */
.color-help {
    display: grid;
    gap: 0.5rem;
    margin: 0.5rem 0 0.9rem;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(74, 144, 217, 0.35);
    background: rgba(74, 144, 217, 0.08);
}

.color-help-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.color-help-icon {
    flex: 0 0 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(74, 144, 217, 0.18);
    color: var(--accent-color);
    font-size: 0.8rem;
}

.color-help-item p {
    font-size: 0.85rem;
    line-height: 1.45;
    opacity: 0.85;
}

.tile-color-help {
    font-size: 0.8rem;
    opacity: 0.75;
    margin: 0 0 0.75rem;
    line-height: 1.4;
}

.tile-color-help a {
    color: var(--link-color);
}

/* Background theme picker (Settings) */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.theme-option {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: 8px;
    border: 2px solid rgba(var(--ink), 0.15);
    background-color: #111;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    font: inherit;
    color: #fff;
    transition: border-color 150ms ease, transform 150ms ease;
}

.theme-option:hover {
    border-color: rgba(var(--ink), 0.45);
}

.theme-option[aria-checked="true"] {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.35);
}

.theme-option-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.2rem 0.35rem;
    font-size: 0.72rem;
    text-align: left;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
}

.theme-option-check {
    position: absolute;
    top: 0.25rem;
    right: 0.3rem;
    font-size: 0.8rem;
    color: var(--accent-color);
    display: none;
}

.theme-option[aria-checked="true"] .theme-option-check {
    display: block;
}

/* Preview: a small copy of the clock screen with the chosen colors + theme */
.theme-preview {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    border: 1px solid rgba(var(--ink), 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    padding: 1rem;
    background-size: cover;
    background-position: center;
}

/* Same veil + image the clock screen uses (the theme rules set the vars on any
   element carrying data-bg-theme, including this preview) */
.theme-preview[data-bg-theme] {
    background-image:
        linear-gradient(color-mix(in srgb, var(--preview-bg, #000) var(--bg-theme-veil), transparent),
                        color-mix(in srgb, var(--preview-bg, #000) var(--bg-theme-veil), transparent)),
        var(--bg-theme-img);
}

.theme-preview[data-bg-theme] .theme-preview-utc {
    text-shadow: 0 2px 12px color-mix(in srgb, var(--preview-bg, #000) 70%, transparent);
}

.theme-preview-utc {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.theme-preview-label {
    font-size: 0.75rem;
    opacity: 0.7;
    letter-spacing: 0.1em;
}

.theme-preview-time {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1;
}

.theme-preview-tiles {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.theme-preview-tile {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    font-size: 0.75rem;
    border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    background: color-mix(in srgb, var(--preview-bg, #000) 55%, transparent);
    backdrop-filter: blur(6px);
}

.theme-preview-tile strong {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
}

.theme-preview-name {
    position: absolute;
    top: 0.5rem;
    left: 0.6rem;
    font-size: 0.72rem;
    opacity: 0.75;
}

/* Reference: full-width overview + parameters, the rest in columns */
.ref-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 2rem;
    align-items: start;
}

@media (min-width: 1100px) {
    .ref-sections { grid-template-columns: 1fr 1fr; }
    .ref-sections .section-wide { grid-column: 1 / -1; }
}

/* Grid items default to min-width:auto and would stretch to their widest table */
.config-sections > *,
.ref-sections > *,
.about-page > * {
    min-width: 0;
}

/* Wide tables and code scroll inside their own box on phones, never the page */
@media (max-width: 640px) {
    .ref-table {
        display: block;
        overflow-x: auto;
    }
}

/* Logo + domain lockup at the top of each content page */
.page-brand-name {
    display: block;
    font-size: 0.95rem;
    opacity: 0.6;
    letter-spacing: 0.02em;
}

.page-brand-name strong {
    font-weight: 800;
}

/* About: story full width, the rest in three columns on desktop */
.about-page {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 2rem;
    align-items: start;
}

@media (min-width: 1100px) {
    .about-page { grid-template-columns: repeat(3, 1fr); }
    .about-page .about-story { grid-column: 1 / -1; max-width: 80rem; }
}

.about-story p {
    font-size: 1.05rem;
}

.about-signoff {
    font-style: italic;
}

/* Branding header */
.page-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.brand-logo {
    border-radius: 10px;
}

/* Config sections */
.config-section {
    border: 1px solid rgba(var(--ink), 0.15);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.config-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-section h3 {
    font-size: 0.95rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.section-desc {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 0.75rem;
}

/* Radio group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    margin: -0.3rem -0.5rem;
    transition: background 200ms ease;
}

.radio-label:hover {
    background: rgba(var(--ink), 0.06);
}

.radio-label input[type="radio"],
.radio-label input[type="checkbox"] {
    accent-color: var(--accent-color);
}

/* Two-column timezone grid */
.tz-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.tz-grid-col {
    position: relative;
}

.tz-grid-col h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

/* Two-column color grid */
.color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 550px) {
    .tz-grid,
    .color-grid {
        grid-template-columns: 1fr;
    }
}

/* Timezone search */
#tz-search {
    width: 100%;
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

#tz-search::placeholder {
    color: rgba(var(--ink), 0.4);
}

#tz-search:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

/* Timezone list */
#tz-list {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 10;
    overflow: hidden;
    border: 1px solid rgba(var(--ink), 0.1);
    border-radius: 4px;
    background: var(--surface);
}

.tz-option {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, padding-left 150ms ease;
}

.tz-option:hover {
    background: rgba(74, 144, 217, 0.3);
    color: var(--link-color);
    padding-left: 1rem;
}

.tz-option.tz-empty {
    color: rgba(var(--ink), 0.4);
    cursor: default;
    font-style: italic;
}

.tz-option.tz-empty:hover {
    background: transparent;
}

/* Favorites chips */
#favorites-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 2rem;
}

.fav-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(74, 144, 217, 0.25);
    border: 1px solid rgba(74, 144, 217, 0.4);
    border-radius: 16px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    color: var(--fg);
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease, transform 150ms ease;
}

.fav-chip:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.5);
    transform: translateY(-1px);
}

.fav-chip-x {
    color: rgba(var(--ink), 0.4);
    font-size: 0.75rem;
    line-height: 1;
}

.fav-chip:hover .fav-chip-x {
    color: var(--err-color);
}

.fav-empty {
    font-size: 0.8rem;
    color: rgba(var(--ink), 0.4);
    font-style: italic;
    padding: 0.25rem 0;
}

/* Quick Add US Timezones */
.quick-add-box {
    margin-top: 1rem;
    border: 1px solid rgba(74, 144, 217, 0.3);
    border-radius: 8px;
    padding: 0.75rem;
    background: rgba(74, 144, 217, 0.06);
}

.quick-add-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: rgba(var(--ink), 0.7);
}

.quick-add-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.quick-add-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(var(--ink), 0.05);
    border: 1px solid rgba(var(--ink), 0.1);
    border-radius: 16px;
    padding: 0.25rem 0.6rem;
    color: var(--fg);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease, transform 150ms ease, box-shadow 200ms ease;
}

.quick-add-item:hover {
    background: rgba(74, 144, 217, 0.25);
    border-color: rgba(74, 144, 217, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.2);
}

.quick-add-plus {
    color: var(--ok-color);
    font-weight: bold;
    font-size: 0.85rem;
    line-height: 1;
}

/* Color picker row */
.color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.color-row label {
    min-width: 90px;
    font-size: 0.9rem;
}

.color-row input[type="color"] {
    width: 40px;
    height: 32px;
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
}

.color-row input[type="text"] {
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-family: 'Courier New', Courier, monospace;
    width: 100px;
}

/* Color scheme grid */
.color-schemes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.color-scheme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.5rem 0.25rem;
    border: 2px solid rgba(var(--ink), 0.15);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 150ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.color-scheme-swatch:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(var(--ink), 0.15);
    border-color: rgba(var(--ink), 0.4);
}

.color-scheme-swatch.scheme-active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color), 0 3px 10px rgba(74, 144, 217, 0.3);
}

.scheme-preview {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1;
}

.scheme-label {
    font-size: 0.6rem;
    opacity: 0.7;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.scheme-delete {
    position: absolute;
    top: -0.4rem;
    right: -0.4rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
}

.color-scheme-swatch:hover .scheme-delete {
    display: flex;
}

.scheme-add {
    border-style: dashed;
    border-color: rgba(var(--ink), 0.25);
    background: transparent;
    color: rgba(var(--ink), 0.5);
}

.scheme-add:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Color preview */
#color-preview {
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    border: 1px solid rgba(var(--ink), 0.1);
    background: #000;
    color: #fff;
}

.preview-time {
    display: block;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 0.3rem;
}

.preview-label {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Contrast info */
#contrast-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.3rem 0;
}

.contrast-excellent {
    color: var(--ok-color);
}

.contrast-good {
    color: var(--ok2-color);
}

.contrast-warning {
    color: var(--warn-color);
}

.contrast-error {
    color: var(--err-color);
}

/* Widget size inputs */
.widget-size-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.widget-size-row label {
    font-size: 0.9rem;
}

.widget-size-row input[type="number"] {
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-family: 'Courier New', Courier, monospace;
    width: 80px;
}

.widget-size-row input[type="number"]:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

.size-unit {
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Buttons */
.config-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
    align-items: center;
}

.data-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#import-file {
    display: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity 150ms ease, background 200ms ease, transform 150ms ease, box-shadow 200ms ease;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
}

.btn-primary:hover {
    background: #3a7bc4;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(74, 144, 217, 0.3);
}

.btn-primary:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(var(--ink), 0.1);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
}

.btn-secondary:hover {
    background: rgba(var(--ink), 0.18);
    transform: translateY(-1px);
}

.btn-widget {
    background: rgba(var(--ink), 0.06);
    color: rgba(var(--ink), 0.7);
    border: 1px solid rgba(var(--ink), 0.12);
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
}

.btn-widget:hover {
    color: var(--fg);
    background: rgba(var(--ink), 0.12);
    transform: translateY(-1px);
}

.btn-share {
    background: rgba(74, 144, 217, 0.12);
    color: rgba(180, 210, 240, 0.85);
    border: 1px solid rgba(74, 144, 217, 0.25);
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
}

.btn-share:hover {
    color: var(--fg);
    background: rgba(74, 144, 217, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: rgba(252, 165, 165, 0.85);
    border: 1px solid rgba(239, 68, 68, 0.25);
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
}

.btn-danger:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

/* Focus outlines */
:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Config/About footer (static, centered) */
[data-page="config"] footer,
[data-page="reference"] footer,
[data-page="about"] footer {
    position: static;
    margin-top: 2rem;
    justify-content: center;
    width: 100%;
    opacity: 0.5;
}

/* ==========================================================================
   About page
   ========================================================================== */

.about-section {
    margin-bottom: 1.5rem;
}

.about-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.about-section p {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.about-list {
    list-style: none;
    padding: 0;
}

.about-list li {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.8;
    padding-left: 1.2rem;
    position: relative;
    margin-bottom: 0.3rem;
}

.about-list li::before {
    content: '\2022';
    position: absolute;
    left: 0;
    color: var(--accent-color);
}

.about-link {
    color: var(--accent-color);
    text-decoration: none;
    transition: opacity 200ms ease;
}

.about-link:hover {
    text-decoration: underline;
}

/* Reference tables */
.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.ref-table th,
.ref-table td {
    border: 1px solid rgba(var(--ink), 0.12);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.ref-table th {
    background: rgba(var(--ink), 0.06);
    font-weight: 600;
    white-space: nowrap;
}

.ref-table td code {
    background: rgba(var(--ink), 0.06);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.ref-table-compact td:first-child {
    white-space: nowrap;
}

.ref-code {
    background: var(--surface);
    color: var(--code-color);
    border: 1px solid rgba(var(--ink), 0.12);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.about-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* About hero: RJ and the NowUTC clock watching the world. One image per mode,
 * swapped by html[data-mode] like the logos. Full image, never cropped, so the
 * brand badge baked into the bottom-right corner stays visible. */
.about-hero {
    margin: 2rem 0 0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
}
.about-hero img {
    display: block;
    width: 100%;
    height: auto;
}
.about-hero .hero-for-light { display: none; }
html[data-mode="light"] .about-hero .hero-for-light { display: block; }
html[data-mode="light"] .about-hero .hero-for-dark { display: none; }
html[data-mode="light"] .about-hero { box-shadow: 0 18px 50px rgba(30, 58, 138, 0.18); }

/* Image guard: original art is protected from casual saving. The pointer passes
 * through the image to its parent, so right-click and long-press never offer
 * "Save image" and it cannot be dragged out. Deterrent, not DRM. Pairs with
 * initImageGuard() in src/js/main.js. */
.img-protect {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}
/* Chrome's context-menu hit test still finds an image under pointer-events: none, so every
 * protected image sits in this wrapper and a transparent overlay takes the right-click. */
.img-protect-wrap { display: block; position: relative; }
.img-protect-wrap::after { content: ""; position: absolute; inset: 0; }

/* Scrollbar for tz-list */
#tz-list::-webkit-scrollbar {
    width: 6px;
}

#tz-list::-webkit-scrollbar-track {
    background: transparent;
}

#tz-list::-webkit-scrollbar-thumb {
    background: rgba(var(--ink), 0.2);
    border-radius: 3px;
}

#tz-list::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--ink), 0.35);
}

/* DST transition indicator */
.dst-indicator {
    color: var(--warn-color);
    font-weight: 600;
}

/* ==========================================================================
   Format copy tray
   ========================================================================== */

.format-tray {
    position: fixed;
    bottom: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.96);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    width: clamp(280px, 80vw, 520px);
    max-height: 85vh;
    z-index: 150;
}

.format-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: background 150ms ease;
    font-size: clamp(0.55rem, min(2.5vw, 3vh), 0.9rem);
}

.format-row:hover {
    background: rgba(74, 144, 217, 0.2);
}

.format-row + .format-row {
    border-top: 1px solid rgba(var(--ink), 0.06);
}

.format-label {
    min-width: 5.5em;
    opacity: 0.7;
    font-size: 1.3em;
    text-align: right;
}

.format-value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.3em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.format-icon {
    opacity: 0.3;
    font-size: 1.3em;
    flex-shrink: 0;
}

.format-row:hover .format-icon {
    opacity: 0.7;
}

/* ==========================================================================
   Epoch row + converter toggle
   ========================================================================== */

#epoch-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.3rem, 1vw, 0.6rem);
}

#timer-toggle {
    font-size: clamp(0.55rem, min(3vw, 4.5vh), 1.2rem);
    opacity: 0.35;
    cursor: pointer;
    transition: opacity 200ms ease;
}

#timer-toggle:hover,
#timer-toggle:focus-visible {
    opacity: 0.7;
}

#converter-toggle {
    font-size: clamp(0.55rem, min(3vw, 4.5vh), 1.2rem);
    opacity: 0.35;
    cursor: pointer;
    transition: opacity 200ms ease;
}

#converter-toggle:hover,
#converter-toggle:focus-visible {
    opacity: 0.7;
}

/* ==========================================================================
   Timestamp converter
   ========================================================================== */

#converter {
    position: fixed;
    bottom: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 8px;
    width: clamp(280px, 80vw, 520px);
    max-height: 65vh;
    overflow-y: auto;
    z-index: 160;
    padding: 0.5rem;
}

.converter-input-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

#converter-input {
    flex: 1;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.45rem 0.6rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
}

#converter-input::placeholder {
    color: rgba(var(--ink), 0.35);
}

#converter-input:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

.converter-close-btn {
    background: none;
    border: none;
    color: rgba(var(--ink), 0.5);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.3rem;
    transition: color 150ms ease;
}

.converter-close-btn:hover {
    color: var(--fg);
}

#converter-results {
    margin-top: 0.3rem;
}

.converter-error {
    color: var(--err-color);
    font-size: 0.8rem;
    padding: 0.3rem 0;
}

/* Converter tabs */
.converter-tabs {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(var(--ink), 0.1);
    margin-bottom: 0.4rem;
    padding: 0 0.25rem;
}

.converter-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(var(--ink), 0.4);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: color 150ms ease, border-color 150ms ease;
}

.converter-tab:hover {
    color: rgba(var(--ink), 0.7);
}

.converter-tab.active {
    color: var(--fg);
    border-bottom-color: var(--accent-color);
}

.converter-tabs .converter-close-btn {
    margin-left: auto;
}

/* To UTC panel */
.utc-conv-tz-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.3rem;
}

.utc-conv-tz-row input[type="text"] {
    flex: 1;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
}

.utc-conv-tz-row input[type="text"]::placeholder {
    color: rgba(var(--ink), 0.35);
}

.utc-conv-tz-row input[type="text"]:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

.utc-conv-tz-selected {
    background: rgba(74, 144, 217, 0.25);
    border: 1px solid rgba(74, 144, 217, 0.4);
    border-radius: 12px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    color: var(--fg);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.utc-conv-tz-selected:empty {
    display: none;
}

.utc-conv-tz-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(var(--ink), 0.1);
    border-radius: 4px;
    background: var(--surface);
    margin-top: 0.25rem;
}

.utc-conv-tz-option {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--fg);
    transition: background 150ms ease, padding-left 150ms ease;
}

.utc-conv-tz-option:hover {
    background: rgba(74, 144, 217, 0.3);
    padding-left: 1rem;
}

.utc-conv-tz-option + .utc-conv-tz-option {
    border-top: 1px solid rgba(var(--ink), 0.06);
}

/* ==========================================================================
   Desktop tile grid view
   ========================================================================== */

[data-view="desktop"] #clock-container,
[data-view="desktop"] #epoch-row,
[data-view="desktop"] #epoch-ms-display,
[data-view="desktop"] #tz-row,
[data-view="desktop"] #tz-label,
[data-view="desktop"] #format-tray,
[data-view="desktop"] #converter { display: none !important; }

[data-view="desktop"] {
    justify-content: flex-start;
    padding: 2rem 0;
    overflow: auto;
}

[data-view="desktop"] main {
    display: none;
}

[data-view="widget"] #desktop-container,
[data-view="widget"] #desktop-format-tray,
[data-view="widget"] #desktop-converter { display: none !important; }

@media (max-width: 899px) {
    #view-toggle { display: none !important; }
}

#desktop-container {
    max-width: 105rem;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) { #desktop-container { padding: 0 1.5rem; } }
@media (min-width: 1024px) { #desktop-container { padding: 0 2rem; } }

.desktop-header {
    margin-bottom: 1.5rem;
}

.desktop-utc-tile {
    background: rgba(var(--ink), 0.04);
    border: 1px solid rgba(var(--ink), 0.12);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    text-align: center;
    position: relative;
}

.desktop-utc-tile .tile-label {
    font-size: 0.9rem;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

.desktop-utc-tile .tile-time {
    font-family: 'Courier New', Courier, monospace;
    font-size: 4rem;
    font-weight: bold;
    line-height: 1.1;
}

.desktop-utc-tile .tile-date {
    font-size: 1rem;
    opacity: 0.5;
    margin-top: 0.25rem;
}

/* Tile icon row (flex container replacing absolute positioning) */
.tile-icons {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.tile-drag,
.tile-pin,
.tile-copy,
.tile-popup,
.tile-converter-toggle,
.tile-share,
.tile-color-btn,
.tile-remove {
    opacity: 0.3;
    cursor: pointer;
    font-size: 0.85rem;
    transition: opacity 200ms ease;
}

.tile-drag:hover,
.tile-drag:focus-visible,
.tile-pin:hover,
.tile-pin:focus-visible,
.tile-copy:hover,
.tile-copy:focus-visible,
.tile-popup:hover,
.tile-popup:focus-visible,
.tile-converter-toggle:hover,
.tile-converter-toggle:focus-visible,
.tile-share:hover,
.tile-share:focus-visible,
.tile-color-btn:hover,
.tile-color-btn:focus-visible,
.tile-remove:hover,
.tile-remove:focus-visible {
    opacity: 0.8;
}

.desktop-tile:hover .tile-drag,
.desktop-tile:hover .tile-pin,
.desktop-utc-tile:hover .tile-pin,
.desktop-tile:hover .tile-copy,
.desktop-tile:hover .tile-popup,
.desktop-tile:hover .tile-converter-toggle,
.desktop-tile:hover .tile-share,
.desktop-tile:hover .tile-color-btn,
.desktop-tile:hover .tile-remove,
.desktop-utc-tile:hover .tile-copy,
.desktop-utc-tile:hover .tile-popup,
.desktop-utc-tile:hover .tile-converter-toggle {
    opacity: 0.6;
}

/* Legacy standalone tile-copy for UTC tile (no .tile-icons parent) */
.desktop-utc-tile > .tile-copy {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1rem;
}

.desktop-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.desktop-tile {
    background: rgba(var(--ink), 0.03);
    border: 1px solid rgba(var(--ink), 0.08);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    position: relative;
    transition: border-color 200ms ease, background 200ms ease;
    cursor: default;
}

.desktop-tile:hover {
    border-color: rgba(var(--ink), 0.2);
    background: rgba(var(--ink), 0.05);
}

.desktop-tile .tile-city {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.desktop-tile .tile-custom-label {
    font-size: 0.75rem;
    opacity: 0.4;
}

.desktop-tile .tile-time {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.2;
}

.desktop-tile .tile-meta {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: 0.15rem;
}

.desktop-tile .tile-dst {
    color: var(--warn-color);
    font-weight: 600;
    font-size: 0.75rem;
}

.desktop-tile .tile-copy {
    font-size: 0.85rem;
}

.tile-remove:hover {
    color: var(--err-color);
}

/* Tile reordering (drag-and-drop, or the grip handle + arrow keys) */
.tile-drag {
    cursor: grab;
}

.tile-drag:active {
    cursor: grabbing;
}

.desktop-tile.tile-dragging {
    opacity: 0.4;
}

/* Insertion marker -- which side of this tile the dragged one will land on */
.desktop-tile.tile-drop-before,
.desktop-tile.tile-drop-after {
    position: relative;
}

.desktop-tile.tile-drop-before::before,
.desktop-tile.tile-drop-after::after {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.7;
}

.desktop-tile.tile-drop-before::before {
    left: -6px;
}

.desktop-tile.tile-drop-after::after {
    right: -6px;
}

@media (prefers-reduced-motion: reduce) {
    .desktop-tile.tile-dragging {
        opacity: 0.6;
    }
}

/* ==========================================================================
   Pinned time (click a tile's time to freeze every clock at that moment)
   ========================================================================== */

.tile-time-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    width: 100%;
}

/* The UTC tile centers its contents with text-align, which a flex row ignores.
   Re-center on the flex axis or the big clock jumps to the left edge. */
.desktop-utc-tile .tile-time-row {
    justify-content: center;
}

.desktop-tile .tile-time,
.desktop-utc-tile .tile-time {
    cursor: text;
}

.desktop-utc-tile > .tile-pin {
    position: absolute;
    top: 0.75rem;
    right: 7.75rem;
}

/* Day badge and the editor both inherit the tile's color, which may be a
   per-tile custom value applied as an inline style. Never set a literal color
   here or a custom-colored tile will render an unreadable badge. */
.tile-day-badge {
    display: none;   /* JS flips to inline-block only while pinned */
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border: 1px solid currentColor;
    border-radius: 4px;
    opacity: 0.75;
    white-space: nowrap;
}

/* Fill the row rather than a fixed ch width: "12:30 AM" is 8 characters and a
   narrow box just scrolls the text, hiding the leading digit. min-width:0 lets
   the flex item actually shrink inside the tile instead of overflowing it. */
.tile-time-input {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.2;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    padding: 0;
    background: transparent;
    color: inherit;
    border: none;
    border-bottom: 2px solid currentColor;
    outline: none;
    box-sizing: border-box;
}

.desktop-utc-tile .tile-time-input {
    font-size: 4rem;
    text-align: center;
}

.desktop-pinned-bar {
    display: none;   /* JS flips to flex */
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--warn-color);
    border-radius: 8px;
    background: rgba(251, 191, 36, 0.08);
    font-size: 0.9rem;
}

.desktop-pinned-bar .fa-thumbtack {
    color: var(--warn-color);
}

.pinned-clear {
    margin-left: auto;
    white-space: nowrap;
}

/* An OUTLINE, not a border/background: setTileColor writes backgroundColor,
   color and borderColor as inline styles, so anything else would be either
   overridden or would clobber a custom tile color. */
.desktop-tile.tile-pinned-source,
.desktop-utc-tile.tile-pinned-source {
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
}

.desktop-tile.tile-edit-error,
.desktop-utc-tile.tile-edit-error {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

/* Per-tile popup/converter on UTC tile (absolute positioned, no .tile-icons) */
.desktop-utc-tile > .tile-popup {
    position: absolute;
    top: 0.75rem;
    right: 2.5rem;
}

.desktop-utc-tile > .tile-converter-toggle {
    position: absolute;
    top: 0.75rem;
    right: 4.25rem;
}

.desktop-utc-tile > .tile-timer-toggle {
    position: absolute;
    top: 0.75rem;
    right: 6rem;
    opacity: 0.3;
    font-size: 0.75rem;
    cursor: pointer;
    transition: opacity 200ms ease;
}

.desktop-utc-tile:hover > .tile-timer-toggle {
    opacity: 0.6;
}

.tile-timer-toggle:hover,
.tile-timer-toggle:focus-visible {
    opacity: 0.8 !important;
}

.desktop-countdown {
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.2rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    letter-spacing: 0.05em;
}

.desktop-countdown.countdown-reached {
    animation: pulse 1s ease-in-out infinite;
}

/* Timer modal */
.timer-desc {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 0.5rem;
    color: var(--fg);
}

.timer-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Desktop add-tile button */
.desktop-add-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 2px dashed rgba(var(--ink), 0.15);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: border-color 200ms ease, background 200ms ease;
    min-height: 100px;
}

.desktop-add-tile:hover {
    border-color: var(--accent-color);
    background: rgba(74, 144, 217, 0.06);
}

.add-tile-icon {
    font-size: 2rem;
    opacity: 0.4;
    line-height: 1;
}

.add-tile-label {
    font-size: 0.8rem;
    opacity: 0.4;
}

.desktop-add-tile:hover .add-tile-icon,
.desktop-add-tile:hover .add-tile-label {
    opacity: 0.7;
}

/* Tile modal overlay (shared by quick-add and timer) */
.tile-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    align-items: center;
    justify-content: center;
    z-index: 220;
}

.tile-modal-card {
    background: var(--surface-2);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    max-width: 400px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.tile-modal-search {
    width: 100%;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.tile-modal-search::placeholder {
    color: rgba(var(--ink), 0.4);
}

.tile-modal-search:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

.tile-modal-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(var(--ink), 0.1);
    border-radius: 4px;
}

.tile-modal-tz-option {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--fg);
    transition: background 150ms ease, padding-left 150ms ease;
}

.tile-modal-tz-option:hover {
    background: rgba(74, 144, 217, 0.3);
    padding-left: 1rem;
}

.tile-modal-tz-option + .tile-modal-tz-option {
    border-top: 1px solid rgba(var(--ink), 0.06);
}

.tile-modal-tz-empty {
    color: rgba(var(--ink), 0.4);
    cursor: default;
    font-style: italic;
}

.tile-modal-tz-empty:hover {
    background: transparent;
    padding-left: 0.75rem;
}

.quick-add-section {
    margin-bottom: 0.5rem;
}

.quick-add-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
    padding: 0.35rem 0.75rem 0.2rem;
}

.quick-add-us-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem 0.5rem;
}

.quick-add-us-btn {
    background: rgba(74, 144, 217, 0.15);
    border: 1px solid rgba(74, 144, 217, 0.3);
    border-radius: 6px;
    color: var(--fg);
    font-size: 0.78rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
}

.quick-add-us-btn:hover {
    background: rgba(74, 144, 217, 0.35);
    border-color: rgba(74, 144, 217, 0.6);
}

.quick-add-divider {
    border: none;
    border-top: 1px solid rgba(var(--ink), 0.1);
    margin: 0 0.75rem 0.4rem;
}

.quick-add-other-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
    padding: 0 0.75rem 0.3rem;
}

/* Tile color picker overlay */
.tile-color-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    align-items: center;
    justify-content: center;
    z-index: 220;
}

.tile-color-card {
    background: var(--surface-2);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    max-width: 360px;
    width: 90vw;
}

.tile-color-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.tile-color-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
}

.tile-color-close {
    background: none;
    border: none;
    color: rgba(var(--ink), 0.5);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    transition: color 150ms ease;
}

.tile-color-close:hover {
    color: var(--fg);
}

.tile-color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.tile-cs-swatch {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 2px solid rgba(var(--ink), 0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    transition: transform 150ms ease, border-color 200ms ease;
}

.tile-cs-swatch:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.tile-cs-swatch.scheme-active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color), 0 2px 6px rgba(74, 144, 217, 0.3);
}

.tile-color-reset-btn {
    width: 100%;
    justify-content: center;
}

/* Clickable tile text */
.tile-time,
.tile-date,
.tile-label,
.tile-city,
.tile-meta {
    cursor: pointer;
}

/* Desktop format tray (floating, positioned by JS) */
.desktop-format-tray {
    position: fixed;
    z-index: 200;
    width: clamp(280px, 40vw, 480px);
    bottom: auto;
    left: auto;
    transform: none;
}

.format-tray-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgba(var(--ink), 0.1);
}

.format-tray-title {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.7;
}

.format-tray-close {
    background: none;
    border: none;
    color: rgba(var(--ink), 0.5);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    transition: color 150ms ease;
}

.format-tray-close:hover {
    color: var(--fg);
}

/* Desktop converter (centered overlay) */
.desktop-converter {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 8px;
    width: clamp(320px, 50vw, 560px);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 210;
    padding: 0.5rem;
}

#desktop-converter-input {
    flex: 1;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.45rem 0.6rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
}

#desktop-converter-input::placeholder {
    color: rgba(var(--ink), 0.35);
}

#desktop-converter-input:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

#desktop-converter-results {
    margin-top: 0.3rem;
}

.desktop-empty {
    text-align: center;
    padding: 3rem 1rem;
    opacity: 0.6;
}

.desktop-empty p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* View toggle icon */
#view-toggle {
    position: fixed;
    bottom: .75rem;
    right: 7.0rem;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 1.5rem;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 200ms ease;
}

#view-toggle:hover {
    opacity: 1.0;
}

/* Hide view toggle in embed/popup */
.embed-mode #view-toggle { display: none !important; }

/* ==========================================================================
   First-time wizard overlay
   ========================================================================== */

.wizard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    align-items: center;
    justify-content: center;
    z-index: 250;
    padding: 1rem;
}

.wizard-card {
    background: var(--surface-2);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.wizard-progress {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.wizard-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(var(--ink), 0.2);
    transition: background 200ms ease;
}

.wizard-dot.active {
    background: var(--accent-color);
}

.wizard-dot.completed {
    background: #4ade80;
}

.wizard-icon {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.wizard-title {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--fg);
}

.wizard-text {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.8;
    color: var(--fg);
    text-align: center;
    margin-bottom: 0.5rem;
}

.wizard-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0;
}

.wizard-list li {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.8;
    color: var(--fg);
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.2rem;
}

.wizard-list li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--ok-color);
    font-weight: bold;
}

/* Wizard color presets */
.wizard-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.wizard-preset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 2px solid rgba(var(--ink), 0.15);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: transform 150ms ease, border-color 200ms ease, box-shadow 200ms ease;
    background: none;
}

.wizard-preset:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wizard-preset.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color), 0 4px 12px rgba(74, 144, 217, 0.3);
}

/* Wizard timezone picker */
.wizard-tz-search {
    width: 100%;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.wizard-tz-search::placeholder {
    color: rgba(var(--ink), 0.4);
}

.wizard-tz-search:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
    border-color: transparent;
}

.wizard-tz-list {
    position: relative;
    z-index: 10;
    overflow: hidden;
    border: 1px solid rgba(var(--ink), 0.1);
    border-radius: 4px;
    background: var(--surface);
    margin-bottom: 0.5rem;
}

.wizard-favorites {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 1rem;
    margin-bottom: 0.5rem;
}

/* Wizard tips */
.wizard-tips {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0.75rem 0;
}

.wizard-tip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: rgba(var(--ink), 0.8);
    padding: 0.4rem 0.6rem;
    background: rgba(var(--ink), 0.04);
    border-radius: 8px;
}

.wizard-tip i,
.wizard-tip kbd {
    min-width: 2rem;
    text-align: center;
    color: var(--accent-color);
    font-size: 1rem;
}

.wizard-ready {
    margin-top: 0.75rem;
    font-weight: 600;
    color: var(--ok-color) !important;
    opacity: 1 !important;
}

/* Wizard navigation */
.wizard-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.25rem;
    gap: 0.5rem;
}

.wizard-btn {
    min-width: 80px;
}

.wizard-skip {
    background: none;
    border: none;
    color: rgba(var(--ink), 0.4);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    transition: color 200ms ease;
}

.wizard-skip:hover {
    color: rgba(var(--ink), 0.7);
}

@media (max-width: 480px) {
    .wizard-card {
        padding: 1rem 1.25rem;
        border-radius: 12px;
    }

    .wizard-presets {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .wizard-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .wizard-skip {
        order: 3;
        width: 100%;
        text-align: center;
        margin-top: 0.25rem;
    }
}

/* ==========================================================================
   Keyboard shortcut overlay
   ========================================================================== */

.shortcut-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.shortcut-card {
    background: var(--surface-2);
    border: 1px solid rgba(59, 29, 192, 0.75);
    border-radius: 12px;
    padding: .5rem 1rem;
    max-width: 340px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.shortcut-title {
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--fg);
    text-align: center;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    color: rgba(var(--ink), 0.8);
}

.shortcut-row span {
    margin-left: auto;
}

.shortcut-hint {
    margin-top: 0.1rem;
    font-size: 0.7rem;
    opacity: 0.4;
    text-align: center;
}

kbd {
    display: inline-block;
    background: rgba(var(--ink), 0.1);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.15em 0.45em;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    min-width: 1.6em;
    text-align: center;
    color: var(--fg);
}

/* ==========================================================================
   Embed mode
   ========================================================================== */

.embed-mode footer,
.embed-mode #widget-link,
.embed-mode #settings-link,
.embed-mode #converter-toggle,
.embed-mode #timer-toggle { display: none !important; }

.embed-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.embed-textarea {
    width: 100%;
    background: var(--surface);
    color: var(--code-color);
    border: 1px solid rgba(var(--ink), 0.15);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    resize: vertical;
}

.embed-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.embed-options label {
    font-size: 0.85rem;
    opacity: 0.7;
}

.embed-options input[type="text"] {
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid rgba(var(--ink), 0.2);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-family: 'Courier New', Courier, monospace;
    width: 70px;
}

/* ==========================================================================
   View Transitions (progressive enhancement)
   ========================================================================== */

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-fade-out 150ms ease-out; }
::view-transition-new(root) { animation: vt-fade-in 150ms ease-in; }
@keyframes vt-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   Reduced motion preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    #countdown-display.countdown-reached { animation: none; }
    ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0s; }
    #secondary-tz, .tz-arrow, #epoch-display, #epoch-ms-display, #widget-link,
    #settings-link, #copied-msg, .tz-option, .fav-chip,
    .quick-add-item, .color-preset, .btn, .btn-danger, .radio-label,
    .wizard-dot, .wizard-preset, .wizard-skip,
    .tile-popup, .tile-converter-toggle, .tile-copy, .tile-share,
    .tile-color-btn, .tile-remove, .tile-timer-toggle, .format-tray-close, .desktop-countdown,
    .color-scheme-swatch, .tile-cs-swatch, .desktop-add-tile,
    .quick-add-us-btn, .tile-modal-tz-option,
    .converter-tab, .utc-conv-tz-option {
        transition-duration: 0s;
    }
}

/* ==========================================================================
   Site header (logo + nav), collapsible
   ========================================================================== */

:root {
    --site-header-h: 3.5rem;
}

/* The header is fixed; the body margin reserves its height. The body's
   background paints the canvas, so the strip behind it is the theme color. */
html:not(.header-collapsed):not(.no-site-header) body {
    margin-top: var(--site-header-h);
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--site-header-h);
    z-index: 140;
    background: var(--bg-color);
    color: var(--text-color);
    border-bottom: 1px solid color-mix(in srgb, var(--text-color) 14%, transparent);
}

[data-page="config"] .site-header,
[data-page="reference"] .site-header,
[data-page="about"] .site-header {
    background: var(--page-bg);
    color: var(--fg);
}

.site-header-inner {
    max-width: 105rem;
    height: 100%;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

@media (min-width: 640px) { .site-header-inner { padding: 0 1.5rem; } }
@media (min-width: 1024px) { .site-header-inner { padding: 0 2rem; } }

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    text-decoration: none;
    flex-shrink: 0;
}

.site-brand-mark {
    width: 2.25rem;
    height: 2.25rem;
    object-fit: contain;
    border-radius: 8px;
}

.site-brand-name {
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.site-brand-name strong {
    font-weight: 800;
}

.site-brand-tld {
    opacity: 0.7;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.site-nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0.75;
    transition: opacity 150ms ease, background 150ms ease;
}

.site-nav-link:hover,
.site-nav-link:focus-visible {
    opacity: 1;
    background: color-mix(in srgb, var(--text-color) 8%, transparent);
}

.site-nav-link[aria-current="page"] {
    opacity: 1;
    box-shadow: inset 0 -2px 0 var(--accent-color);
}

.header-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: transparent;
    color: inherit;
    border: 1px solid color-mix(in srgb, var(--text-color) 20%, transparent);
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    opacity: 0.7;
    transition: opacity 150ms ease;
}

.header-toggle:hover,
.header-toggle:focus-visible {
    opacity: 1;
}

.header-collapse {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
}

/* Collapsed: header gone, a small tab top-right brings it back */
.header-expand {
    display: none;
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 140;
    padding: 0.3rem 0.5rem;
    background: var(--bg-color);
    color: var(--text-color);
    opacity: 0.45;
}

.header-expand-mark {
    width: 1.25rem;
    height: 1.25rem;
    object-fit: contain;
    border-radius: 4px;
}

html.header-collapsed .site-header { display: none; }
html.header-collapsed .header-expand { display: flex; }

/* Embed iframes and popup widget windows never show site chrome */
html.no-site-header .site-header,
html.no-site-header .header-expand,
.embed-mode .site-header,
.embed-mode .header-expand { display: none !important; }

/* Phones: icons only in the nav, short brand */
@media (max-width: 640px) {
    .site-nav-link span { display: none; }
    .site-nav-link { padding: 0.45rem 0.6rem; font-size: 1rem; }
    .site-brand-tld { display: none; }
    .site-header-inner { gap: 0.5rem; }
}

/* Phones: with the sun/moon switch there are 7 controls; tighten, then drop
   the brand name before anything can push the row off screen */
@media (max-width: 440px) {
    .site-nav { gap: 0; }
    .site-nav-link { padding: 0.45rem 0.5rem; }
    .site-header-inner { gap: 0.35rem; }
    .mode-toggle, .header-collapse { width: 2rem; height: 2rem; }
}

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

@media (prefers-reduced-motion: reduce) {
    .site-nav-link, .header-toggle { transition-duration: 0s; }
}
/* ==========================================================================
   Background themes (clock screen only)
   html[data-bg-theme] is set before first paint by the inline script in
   index.html <head>, and again by src/js/themes.js. The image sits under a
   veil of the user's own background color, so it stays soft and the clocks
   on top keep their contrast. Embed iframes never get a theme.
   ========================================================================== */

/* The image URL comes from --bg-theme-img, set inline (themes.js applyTheme()
   and the index.html <head> script) on <html> or on the Settings preview.
   --bg-theme-veil is how much of the site background color covers the photo:
   a default per mode, raised per theme below where a photo runs bright. */
[data-bg-theme] { --bg-theme-veil: 20%; }
html[data-mode="light"] [data-bg-theme],
html[data-mode="light"][data-bg-theme] { --bg-theme-veil: 30%; }
/* Per-theme veils, set from a review of every image under a sample clock.
   0% = the photo is already faint (a map or contour lines would vanish under
   a veil); higher = a busy or saturated photo that needs calming. */
[data-bg-theme="night-map"],
[data-bg-theme="night-contours"],
html[data-mode="light"] [data-bg-theme="day-map"],
html[data-mode="light"][data-bg-theme="day-map"],
html[data-mode="light"] [data-bg-theme="day-contours"],
html[data-mode="light"][data-bg-theme="day-contours"] { --bg-theme-veil: 0%; }
[data-bg-theme="nebula"],
[data-bg-theme="earthrise"],
[data-bg-theme="starry-road"] { --bg-theme-veil: 10%; }
[data-bg-theme="rainy-window"],
[data-bg-theme="hourglass"] { --bg-theme-veil: 30%; }
[data-bg-theme="clockwork"] { --bg-theme-veil: 35%; }
html[data-mode="light"] [data-bg-theme="chart-paper"],
html[data-mode="light"][data-bg-theme="chart-paper"] { --bg-theme-veil: 15%; }
html[data-mode="light"] [data-bg-theme="dawn-meadow"],
html[data-mode="light"][data-bg-theme="dawn-meadow"],
html[data-mode="light"] [data-bg-theme="sundial"],
html[data-mode="light"][data-bg-theme="sundial"] { --bg-theme-veil: 35%; }
html[data-mode="light"] [data-bg-theme="turquoise-sea"],
html[data-mode="light"][data-bg-theme="turquoise-sea"],
html[data-mode="light"] [data-bg-theme="birch-forest"],
html[data-mode="light"][data-bg-theme="birch-forest"] { --bg-theme-veil: 40%; }

html[data-bg-theme] body[data-page="widget"]:not(.embed-mode) {
    background-image:
        linear-gradient(color-mix(in srgb, var(--bg-color) var(--bg-theme-veil), transparent),
                        color-mix(in srgb, var(--bg-color) var(--bg-theme-veil), transparent)),
        var(--bg-theme-img);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* Clocks over a photo: a soft shadow keeps the digits crisp */
html[data-bg-theme] body[data-page="widget"]:not(.embed-mode) #clock-container {
    text-shadow: 0 2px 12px color-mix(in srgb, var(--bg-color) 70%, transparent);
}

/* Desktop tiles get a frosted backing of the background color. Tiles with
   their own color keep it (that is an inline style and wins). */
html[data-bg-theme] body[data-page="widget"]:not(.embed-mode) .desktop-utc-tile,
html[data-bg-theme] body[data-page="widget"]:not(.embed-mode) .desktop-tile,
html[data-bg-theme] body[data-page="widget"]:not(.embed-mode) .desktop-add-tile {
    background-color: color-mix(in srgb, var(--bg-color) 62%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* The header follows the theme too, frosted instead of a solid bar */
html[data-bg-theme] body[data-page="widget"]:not(.embed-mode) .site-header {
    background: color-mix(in srgb, var(--bg-color) 70%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}