/* ============================================================================
   CONTINUAL - Player stylesheet
   ----------------------------------------------------------------------------
   PURPOSE:  Visual styles for the player, splash, banner, text box, gear,
             and settings panel. Built mobile-first; refined for 16:9 TVs.
   SPEC:     SPEC.md sections 6 (Player), 7 (Settings Panel), 8 (Themes),
             9 (Visual Design).
   ============================================================================ */

/* ----- CSS reset (minimal) -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ----- Responsive type tokens (used by themes) ------------------------------ */
:root {
    --title-size:   clamp(2.0rem, 5vw, 4.5rem);
    --body-size:    clamp(1.4rem, 3vw, 2.6rem);
    --container-pad: 2rem;     /* overridden by .padding-tight / .padding-loose */
    --line-height:  1.5;
    --textbox-bg:   rgba(0, 0, 0, 0.55);
    --textbox-fg:   #ffffff;
    --textbox-max-w: 80vw;
    --textbox-max-h: 75vh;
    --fade-duration: 0.5s;
    /* Settings accent color — used for value readouts, sliders, and checkboxes */
    --accent: #7ec8e3;
    --accent-on:  #4caf7d;   /* green for On/enabled */
    --accent-off: rgba(255, 255, 255, 0.35); /* muted for Off/disabled */
}
.padding-very_tight { --container-pad: 0.5rem; --line-height: 1.15; }
.padding-tight      { --container-pad: 1rem;   --line-height: 1.3; }
.padding-normal     { --container-pad: 2rem;   --line-height: 1.5; }
.padding-loose      { --container-pad: 3rem;   --line-height: 1.8; }
.padding-very_loose { --container-pad: 4.5rem; --line-height: 2.1; }

/* ----- Text size classes ----------------------------------------------------- */
/* Override --body-size and --title-size so every theme scales proportionally.
   "Small" is still designed to be readable from across a room on a TV.          */
body.text-size-small   { --body-size: clamp(1.1rem, 2.4vw, 2.1rem); --title-size: clamp(1.6rem, 4.0vw, 3.6rem); }
body.text-size-normal  { --body-size: clamp(1.4rem, 3.0vw, 2.6rem); --title-size: clamp(2.0rem, 5.0vw, 4.5rem); }
body.text-size-large   { --body-size: clamp(1.8rem, 3.9vw, 3.4rem); --title-size: clamp(2.6rem, 6.5vw, 5.9rem); }
body.text-size-xlarge  { --body-size: clamp(2.3rem, 5.0vw, 4.3rem); --title-size: clamp(3.3rem, 8.3vw, 7.4rem); }
body.text-size-xxlarge { --body-size: clamp(2.9rem, 6.3vw, 5.5rem); --title-size: clamp(4.2rem, 10.5vw, 9.5rem); }

/* ----- Container width classes ---------------------------------------------- */
/* Controls how wide the text box can grow — i.e. how much margin from screen edge. */
body.container-narrow   { --textbox-max-w: 60vw; }
body.container-standard { --textbox-max-w: 80vw; }   /* default */
body.container-wide     { --textbox-max-w: 90vw; }
body.container-full     { --textbox-max-w: 96vw; }

/* ----- Text entry animations ------------------------------------------------ */
/* "None" is the default: pure opacity fade (no override needed).
   Each class applies an additional transform/filter on the inactive state so
   the animation plays on fade-in (and reverses gently on fade-out).           */
body.text-anim-scale #textbox {
    transform: scale(0.93);
    transition: opacity var(--fade-duration) ease-out,
                transform calc(var(--fade-duration) * 1.4) ease-out;
}
body.text-anim-scale #textbox.active { transform: scale(1.0); }

body.text-anim-drift-up #textbox {
    transform: translateY(20px);
    transition: opacity var(--fade-duration) ease-out,
                transform calc(var(--fade-duration) * 1.4) ease-out;
}
body.text-anim-drift-up #textbox.active { transform: translateY(0); }

/* Materialize uses blur — elegant but may be slow on older TVs.
   Noted in help text. */
body.text-anim-materialize #textbox {
    filter: blur(6px);
    transition: opacity var(--fade-duration) ease-out,
                filter calc(var(--fade-duration) * 1.4) ease-out;
}
body.text-anim-materialize #textbox.active { filter: blur(0); }

/* ----- Solid background color (when background images are hidden) ----------- */
body.bg-images-hidden {
    background: var(--bg-solid, #000);
}
body.bg-images-hidden #player {
    background: var(--bg-solid, #000);
}
/* Immediately collapse both crossfade layers so the solid color shows through */
body.bg-images-hidden .bg-layer {
    opacity: 0 !important;
    transition: none !important;
}

/* ----- Splash screen -------------------------------------------------------- */
#splash {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.4s ease-out;
}
#splash .splash-hint {
    margin: 0;
    font-family: "Palatino Linotype", Palatino, serif;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    animation: splash-pulse 2.2s ease-in-out infinite;
}
@keyframes splash-pulse {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 0.9; }
}
#splash img {
    max-width: 80vw;
    max-height: 80vh;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}
#splash .splash-fallback-text {
    display: none;
    font-size: clamp(2rem, 6vw, 5rem);
    text-align: center;
    color: #fff;
    padding: 2rem;
    font-family: "Palatino Linotype", Palatino, serif;
    letter-spacing: 0.05em;
}
#splash.splash-fallback .splash-fallback-text { display: block; }

/* ----- Player container ----------------------------------------------------- */
#player {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ----- Background image layers (A/B for crossfade + Ken Burns) -------------- */
/* Images are rendered as <img> elements inside each layer so browsers allow
   right-click → "Save Image As". The div handles opacity crossfade and Ken Burns
   transform; the img fills the div with object-fit:cover (same visual result as
   background-size:cover). pointer-events defaults to auto so right-click reaches
   the img even through the pointer-events:none overlay elements above it.       */
.bg-layer {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--fade-duration) ease-in-out;
    will-change: transform, opacity;
}
.bg-layer img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    user-select: none;
}
.bg-layer.active { opacity: 1; }
.bg-layer.ken-burns { animation: ken-burns 20s ease-in-out infinite alternate; }
@keyframes ken-burns {
    from { transform: scale(1.0)  translate(0, 0); }
    to   { transform: scale(1.08) translate(-2%, -1%); }
}

/* ----- Fade-to-black overlay ----------------------------------------------- */
#fade-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--fade-duration) ease-in-out;
}
#fade-overlay.active { opacity: 1; }

/* ----- Banner --------------------------------------------------------------- */
/* max-height keeps it to 12vh of the viewport. max-width: 100% ensures a very
   wide image shrinks proportionally rather than overflowing horizontally.
   border-radius rounds all 4 corners; top two are visible against the
   page background since top:0 positions the image flush with the viewport.   */
#banner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    max-height: 12vh;
    max-width: 100%;
    width: auto;
    height: auto;
    z-index: 50;
    pointer-events: none;
    border-radius: 12px;
}

/* ----- Text box ------------------------------------------------------------- */
#textbox-wrapper {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--container-pad);
    pointer-events: none;
}
#textbox {
    background: var(--textbox-bg);
    color: var(--textbox-fg);
    border-radius: 20px; /* default; overridden inline by applyVisualSettings() */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 2px solid transparent; /* pre-sized so layout never shifts when border effect toggles */
    padding: var(--container-pad);
    max-width: var(--textbox-max-w);
    max-height: var(--textbox-max-h);
    overflow: hidden;
    text-align: center;
    line-height: var(--line-height);
    font-size: var(--body-size);
    opacity: 0;
    transition: opacity var(--fade-duration) ease-in-out, box-shadow 0.4s ease, border-color 0.4s ease;
}
#textbox.active { opacity: 1; }

/* Gold glow (halo) — body class toggled by applyVisualSettings() */
body.textbox-glow #textbox {
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0  22px rgba(255, 215, 0, 0.45),
        0 0  55px rgba(255, 190, 0, 0.22),
        0 0  95px rgba(255, 160, 0, 0.10);
}
/* Gold border — body class toggled by applyVisualSettings() */
body.textbox-border #textbox {
    border-color: rgba(255, 215, 0, 0.60);
}

#textbox h1, #textbox h2, #textbox h3 { font-size: var(--title-size); margin: 0 0 0.5em 0; }
#textbox p { margin: 0 0 0.5em 0; }
#textbox blockquote { margin: 0.5em 1em; font-style: italic; }
#textbox hr { border: 0; border-top: 2px solid rgba(255, 255, 255, 0.55); margin: 0.9rem 0; transition: border-top-color 0.4s ease, box-shadow 0.4s ease; }

/* Golden HR — mirrors the textbox border / glow effects on separator lines */
body.textbox-border #textbox hr {
    border-top-color: rgba(255, 215, 0, 0.60);
}
body.textbox-glow #textbox hr {
    border-top-color: rgba(255, 215, 0, 0.70);
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.45), 0 0 14px rgba(255, 190, 0, 0.22);
}

/* ----- Category label (below gear icon) ------------------------------------ */
#category-label {
    position: fixed;
    top: 50px;            /* 12px gear-top + 40px gear-height − 2px overlap = 50px */
    right: 12px;
    z-index: 100;
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    font-size: 0.62rem;
    font-style: italic;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.92);
    text-align: right;
    cursor: pointer;
    padding: 2px 6px 3px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 4px;
    /* No max-width or overflow:hidden — always shows full text, grows left from right edge */
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.7);
    transition: background 0.2s, border-color 0.2s;
    line-height: 1.4;
}
#category-label:hover    { background: rgba(0, 0, 0, 0.72); border-color: rgba(255, 255, 255, 0.55); }
#category-label[hidden]  { display: none; }

/* ----- Gear icon ------------------------------------------------------------ */
#gear-icon {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    z-index: 100;
    transition: background 0.2s, transform 0.2s;
}
#gear-icon:hover  { background: rgba(0, 0, 0, 0.6); transform: rotate(30deg); }
#gear-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#gear-icon[hidden] { display: none; }

/* ============================================================================
   SETTINGS PANEL
   ============================================================================ */
#settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(440px, 92vw);
    height: 100vh;
    background: rgba(14, 14, 18, 0.97);
    color: #f4f4f4;
    z-index: 100;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.7);
    transform: translateX(100%);
    transition: transform 0.25s ease-out;
    overflow-y: auto;
    font-family: "Trebuchet MS", "Helvetica Neue", Arial, sans-serif;
    font-size: 1.05rem;
    /* Custom scrollbar — Webkit */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.04);
}
#settings-panel::-webkit-scrollbar         { width: 5px; }
#settings-panel::-webkit-scrollbar-track   { background: rgba(255, 255, 255, 0.04); }
#settings-panel::-webkit-scrollbar-thumb   { background: rgba(255, 255, 255, 0.22); border-radius: 3px; }
#settings-panel::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

#settings-panel:not([hidden]) { transform: translateX(0); }

/* ----- Panel inner padding -------------------------------------------------- */
#settings-panel-inner { padding: 1.1rem 1.2rem 1.5rem; }

/* ----- Panel header --------------------------------------------------------- */
#settings-panel header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.7rem;
    margin-bottom: 0.9rem;
}
.settings-header-title {
    flex: 1;
    min-width: 0;  /* required for text-overflow in a flex child */
    overflow: hidden;
}
#settings-panel-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    line-height: 1.2;
}
#settings-tagline {
    margin: 0.2rem 0 0;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.42);
    font-style: italic;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#settings-close {
    flex-shrink: 0;
    background: transparent;
    border: 0;
    color: #f4f4f4;
    font-size: 1.3rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#settings-close:hover       { background: rgba(255, 255, 255, 0.09); }
#settings-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ----- Now Playing bar ------------------------------------------------------ */
#now-playing-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: -0.1rem 0 0.85rem;
    padding: 0.28rem 0.4rem 0.28rem 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    min-height: 1.8em;
}
#now-playing-bar[hidden] { display: none; }
#now-playing-info {
    flex: 1;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    letter-spacing: 0.02em;
    word-break: break-all;
}
#now-playing-skip {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.55);
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}
#now-playing-skip:hover { border-color: var(--accent); color: var(--accent); background: rgba(126,200,227,0.08); }
#now-playing-skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ============================================================================
   SETTING ROWS
   ============================================================================ */
#settings-controls .setting {
    margin-bottom: 1.0rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

/* ----- Setting groups (related pairs share one separator) ------------------- */
/* A .setting-group wraps 2 related settings (e.g. toggle + its volume slider).
   The group itself carries the bottom border; individual settings inside have
   no bottom border and tighter spacing so they read as a single logical item.  */
.setting-group {
    margin-bottom: 1.0rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}
/* Use #settings-controls prefix to match specificity of #settings-controls .setting
   so border-bottom:none overrides it for settings inside a group. */
#settings-controls .setting-group .setting {
    border-bottom: none;
    margin-bottom: 0.45rem;
    padding-bottom: 0.1rem;
}
#settings-controls .setting-group .setting:last-child {
    margin-bottom: 0;
}

#settings-controls > .setting:last-child,
#settings-controls > .setting-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Label row: holds label name, optional value display, optional inline control,
   and the ? help button. All on one horizontal line.                            */
#settings-controls .setting .setting-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    min-height: 1.8rem;
}
.setting-label-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.05rem;
}
/* Inline current-value badge — shown for sliders, toggles, and colors */
.setting-label-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    min-width: 1.8em;
    text-align: right;
    letter-spacing: -0.01em;
}
.setting-label-value.status-on  { color: var(--accent-on); }
.setting-label-value.status-off { color: var(--accent-off); }

/* ----- ? help button -------------------------------------------------------- */
#settings-controls .help-toggle {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.65);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.75rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}
#settings-controls .help-toggle:hover    { border-color: var(--accent); color: var(--accent); }
#settings-controls .help-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ----- Help text ------------------------------------------------------------ */
#settings-controls .help-text {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.45rem 0.7rem;
    border-radius: 5px;
    margin-top: 0.35rem;
    font-size: 0.82rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.75);
}
#settings-controls .help-text[hidden] { display: none; }

/* ----- Sliders -------------------------------------------------------------- */
input[type=range] {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    cursor: pointer;
    accent-color: var(--accent);
    height: 4px;
}

/* ----- Radio groups --------------------------------------------------------- */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
    margin-top: 0.2rem;
}
.radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 400;
    cursor: pointer;
    font-size: 0.96rem;
}
.radio-group input[type=radio] {
    accent-color: var(--accent);
    cursor: pointer;
}

/* ----- Toggle (inline checkbox in label row) -------------------------------- */
.setting-toggle-wrap {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0 0.15rem;
}
.setting-toggle-wrap input[type=checkbox] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-on);
    margin: 0;
}
.setting-toggle-wrap:focus-within { outline: 2px solid var(--accent); border-radius: 3px; }

/* ----- Color picker (inline in label row) ----------------------------------- */
.setting-color-inline {
    flex-shrink: 0;
    width: 34px;
    height: 24px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}
.setting-color-inline:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ----- Text inputs ---------------------------------------------------------- */
#settings-controls input[type=text] {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 5px;
    color: #f4f4f4;
    padding: 0.35rem 0.6rem;
    font-size: 0.88rem;
}
#settings-controls input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
}

/* ----- Category checkboxes (2-column grid, auto-collapses to 1 when names are long) */
.categories-group {
    margin-top: 0.3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.05rem 0.5rem;
}
.categories-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.18rem 0;
    font-weight: 400;
    font-size: 0.96rem;
    cursor: pointer;
    min-width: 0;
}
.categories-group label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.categories-group input[type=checkbox] {
    accent-color: var(--accent-on);
    cursor: pointer;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
/* The "none selected" warning note should span all columns */
.categories-group .categories-none-note {
    grid-column: 1 / -1;
}

/* ============================================================================
   PANEL FOOTER
   ============================================================================ */
#settings-panel footer {
    margin-top: 1.4rem;
    padding-top: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
#settings-footer-actions {
    display: flex;
    gap: 0.55rem;
    align-items: center;
}
#settings-copy-link {
    flex: 1;
    background: rgba(35, 95, 170, 0.85);
    color: #fff;
    border: 0;
    padding: 0.55rem 0.9rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    transition: background 0.15s;
}
#settings-copy-link:hover       { background: rgba(50, 115, 200, 0.95); }
#settings-copy-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#settings-reset {
    background: rgba(170, 55, 55, 0.8);
    color: #fff;
    border: 0;
    padding: 0.55rem 0.9rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    transition: background 0.15s;
}
#settings-reset:hover       { background: rgba(200, 65, 65, 0.95); }
#settings-reset:focus-visible { outline: 2px solid #f99; outline-offset: 2px; }

/* ----- QR code button ------------------------------------------------------- */
#settings-qr-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    padding: 0.28rem 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
    /* Match height of sibling buttons (0.55rem padding + font line = ~2.1rem total) */
    height: 2.1rem;
}
#settings-qr-btn:hover { background: rgba(255,255,255,0.15); border-color: var(--accent); }
#settings-qr-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#settings-qr-thumb {
    width: auto;
    height: 1.1rem;
    display: block;
    border-radius: 2px;
    opacity: 0.85;
}

/* ----- About button (ℹ️ icon link in footer) -------------------------------- */
#settings-about-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 2.1rem;
    width: 2.1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.15rem;
    line-height: 1;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#settings-about-btn:hover { background: rgba(255,255,255,0.15); border-color: var(--accent); color: var(--accent); }
#settings-about-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- Links dropdown ------------------------------------------------------- */
.settings-links-dd {
    position: relative;
    flex-shrink: 0;
}
.settings-links-toggle {
    background: rgba(60, 120, 80, 0.8);
    color: #fff;
    border: 0;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s;
}
.settings-links-toggle:hover { background: rgba(75, 145, 95, 0.95); }
.settings-links-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-links-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: rgba(18, 22, 32, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    z-index: 200;
}
.settings-links-menu[hidden] { display: none; }
.settings-links-item {
    display: block;
    padding: 0.55rem 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.settings-links-item:hover {
    background: rgba(126, 200, 227, 0.15);
    color: var(--accent);
    text-decoration: none;
}

/* ----- QR popup ------------------------------------------------------------- */
.qr-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: qr-fade-in 0.2s ease-out;
}
@keyframes qr-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.qr-popup-box {
    position: relative;
    background: rgba(14, 16, 26, 0.97);
    border: 1px solid rgba(126, 200, 227, 0.35);
    border-radius: 14px;
    padding: 1.6rem 1.6rem 1.2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(126,200,227,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 90vw;
}
.qr-popup-close {
    position: absolute;
    top: 0.6rem;
    right: 0.75rem;
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.qr-popup-close:hover { color: #fff; background: rgba(255,255,255,0.09); }
.qr-popup-img {
    width: 300px;
    height: 300px;
    border-radius: 8px;
    display: block;
    background: #fff; /* fallback while loading */
}
.qr-popup-url {
    margin: 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    font-style: italic;
    letter-spacing: 0.02em;
    max-width: 300px;
    overflow-wrap: break-word;
    word-break: break-all;
    text-align: center;
    line-height: 1.4;
}

/* ----- Error indicator & list ----------------------------------------------- */
#settings-error-indicator {
    margin: 0.7rem 0 0;
    color: #ffb84d;
    font-size: 0.82rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 4px;
    padding: 0.2rem 0;
}
#settings-error-indicator:hover { color: #ffd080; }
#settings-error-indicator[hidden] { display: none; }
#settings-error-list {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0.45rem 0.7rem;
    background: rgba(255, 120, 0, 0.07);
    border: 1px solid rgba(255, 150, 0, 0.18);
    border-radius: 5px;
    font-size: 0.74rem;
    color: rgba(255, 185, 90, 0.9);
    max-height: 140px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,150,0,0.3) transparent;
}
#settings-error-list[hidden] { display: none; }
#settings-error-list li { padding: 0.15rem 0; border-bottom: 1px solid rgba(255,150,0,0.1); }
#settings-error-list li:last-child { border-bottom: 0; }

/* ----- Font themes (1-7) --------------------------------------------------- */
/* Theme 1 — Radiant: Gabriela (main font) for headings + Lato (lesser) for body.
   Gabriela is a graceful, display-weight serif. Lato provides clean, airy body text.
   Both are loaded from Google Fonts. */
.theme-1 #textbox h1, .theme-1 #textbox h2, .theme-1 #textbox h3 { font-family: "Gabriela", "Palatino Linotype", Palatino, serif; font-weight: 400; }
.theme-1 #textbox { font-family: "Lato", "Helvetica Neue", Arial, sans-serif; font-weight: 300; letter-spacing: 0.02em; }
.theme-2 #textbox h1, .theme-2 #textbox h2, .theme-2 #textbox h3 { font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; }
.theme-2 #textbox { font-family: "Book Antiqua", "Times New Roman", serif; }
.theme-3 #textbox h1, .theme-3 #textbox h2, .theme-3 #textbox h3 { font-family: Georgia, "Times New Roman", serif; }
.theme-3 #textbox { font-family: Georgia, "Times New Roman", serif; }
.theme-4 #textbox h1, .theme-4 #textbox h2, .theme-4 #textbox h3 { font-family: "Trebuchet MS", "Helvetica Neue", Arial, sans-serif; }
.theme-4 #textbox { font-family: Verdana, "Helvetica Neue", sans-serif; }
.theme-5 #textbox h1, .theme-5 #textbox h2, .theme-5 #textbox h3 { font-family: "Copperplate Gothic Light", "Palatino Linotype", serif; }
.theme-5 #textbox { font-family: Garamond, "Times New Roman", serif; }

/* Theme 6 — Devotional: Cinzel (Roman-inscription headers) + Crimson Text (oldstyle body).
   Classical-liturgical; suits proclamations and declarations.
   Cinzel and Crimson Text load from Google Fonts (index.php); graceful serif fallbacks. */
.theme-6 #textbox h1, .theme-6 #textbox h2, .theme-6 #textbox h3 {
    font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", serif;
    letter-spacing: 0.07em;
    font-weight: 700;
}
.theme-6 #textbox { font-family: "Crimson Text", "Palatino Linotype", "Times New Roman", serif; }

/* Theme 7 — Radiance: Playfair Display (high-contrast editorial italic headers) + Lato (airy sans body).
   Modern worship-magazine aesthetic; pairs ornate headers with ultra-clean light body text.
   Both load from Google Fonts; graceful fallbacks provided. */
.theme-7 #textbox h1, .theme-7 #textbox h2, .theme-7 #textbox h3 {
    font-family: "Playfair Display", Georgia, serif;
    font-style: italic;
    font-weight: 700;
}
.theme-7 #textbox { font-family: "Lato", "Helvetica Neue", Arial, sans-serif; font-weight: 300; letter-spacing: 0.03em; }

/* ----- Banner quick-pick chips ---------------------------------------------- */
.banner-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0.35rem 0 0.45rem;
}
.banner-chip {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    padding: 0.2rem 0.55rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    text-transform: capitalize;
}
.banner-chip:hover { border-color: var(--accent); color: var(--accent); }
.banner-chip-active {
    background: rgba(126, 200, 227, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.banner-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ----- Audio unlock popup --------------------------------------------------- */
/* Appears at the bottom when browser blocks autoplay and settings want audio.
   Auto-dismisses after 5 s; any content-area click dismisses immediately.
   z-index sits above the player (20) but below the splash (200).              */
#audio-unlock-popup {
    position: fixed;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    z-index: 160;
    pointer-events: none;   /* the document-level click handler handles interaction */
    animation: aup-slide-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.aup-inner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(8, 12, 28, 0.88);
    border: 1px solid rgba(126, 200, 227, 0.38);
    border-radius: 40px;
    padding: 0.65rem 1.5rem 0.65rem 1.1rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(126, 200, 227, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
    white-space: nowrap;
}
.aup-icon {
    font-size: 1.45rem;
    line-height: 1;
    animation: aup-pulse 1.6s ease-in-out infinite;
    display: inline-block;
    flex-shrink: 0;
}
.aup-text {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    font-size: clamp(0.82rem, 2vw, 1.05rem);
    letter-spacing: 0.13em;
    color: rgba(255, 255, 255, 0.92);
    text-transform: uppercase;
    font-style: italic;
}
#audio-unlock-popup.aup-fade {
    animation: aup-fade-out 0.4s ease-out forwards;
}
@keyframes aup-slide-in {
    from { transform: translateX(-50%) translateY(24px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}
@keyframes aup-fade-out {
    to   { transform: translateX(-50%) translateY(12px); opacity: 0; }
}
@keyframes aup-pulse {
    0%, 100% { transform: scale(1.0) rotate(0deg); }
    40%       { transform: scale(1.2) rotate(-8deg); }
    60%       { transform: scale(1.15) rotate(6deg); }
}

/* ----- Shortcut toast (bottom pill, appears when a hotkey fires outside settings) */
.shortcut-toast {
    position: fixed;
    bottom: 2.8rem;
    left: 50%;
    transform: translateX(-50%) translateY(0.8rem);
    background: rgba(8, 12, 28, 0.88);
    color: rgba(255, 255, 255, 0.92);
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    font-size: clamp(0.78rem, 1.8vw, 0.98rem);
    letter-spacing: 0.06em;
    padding: 0.45em 1.4em;
    border-radius: 40px;
    border: 1px solid rgba(126, 200, 227, 0.32);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
    z-index: 161;   /* above audio-unlock-popup (160) */
    white-space: nowrap;
}
.shortcut-toast.shortcut-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ----- Pause banner (Space key) -------------------------------------------- */
/* Large bottom-center overlay shown while playback is paused. Persists until
   Space is pressed again; fades in/out via .pause-banner-visible class toggle. */
#pause-banner {
    position: fixed;
    bottom: 4rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 165;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}
#pause-banner.pause-banner-visible { opacity: 1; }
.pause-banner-inner {
    display: inline-block;
    background: rgba(0, 0, 0, 0.84);
    border: 2px solid rgba(126, 200, 227, 0.55);
    border-radius: 14px;
    padding: 1rem 2.6rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(126, 200, 227, 0.1);
}
.pause-banner-text {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    letter-spacing: 0.22em;
    color: rgba(255, 255, 255, 0.96);
    text-transform: uppercase;
    font-style: italic;
    line-height: 1;
}

/* ----- Shortcuts reference overlay (? key) ----------------------------------- */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.70);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: sc-fade-in 0.18s ease-out;
}
@keyframes sc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.shortcuts-box {
    background: rgba(10, 13, 28, 0.97);
    border: 1px solid rgba(126, 200, 227, 0.30);
    border-radius: 14px;
    padding: 1.5rem 2rem 1.2rem;
    min-width: 20rem;
    max-width: min(92vw, 480px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(126,200,227,0.08);
    color: #fff;
}
.shortcuts-title {
    margin: 0 0 0.9rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}
.shortcuts-table {
    border-collapse: collapse;
    width: 100%;
}
.shortcuts-table tr + tr td { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.shortcuts-table td { padding: 0.38em 0.4em; font-size: 1.05rem; vertical-align: middle; }
.sc-key {
    font-family: "Courier New", Courier, monospace;
    font-size: 1.0rem;
    color: var(--accent);
    white-space: nowrap;
    padding-right: 1.1em;
    min-width: 6.5rem;
}
.sc-desc { color: rgba(255, 255, 255, 0.80); }
.shortcuts-hint {
    margin: 0.9rem 0 0;
    font-size: 0.84rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    letter-spacing: 0.03em;
}

/* ----- Mobile portrait tweaks ---------------------------------------------- */
@media (max-width: 600px) {
    :root { --container-pad: 1rem; --line-height: 1.3; }
    #gear-icon { top: 8px; right: 8px; width: 36px; height: 36px; }
    #banner { max-height: 8vh; }
    #category-label { top: 46px; right: 8px; }
    #audio-unlock-popup { bottom: 28px; }
    .aup-text { letter-spacing: 0.07em; }
}
