/* ============================================
   THE ORACLE by KrisFAM STUDIOS
   Newspaper-Inspired Design System
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Default (English) palette — classic broadsheet */
    --primary: #8B0000;
    --primary-dark: #6a0000;
    --secondary: #1a1a1a;
    --secondary-dark: #0d0d0d;
    --accent: #c8a96e;
    --accent-dim: rgba(200, 169, 110, 0.6);

    /* Newspaper colors */
    --bg-deep: #f5f0e8;
    --bg-card: #ffffff;
    --bg-card-hover: #faf8f4;
    --bg-surface: #fdfcf9;
    --bg-overlay: rgba(245, 240, 232, 0.97);
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #8a8a8a;
    --border-subtle: rgba(0, 0, 0, 0.1);
    --border-active: rgba(0, 0, 0, 0.25);
    --border-rule: #1a1a1a;
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 2px 12px rgba(139, 0, 0, 0.12);
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --transition: 0.25s ease;
    --font-masthead: 'Copperplate', 'Copperplate Gothic Bold', serif;
    --font-display: 'Optima', 'Segoe UI', 'Candara', sans-serif;
    --font-body: 'Optima', 'Segoe UI', 'Candara', sans-serif;
    --font-ui: 'Futura', 'Century Gothic', 'Trebuchet MS', sans-serif;

    /* Layout */
    --nav-height: 64px;
    --top-bar-height: 72px;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

/* Language palettes — applied to slideshow overlay */
[data-lang="hi"] {
    --primary: #FF6F00;
    --primary-dark: #e06000;
    --accent: #138808;
    --accent-dim: rgba(19, 136, 8, 0.5);
    --bg-surface: #fef9f0;
    --bg-card: #fff8ee;
    --border-rule: #FF6F00;
    --shadow-glow: 0 2px 12px rgba(255, 111, 0, 0.15);
}

[data-lang="zh"] {
    --primary: #CC0000;
    --primary-dark: #a00000;
    --accent: #C8A84C;
    --accent-dim: rgba(200, 168, 76, 0.5);
    --bg-surface: #fef5f5;
    --bg-card: #fff5f5;
    --border-rule: #CC0000;
    --shadow-glow: 0 2px 12px rgba(204, 0, 0, 0.15);
}

[data-lang="el"] {
    --primary: #0D5EAF;
    --primary-dark: #0a4a8a;
    --accent: #FFFFFF;
    --accent-dim: rgba(13, 94, 175, 0.5);
    --bg-surface: #f0f5fc;
    --bg-card: #f5f8ff;
    --border-rule: #0D5EAF;
    --shadow-glow: 0 2px 12px rgba(13, 94, 175, 0.15);
}

[data-lang="es"] {
    --primary: #C60B1E;
    --primary-dark: #a00918;
    --accent: #FFC400;
    --accent-dim: rgba(255, 196, 0, 0.5);
    --bg-surface: #fffbf0;
    --bg-card: #fff9ee;
    --border-rule: #C60B1E;
    --shadow-glow: 0 2px 12px rgba(198, 11, 30, 0.15);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Top Bar — Newspaper masthead --- */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--top-bar-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--bg-surface);
    z-index: 100;
    border-bottom: 3px double var(--border-rule);
}

.top-bar-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: var(--top-bar-height);
    padding: 0 20px;
}

.top-bar-logo {
    width: 36px;
    height: 36px;
}

.top-bar-title {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title-main {
    font-family: var(--font-masthead);
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 4px;
    line-height: 1.1;
}

.title-sub {
    font-family: var(--font-ui);
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-muted);
}

/* --- Main Content --- */
#app-content {
    padding-top: calc(var(--top-bar-height) + var(--safe-top));
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
    min-height: 100dvh;
}

.screen {
    display: none;
    padding: 24px 20px;
    max-width: 720px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Bottom Navigation --- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-surface);
    border-top: 2px solid var(--border-rule);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 8px 20px;
    cursor: pointer;
    transition: color var(--transition);
}

.nav-btn.active {
    color: var(--primary);
}

.nav-btn svg {
    transition: transform var(--transition);
}

.nav-btn.active svg {
    transform: scale(1.05);
}

/* --- Landing Page: Polished Filter UX --- */
#landing-container {
    max-width: 580px;
    margin: 0 auto;
}

.filter-step {
    display: none;
    animation: stepEnter 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.filter-step.active {
    display: block;
}

@keyframes stepEnter {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Stagger animation for cards */
.anim-card {
    opacity: 0;
    animation: cardPop 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cardPop {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Step progress bar */
.step-bar {
    margin-bottom: 28px;
}

.step-bar-track {
    height: 3px;
    background: rgba(0,0,0,0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.step-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.step-bar-labels {
    display: flex;
    justify-content: space-between;
}

.step-bar-label {
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.step-bar-label.active {
    color: var(--primary);
}

.step-bar-label.done {
    color: var(--text-secondary);
}

.filter-header {
    text-align: center;
    margin-bottom: 8px;
}

.filter-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--secondary);
}

.filter-subtitle {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-style: italic;
}

/* --- Age Cards v2: Side-by-side, tactile --- */
.age-cards-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.age-card-v2 {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.age-card-v2:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.age-card-v2:active {
    transform: scale(0.98);
}

.age-card-v2.selected {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(139,0,0,0.12);
    background: linear-gradient(135deg, #fef5f5, #fff);
}

.age-card-v2-visual {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #f0ece4, #e8e2d8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.age-card-v2-emoji {
    font-size: 28px;
}

.age-card-v2-content {
    flex: 1;
}

.age-card-v2-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 2px;
}

.age-card-v2-range {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.age-card-v2-desc {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.age-card-v2-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s;
}

.age-card-v2:hover .age-card-v2-arrow {
    opacity: 0.8;
    transform: translateX(3px);
}

/* --- Horizon Cards v2 --- */
.horizon-cards-v2 {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.horizon-card-v2 {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.horizon-card-v2:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.horizon-card-v2:active {
    transform: scale(0.98);
}

.horizon-card-v2.selected {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(139,0,0,0.12);
}

.horizon-card-v2-icon {
    font-size: 30px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.today-date-badge {
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1.5px solid var(--primary);
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    line-height: 1;
}

.today-date-month {
    font-family: var(--font-ui);
    font-size: 7px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    display: block;
    width: 100%;
    text-align: center;
    padding: 2px 0 1px;
    letter-spacing: 0.8px;
}

.today-date-day {
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 700;
    color: var(--secondary);
    display: block;
    padding-top: 1px;
}

.horizon-card-v2-info {
    flex: 1;
}

.horizon-card-v2-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 2px;
}

.horizon-card-v2-desc {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-secondary);
}

.horizon-card-v2-date {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 3px;
}

.horizon-card-v2-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.3;
    transition: opacity 0.2s, transform 0.2s;
}

.horizon-card-v2:hover .horizon-card-v2-arrow {
    opacity: 0.7;
    transform: translateX(3px);
}

/* --- Category Cards v2: Colored icon tiles --- */
/* Roo 5-subject layout: 2 rows of 2 sandwiching a single centred Chinese tile.
   Final visual rhythm: Math / Science on top, Simplified Chinese alone in the
   middle, Social Studies / ELA on the bottom. Achieved with a 2-column grid
   and spanning the middle (third) card across both columns, centred. */
.cat-grid-v2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.cat-grid-v2 .cat-card-v2:nth-child(3) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 5px);
}
@media (max-width: 420px) {
    /* On very narrow screens, the centred tile takes the full width. */
    .cat-grid-v2 .cat-card-v2:nth-child(3) { width: 100%; }
}

.cat-card-v2 {
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 16px 12px 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    text-align: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.cat-card-v2:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.cat-card-v2:active {
    transform: scale(0.96);
}

.cat-card-v2.selected {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(139,0,0,0.12);
}

.cat-card-v2.disabled {
    opacity: 0.25;
    pointer-events: none;
    transform: none;
}

.cat-card-v2-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 24px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.cat-card-v2-name {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary);
    line-height: 1.3;
}

.cat-card-v2-check {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: var(--primary);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(139,0,0,0.3);
}

.cat-card-v2.selected .cat-card-v2-check {
    display: flex;
    animation: checkPop 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes checkPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.cat-counter-v2 {
    text-align: center;
    margin-top: 18px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
}

.cat-counter-v2-num {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    transition: all 0.3s ease;
}

.cat-counter-v2-sep {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text-muted);
}

.cat-counter-v2-max {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text-muted);
}

.cat-counter-v2-label {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 6px;
}

/* --- Oracle Cards v2: 2x2 grid, glow on hover --- */
.oracle-row-v2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 4px 0 12px;
}

.oracle-card-v2 {
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 22px 16px 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    text-align: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.oracle-card-v2:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.oracle-card-v2:active {
    transform: scale(0.97);
}

.oracle-card-v2.selected {
    border-color: var(--primary);
    box-shadow: 0 8px 28px rgba(139,0,0,0.15);
}

.oracle-card-v2-glow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 80px;
    border-radius: 50%;
    opacity: 0;
    filter: blur(30px);
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.oracle-card-v2:hover .oracle-card-v2-glow {
    opacity: 0.15;
}

.oracle-card-v2.selected .oracle-card-v2-glow {
    opacity: 0.2;
}

.oracle-edit-v2 {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-deep);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
}

.oracle-card-v2:hover .oracle-edit-v2 {
    opacity: 1;
}

.oracle-avatar-v2 {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border-subtle);
    background: var(--bg-deep);
    transition: border-color 0.3s, transform 0.3s;
    position: relative;
    z-index: 1;
}

.oracle-card-v2:hover .oracle-avatar-v2 {
    transform: scale(1.06);
}

.oracle-card-v2.selected .oracle-avatar-v2 {
    transform: scale(1.08);
}

.oracle-avatar-v2 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.oracle-name-v2 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.oracle-desc-v2 {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

/* --- Back button (minimal) --- */
.btn-back {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 2px;
    transition: color 0.2s;
}

.btn-back:hover {
    color: var(--secondary);
}

/* Filter Navigation */
.filter-nav {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    align-items: center;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .cat-grid-v2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .oracle-avatar-v2 {
        width: 64px;
        height: 64px;
    }

    .oracle-card-v2 {
        padding: 16px 12px 14px;
    }
}

@media (min-width: 700px) {
    .oracle-row-v2 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.btn-primary, .btn-secondary {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: var(--radius-md);
    padding: 13px 24px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    letter-spacing: 0.3px;
}

.filter-nav .btn-primary {
    flex: 1;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:active {
    background: var(--bg-card-hover);
}

/* --- Story List Screen — Spotify-inspired dark panel --- */
.spotify-panel {
    background: #121212;
    border-radius: 10px;
    overflow: hidden;
    margin: -20px;
    min-height: calc(100dvh - var(--top-bar-height) - var(--nav-height) - var(--safe-top) - var(--safe-bottom));
}

.spotify-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px 14px;
    background: linear-gradient(180deg, #282828 0%, #121212 100%);
}

.spotify-back-btn {
    background: rgba(255,255,255,0.07);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.spotify-title {
    font-family: var(--font-ui);
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}

/* Section = one category playlist */
.sp-section {
    margin-bottom: 8px;
}

.sp-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    position: relative;
}

.sp-section-icon {
    font-size: 36px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.sp-section-info {
    flex: 1;
}

.sp-section-label {
    display: block;
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.sp-section-name {
    display: block;
    font-family: var(--font-ui);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.sp-section-count {
    font-family: var(--font-ui);
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

/* Tracklist */
.sp-tracklist {
    padding: 0 8px 8px;
}

.sp-track {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sp-track:hover,
.sp-track:active {
    background: rgba(255,255,255,0.08);
}

.sp-track-num {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: #a0a0a0;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sp-track:hover .sp-track-num {
    color: transparent;
}

.sp-track:hover .sp-track-num::after {
    content: '';
    position: absolute;
}

.sp-track-art {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.sp-track-info {
    flex: 1;
    min-width: 0;
}

.sp-track-title {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    line-height: 1.3;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sp-track:hover .sp-track-title {
    color: #1db954;
}

.sp-track-subtitle {
    font-family: var(--font-ui);
    font-size: 12px;
    color: #a0a0a0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sp-track-play {
    color: #fff;
    opacity: 0;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1db954;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.sp-track:hover .sp-track-play {
    opacity: 1;
    transform: scale(1);
}

.sp-track-play svg {
    margin-left: 2px;
}

/* On touch devices, always show play button subtly */
@media (hover: none) {
    .sp-track-play {
        opacity: 0.6;
    }
}

/* --- Slideshow --- */
#slideshow-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

#slideshow-container {
    width: 92%;
    height: 80%;
    max-width: 720px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

.slideshow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 2px solid var(--border-rule);
    flex-shrink: 0;
    background: var(--bg-card);
}

.slideshow-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.slideshow-progress {
    display: flex;
    gap: 3px;
    flex: 1;
    margin: 0 14px;
}

.progress-dot {
    flex: 1;
    height: 3px;
    background: var(--border-subtle);
    border-radius: 2px;
    transition: background var(--transition);
}

.progress-dot.active {
    background: var(--primary);
}

.progress-dot.completed {
    background: var(--primary);
    opacity: 0.4;
}

.slideshow-lang-indicator {
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* Slide Content */
/* --- Slide Viewport: TRUE presentation slide --- */
.slide-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-surface);
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    animation: slideFadeIn 0.35s ease;
}

.slide.active {
    display: grid;
}

@keyframes slideFadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Slide WITH media: banner on top, content below --- */
.slide.has-media {
    grid-template-columns: 1fr;
    grid-template-rows: 46% 54%;
}

.slide-media {
    position: relative;
    background: transparent;
    overflow: hidden;
    min-height: 0;
}

.slide-media .slide-map {
    width: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;
    border: none;
}

.slide-media .slide-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    margin: 0;
    border: none;
    display: block;
    background: #1a1a1a;
}

/* --- Slide WITHOUT media: centered single column --- */
.slide.no-media {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* --- Slide content zone --- */
.slide-content {
    padding: 24px 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
}

.slide.no-media .slide-content {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
    justify-content: center;
}

.slide.no-media .slide-type-badge {
    align-self: center;
}

.slide-type-badge {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 4px 12px;
    border-radius: 2px;
    margin-bottom: 12px;
    align-self: flex-start;
}

.slide-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 14px;
    color: var(--secondary);
}

.slide.no-media .slide-title {
    font-size: 30px;
}

.slide-body {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.75;
    color: var(--text-secondary);
}

.slide-body p {
    margin-bottom: 10px;
}

/* Mobile: slightly less image space */
@media (max-width: 600px) {
    .slide.has-media {
        grid-template-rows: 30% 70%;
    }
}

/* Slide without media — centered content with larger text */
.slide-content-only {
    padding: 32px 28px;
    justify-content: center;
}

.slide-content-only .slide-title {
    font-size: 32px;
    text-align: center;
}

.slide-content-only .slide-type-badge {
    align-self: center;
}

.slide-content-only .slide-body {
    font-size: 20px;
    line-height: 1.8;
    max-width: 620px;
    margin: 0 auto;
}

/* Karaoke text */
.karaoke-line {
    transition: all 0.3s ease;
    padding: 3px 0;
}

.karaoke-line.active {
    color: var(--secondary);
    font-weight: 500;
    background: linear-gradient(90deg, rgba(139, 0, 0, 0.06), transparent);
    padding-left: 8px;
    border-left: 2px solid var(--primary);
}

.karaoke-line.spoken {
    color: var(--text-muted);
}

/* Standalone map/image (only used outside media zone, e.g. inline in content) */
.slide-content .slide-map {
    width: 100%;
    height: 180px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.slide-content .slide-image {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    border: 1px solid var(--border-subtle);
}

/* Slideshow Navigation */
.slideshow-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    background: var(--bg-card);
}

.slide-nav-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 16px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.slide-nav-btn:active {
    transform: scale(0.96);
}

.slide-nav-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.slide-counter {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Narration controls */
.narration-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
}

.narration-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.narration-waveform {
    flex: 1;
    height: 20px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.waveform-bar {
    width: 2px;
    background: var(--primary);
    border-radius: 1px;
    opacity: 0.2;
    transition: height 0.1s ease;
}

.waveform-bar.active {
    opacity: 0.7;
}

.narration-time {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* Pulse animation for play button on first slide */
.narration-play-btn.pulse-attention {
    animation: pulsePlay 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(128, 30, 30, 0.4);
}

@keyframes pulsePlay {
    0% { box-shadow: 0 0 0 0 rgba(128, 30, 30, 0.4); transform: scale(1); }
    50% { box-shadow: 0 0 0 12px rgba(128, 30, 30, 0); transform: scale(1.1); }
    100% { box-shadow: 0 0 0 0 rgba(128, 30, 30, 0); transform: scale(1); }
}

/* Narration speed control */
.narration-speed {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.speed-btn {
    font-family: var(--font-ui);
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.speed-btn:hover:not(.active) {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* Music indicator */
.music-indicator {
    position: absolute;
    bottom: 70px;
    right: 18px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.5;
}

.music-bars {
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 12px;
}

.music-bar {
    width: 2px;
    background: var(--primary);
    border-radius: 1px;
    animation: musicPulse 0.8s ease infinite;
}

.music-bar:nth-child(1) { height: 5px; animation-delay: 0s; }
.music-bar:nth-child(2) { height: 9px; animation-delay: 0.15s; }
.music-bar:nth-child(3) { height: 3px; animation-delay: 0.3s; }
.music-bar:nth-child(4) { height: 7px; animation-delay: 0.45s; }

@keyframes musicPulse {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}

.music-indicator.paused .music-bar {
    animation-play-state: paused;
}

/* --- Trivia Styles --- */
.trivia-container {
    margin-top: 14px;
}

.trivia-question {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.4;
    color: var(--secondary);
}

.trivia-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trivia-option {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-body);
    font-size: 15px;
    text-align: left;
    color: var(--text-primary);
}

.trivia-option:active {
    transform: scale(0.98);
}

.trivia-option.correct {
    border-color: #16a34a;
    background: rgba(22, 163, 74, 0.08);
}

.trivia-option.wrong {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.06);
}

.trivia-option.disabled {
    pointer-events: none;
}

.trivia-explanation {
    margin-top: 14px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    border-left: 3px solid var(--primary);
}

/* Implications Explorer */
.explore-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    color: var(--primary);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    margin-top: 16px;
    width: 100%;
    justify-content: center;
    transition: all var(--transition);
}

.explore-btn:active {
    background: rgba(139, 0, 0, 0.05);
}

/* --- Modals --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
}

.modal-content h3 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--secondary);
}

.modal-subtitle {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-style: italic;
}

.modal-actions {
    margin-top: 14px;
}

/* Language Buttons */
.language-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 14px;
}

.lang-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    text-align: center;
    color: var(--text-primary);
}

.lang-btn:active,
.lang-btn.selected {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.lang-flag {
    display: block;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    font-family: var(--font-display);
    color: var(--primary);
}

.lang-name {
    display: block;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-secondary);
}

/* Format Buttons */
.format-options {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.format-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 22px 14px;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    text-align: center;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
}

.format-btn:active {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.format-btn span {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--secondary);
}

.format-btn small {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* --- Wisdom Score Celebration --- */
.wisdom-celebration {
    overflow: hidden;
    position: relative;
}

.wisdom-badge {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #c44040);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.wisdom-score-display {
    margin: 14px 0;
}

.score-label {
    display: block;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.score-value {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    animation: countUp 1s ease;
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.wisdom-level {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 6px;
}

.wisdom-session {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    font-style: italic;
}

/* Confetti */
#confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 7px;
    height: 7px;
    top: -10px;
    animation: confettiFall 2.5s ease-in forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

/* --- Implications Explorer --- */
.implications-explorer {
    text-align: left;
    max-width: 480px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
}

.implications-explorer #implications-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.implications-explorer #implications-close {
    position: sticky;
    bottom: 0;
    margin-top: 12px;
    flex-shrink: 0;
}

.implications-explorer h3 {
    text-align: center;
}

#implications-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0;
}

#implications-input {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    outline: none;
}

#implications-input:focus {
    border-color: var(--primary);
}

#implications-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.suggestion-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 5px 12px;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.suggestion-chip:active {
    border-color: var(--primary);
    color: var(--primary);
}

#implications-results {
    margin-top: 14px;
}

.impact-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary);
}

.impact-number {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.impact-text {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* --- Wisdom Received Screen --- */
.wisdom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 3px double var(--border-rule);
}

.wisdom-header h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.wisdom-total-score {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.wisdom-score-banner {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    margin-bottom: 28px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.wisdom-score-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
}

.wisdom-banner-emoji {
    font-size: 44px;
    margin-bottom: 8px;
}

.wisdom-banner-points {
    font-family: var(--font-display);
    font-size: 56px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 4px;
}

.wisdom-banner-label {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.wisdom-banner-level {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
    background: var(--bg-deep);
    padding: 6px 20px;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
}

.wisdom-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.wisdom-empty-icon {
    font-size: 40px;
    margin-bottom: 14px;
}

.wisdom-item {
    background: var(--bg-card);
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
    padding: 14px 4px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.wisdom-item:first-child {
    border-top: 1px solid var(--border-subtle);
}

.wisdom-item-info {
    flex: 1;
    min-width: 0;
}

.wisdom-item-headline {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--secondary);
}

.wisdom-item-meta {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.wisdom-item-score {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.wisdom-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

/* --- Wisdom Section Title & Log --- */
.wisdom-section-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.wisdom-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wisdom-log-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.wisdom-log-week {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.wisdom-log-score {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wisdom-log-emoji {
    font-size: 18px;
}

.wisdom-log-points {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.wisdom-log-level {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Settings Screen --- */
.settings-section {
    margin-bottom: 28px;
}

.settings-section-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-style: italic;
}

.settings-field {
    margin-bottom: 12px;
}

.settings-label {
    display: block;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.settings-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.settings-input:focus {
    border-color: var(--primary);
}

.settings-input[type="password"] {
    font-family: monospace;
    letter-spacing: 2px;
}

.settings-help {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
    font-style: italic;
}

.settings-danger-zone {
    border-top: 1px solid rgba(220, 38, 38, 0.2);
    padding-top: 20px;
}

.btn-danger {
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #dc2626;
    border-radius: var(--radius-sm);
    padding: 11px 20px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
}

/* --- Loading --- */
.overlay.hidden {
    display: none;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(245, 240, 232, 0.92);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-message {
    font-family: var(--font-display);
    font-size: 16px;
    font-style: italic;
    color: var(--text-secondary);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* --- Responsive --- */
@media (min-width: 768px) {
    #slideshow-container {
        width: 75%;
        height: 82%;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .oracle-cards {
        overflow-x: visible;
    }

    .story-card {
        padding: 16px 4px;
    }
}

@media (max-width: 480px) {
    .oracle-cards {
        gap: 8px;
    }

    .oracle-card {
        min-width: 130px;
        padding: 14px 10px;
    }

    .title-main {
        font-size: 22px;
    }
}

/* =============================================================
   LEARNING TIME ASSISTANT — custom additions
   ============================================================= */

/* Topic list cards (subject -> numbered topics) */
.topic-list { display:flex; flex-direction:column; gap:10px; padding:0 16px; }
.topic-card {
    display:flex; align-items:center; gap:12px;
    background:var(--bg-card); border:1px solid var(--border-subtle);
    border-left:4px solid var(--primary); border-radius:var(--radius-lg);
    padding:14px 14px; cursor:pointer; transition:var(--transition);
    box-shadow:var(--shadow-card);
}
.topic-card:hover { background:var(--bg-card-hover); transform:translateX(2px); }
.topic-num {
    flex:none; width:44px; height:44px; border-radius:10px;
    display:flex; align-items:center; justify-content:center;
    color:white; font-family:var(--font-display); font-weight:700; font-size:18px;
}
.topic-info { flex:1; min-width:0; }
.topic-name { font-family:var(--font-display); font-weight:600; font-size:15px; color:var(--text-primary); }
.topic-tiers { margin-top:6px; display:flex; gap:6px; flex-wrap:wrap; }
.tier-chip {
    font-size:11px; padding:3px 9px; border-radius:12px;
    background:rgba(0,0,0,0.06); color:var(--text-secondary);
    font-family:var(--font-ui); letter-spacing:0.02em;
}
.tier-chip.done { background:#d1f5de; color:#116934; }
.tier-chip.small { font-size:10px; padding:2px 8px; }
.topic-next { margin-top:4px; font-size:12px; color:var(--text-muted); }
.topic-arrow { color:var(--text-muted); flex:none; }

/* Slide visual (SVG scene + caption) */
.slide-visual {
    width:100%; height:100%;
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    padding:20px 18px; box-sizing:border-box;
}
.slide-visual-svg { width:min(100%, 360px); height:auto; max-height:200px; }
.slide-visual-caption {
    margin-top:10px; font-size:12px; font-style:italic; text-align:center;
    opacity:0.85; max-width:90%;
}

/* Inline check-for-understanding inside explanation slides */
.check-container { margin-top:14px; }
.inline-check {
    background:var(--bg-surface); border:1px solid var(--border-subtle);
    border-radius:var(--radius-md); padding:14px;
}
.inline-check-question { font-weight:600; margin-bottom:10px; }
.inline-check-options { display:flex; flex-direction:column; gap:8px; }
.inline-check-fill { display:flex; gap:8px; }
.inline-check-fill .assessment-input { flex:1; }
.inline-check-feedback {
    margin-top:10px; padding:8px 10px; border-radius:6px; font-size:13px;
}
.inline-check-feedback.correct { background:#d1f5de; color:#116934; }
.inline-check-feedback.wrong { background:#fde2e2; color:#8a1f1f; }

/* Assessment */
.assessment-viewport {
    flex:1; min-height:0; overflow-y:auto; padding:18px; background:var(--bg-deep);
}
.assessment-shell { max-width:720px; margin:0 auto; }
.assessment-progress { margin-bottom:16px; }
.assessment-progress-bar {
    height:6px; background:rgba(0,0,0,0.1); border-radius:3px; overflow:hidden;
}
.assessment-progress-fill {
    height:100%; background:var(--primary); transition:width 0.3s ease;
}
.assessment-progress-label {
    margin-top:6px; font-size:12px; color:var(--text-muted); font-family:var(--font-ui);
}
.assessment-card {
    background:var(--bg-card); border-radius:var(--radius-lg);
    padding:22px; box-shadow:var(--shadow-card);
}
.assessment-type-badge {
    display:inline-block; background:var(--primary); color:white;
    font-size:11px; padding:3px 10px; border-radius:10px;
    font-family:var(--font-ui); letter-spacing:0.04em; margin-bottom:10px;
}
.assessment-prompt {
    font-family:var(--font-display); font-size:17px; font-weight:500;
    color:var(--text-primary); margin-bottom:16px; line-height:1.5;
}
.assessment-input-zone { margin-bottom:14px; }
.assessment-input, .assessment-textarea {
    width:100%; padding:12px; border:1px solid var(--border-subtle);
    border-radius:var(--radius-md); font-size:15px; font-family:var(--font-body);
    background:var(--bg-surface);
}
.assessment-input:focus, .assessment-textarea:focus {
    outline:none; border-color:var(--primary);
}
.assessment-textarea { resize:vertical; min-height:80px; }
.mcq-option {
    display:block; width:100%; padding:11px 14px; margin-bottom:8px;
    background:var(--bg-surface); border:1px solid var(--border-subtle);
    border-radius:var(--radius-md); cursor:pointer; text-align:left;
    font-family:var(--font-body); font-size:14px;
    transition:var(--transition);
}
.mcq-option:hover:not(:disabled) { background:var(--bg-card-hover); border-color:var(--border-active); }
.mcq-option.selected { background:var(--bg-card-hover); border-color:var(--primary); }
.mcq-option.correct { background:#d1f5de; border-color:#22c55e; color:#116934; }
.mcq-option.wrong { background:#fde2e2; border-color:#ef4444; color:#8a1f1f; }
.mcq-option:disabled { cursor:default; }

.assessment-feedback {
    padding:12px 14px; border-radius:var(--radius-md); margin-bottom:12px;
    font-size:14px; line-height:1.4;
}
.assessment-feedback.correct { background:#d1f5de; color:#116934; }
.assessment-feedback.wrong { background:#fde2e2; color:#8a1f1f; }
.feedback-verdict { font-weight:700; margin-bottom:4px; }
.feedback-answer { margin-top:6px; font-size:13px; }
.feedback-explanation { margin-top:6px; font-size:13px; opacity:0.85; }

.assessment-actions { display:flex; gap:10px; justify-content:flex-end; }

/* Sessions grouping */
.subject-group { margin-bottom:20px; }
.subject-group-header {
    display:flex; align-items:center; gap:10px;
    padding:10px 14px; border-radius:var(--radius-md);
    color:white; font-family:var(--font-display); font-weight:600; font-size:15px;
    margin-bottom:10px;
}
.subject-group-icon { font-size:22px; }
.topic-group { padding-left:10px; border-left:2px solid var(--border-subtle); margin-bottom:12px; }
.topic-group-header {
    font-size:13px; font-family:var(--font-ui); color:var(--text-secondary);
    padding:4px 10px; margin-bottom:6px; font-weight:600;
}
.session-item {
    display:flex; align-items:center; gap:10px; padding:12px 14px;
    background:var(--bg-card); border:1px solid var(--border-subtle);
    border-radius:var(--radius-md); margin-bottom:8px; cursor:pointer;
}
.session-item:hover { background:var(--bg-card-hover); }
.session-item-info { flex:1; min-width:0; }
.session-item-title {
    display:flex; gap:8px; align-items:center; flex-wrap:wrap;
    font-size:13px; margin-bottom:4px;
}
.session-tutor, .session-format { color:var(--text-secondary); }
.session-item-meta { font-size:12px; color:var(--text-muted); display:flex; gap:10px; }
.session-item-actions { display:flex; gap:6px; flex:none; }
.session-action {
    padding:7px 12px; font-size:12px; border-radius:6px;
    font-family:var(--font-ui); cursor:pointer; border:none;
}
.session-action.btn-danger {
    background:transparent; color:#ef4444; padding:4px 10px; font-size:18px;
}

/* Progress screen */
.progress-stats {
    display:grid; grid-template-columns:repeat(3, 1fr); gap:10px;
    padding:12px 16px 20px;
}
.stat-tile {
    background:var(--bg-card); border:1px solid var(--border-subtle);
    border-radius:var(--radius-md); padding:14px 10px; text-align:center;
}
.stat-num {
    display:block; font-family:var(--font-display); font-size:24px;
    font-weight:700; color:var(--primary);
}
.stat-label {
    display:block; font-size:11px; color:var(--text-muted);
    font-family:var(--font-ui); text-transform:uppercase; letter-spacing:0.05em;
}
.progress-topic-list { padding:0 10px; }
.progress-topic-row {
    display:flex; justify-content:space-between; align-items:center;
    padding:8px 10px; border-bottom:1px solid var(--border-subtle);
}
.progress-topic-label { font-size:13px; color:var(--text-primary); flex:1; min-width:0; }
.progress-tier-pips { display:flex; gap:6px; }
.tier-pip {
    font-size:16px; opacity:0.25; filter:grayscale(1);
    transition:var(--transition);
}
.tier-pip.done { opacity:1; filter:none; }

/* Resume dialog: more vertical space for 3 buttons */
#resume-modal .format-options { flex-direction:column; }
#resume-modal .format-btn { min-width:unset; }

/* Small screens — single-column topic cards already; tidy */
@media (max-width: 640px) {
    .progress-stats { grid-template-columns:repeat(3, 1fr); }
    .session-item { flex-wrap:wrap; }
    .session-item-actions { width:100%; justify-content:flex-end; }
}

/* Alias the lesson overlay to inherit slideshow overlay styling */
#lesson-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-overlay);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
#lesson-container {
    width: 92%; height: 88%;
    max-width: 720px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    border: 1px solid var(--border-subtle);
    display: flex; flex-direction: column;
}
#lesson-overlay.hidden, #lesson-overlay .hidden { display: none !important; }

/* Polished slide visual — per-slide bespoke SVG. The stage and caption share
   the media band vertically; the SVG scales to whatever space remains. */
.slide-visual {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: stretch;
    padding: 10px 14px;
    gap: 8px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    min-height: 0;
}
.slide-visual-stage {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    transform: translateY(8px) scale(0.985);
    opacity: 0;
    transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity 420ms ease;
    /* NOTE: shadow intentionally lives on the <img> / placeholder inside,
       not on this container — filter: drop-shadow on a large element is a
       well-known iOS Safari performance trap. */
}
.slide-visual-stage.enter {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.slide-visual-stage > svg.slide-svg {
    width: 100%; height: 100%;
    max-width: 520px;
    display: block;
}
.slide-visual-stage > svg.slide-svg text {
    font-family: 'Inter', system-ui, sans-serif;
}
.slide-visual-caption {
    flex: 0 0 auto;
    font-size: 12.5px;
    font-style: italic;
    text-align: center;
    opacity: 0.88;
    max-width: 92%;
    align-self: center;
    letter-spacing: 0.01em;
    line-height: 1.35;
    /* Clamp to 2 lines so the caption never steals space from the SVG */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Short-answer completeness hint */
.assessment-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}
.assessment-hint.ok { color: #116934; font-style: normal; }

/* Assigned Learning Time Plan card on landing */
.plan-card {
    margin: 0 16px 16px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #fdfcf9, #f2ece0);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.plan-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.10); }
.plan-card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.plan-card-badge {
    background: #1a1a1a; color: #ffd86b;
    font-size: 11px; font-family: var(--font-ui); letter-spacing: 0.08em;
    text-transform: uppercase; padding: 4px 10px; border-radius: 10px;
    font-weight: 600;
}
.plan-card-step { font-size: 11px; opacity: 0.75; letter-spacing: 0.04em; }
.plan-card-subject { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.plan-card-topic { font-size: 14px; opacity: 0.92; margin-bottom: 2px; }
.plan-card-tier { font-size: 13px; opacity: 0.8; }
.plan-card-cta {
    position: absolute; right: 18px; bottom: 16px;
    font-size: 13px; font-family: var(--font-ui); font-weight: 700;
    color: var(--primary);
}

/* Greyed-out subjects when plan is active */
.cat-grid-v2.locked .cat-card-v2 {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.8);
}
.cat-card-v2.disabled { cursor: not-allowed; }

/* Settings: Lesson Plan builder rows */
.plan-row {
    display: grid;
    grid-template-columns: 28px 1fr 1.4fr 0.9fr 0.8fr 34px;
    gap: 8px; align-items: center;
    padding: 6px 0;
}
.plan-row-num {
    font-family: var(--font-display); font-weight: 700;
    color: var(--text-muted); text-align: center;
}
.plan-row select.settings-input { padding: 9px 10px; font-size: 13px; }
.plan-remove {
    background: transparent; color: #ef4444; border: none;
    font-size: 22px; cursor: pointer; padding: 4px 8px;
}
.plan-remove:hover { background: rgba(239,68,68,0.1); border-radius: 6px; }
@media (max-width: 640px) {
    .plan-row { grid-template-columns: 1fr; }
    .plan-row-num { text-align: left; }
}

/* Assigned Learning Time Plan — multi-item list (overrides earlier single-item styles) */
.plan-card-head { justify-content: flex-start; }
.plan-items {
    display: flex; flex-direction: column; gap: 8px;
    margin: 0 0 36px;
}
.plan-item {
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.75);
    transition: var(--transition);
}
.plan-item-current {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 1px rgba(139, 0, 0, 0.15);
}
.plan-item-done { opacity: 0.55; }
.plan-item-subject {
    font-family: var(--font-display); font-weight: 600; font-size: 14px;
    margin-bottom: 2px;
}
.plan-item-topic { font-size: 13px; opacity: 0.92; margin-bottom: 3px; }
.plan-item-meta {
    font-size: 12px; opacity: 0.78;
    display: flex; gap: 8px; align-items: center;
}
.plan-item-tick {
    margin-left: auto;
    color: #22c55e; font-weight: 600;
}

/* Admin: ELA custom-theme field in plan builder */
.plan-row-ela-theme {
    grid-column: 2 / -1;
    margin-top: 4px;
    display: flex; flex-direction: column; gap: 4px;
}
.plan-row-ela-label {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}
.plan-row-ela-theme .settings-input { padding: 8px 10px; font-size: 13px; }

/* Landing: theme chip on plan item */
.plan-item-theme {
    font-style: italic;
    color: var(--primary);
}
@media (max-width: 640px) {
    .plan-row-ela-theme { grid-column: 1; }
}

/* Plan name shown next to badge on landing card */
.plan-card-head { flex-wrap: wrap; gap: 8px; align-items: baseline; }
.plan-card-name {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

/* Masked ELA theme input with show/hide eye toggle */
.theme-mask-wrap { position: relative; display: block; }
.theme-mask-wrap .settings-input { padding-right: 40px; }
.theme-mask-toggle {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.theme-mask-toggle:hover { color: var(--text-primary); background: rgba(0,0,0,0.05); }

/* Raster illustration from Imagen / Nano Banana */
.slide-visual-stage > img.slide-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    /* Shadow on the image itself — cheaper than filter: drop-shadow on container */
    box-shadow: 0 3px 10px rgba(0,0,0,0.10);
    border-radius: 12px;
}
/* Subtle dim while the image is generating — no streak. */
.slide-visual-stage.loading-image {
    position: relative;
    opacity: 0.88;
}

/* Narration play button: let clicks land on the button itself, not the SVG */
.narration-play-btn svg { pointer-events: none; }
.narration-play-btn.loading {
    opacity: 0.6;
    animation: narration-loading-pulse 1.2s ease-in-out infinite;
}
@keyframes narration-loading-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* Clean baseline placeholder — used instantly on every slide, kept if Gemini
   fails. No spinner, no shimmer, no alarm — just a tasteful gradient + caption. */
.img-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 22px;
    box-sizing: border-box;
}
.img-placeholder-text {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    opacity: 0.75;
    letter-spacing: 0.01em;
}


/* =============================================================
   Full-screen lesson layout — text on the left, visual on the right.
   Overrides the earlier centred-popup + top-media rules.
   ============================================================= */
#lesson-overlay {
    background: var(--bg-surface);
    align-items: stretch;
    justify-content: stretch;
}
#lesson-container {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
}
/* Side-by-side: text left, visual right. 55/45 on wide screens. */
.slide.has-media {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    grid-template-rows: 1fr;
    gap: 0;
}
.slide.has-media .slide-content {
    grid-column: 1;
    grid-row: 1;
    padding: 36px 44px;
    overflow-y: auto;
    max-width: 720px;
}
.slide.has-media .slide-media {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}
.slide.has-media .slide-visual {
    height: 100%;
    width: 100%;
}
.slide-title { font-size: 30px; }
.slide-body  { font-size: 19px; line-height: 1.7; }

/* On narrow/portrait screens, fall back to stacked (text on top, image below). */
@media (max-width: 820px) {
    .slide.has-media {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .slide.has-media .slide-content {
        grid-column: 1; grid-row: 1;
        padding: 22px 24px;
        max-width: none;
    }
    .slide.has-media .slide-media {
        grid-column: 1; grid-row: 2;
        padding: 12px 16px 20px;
    }
    .slide-title { font-size: 24px; }
    .slide-body  { font-size: 17px; }
}
