/* Quillheart Online - Dusk Journal stylesheet
   4 themes from desktop, applied via body class
   Literary serif typography (Fraunces + Spectral) */


/* ====================================================================
   THEMES - CSS variable palettes from desktop _GuiStyles.py
   Body class theme-X picks the active palette
   ==================================================================== */

/* Soft Lavender (default) */
.theme-soft-lavender {
    --bg: #1E1B2E;
    --surface: #2D2A3E;
    --surface-elevated: #353149;
    --border: #3E3A52;
    --accent: #B085F5;
    --accent-hover: #C4A0FF;
    --accent-soft: rgba(176, 133, 245, 0.15);
    --text: #D5CEE8;
    --text-dim: #9088A8;
    --error: #F4A8A8;
    --glow-1: rgba(176, 133, 245, 0.12);
    --glow-2: rgba(62, 58, 82, 0.4);
}

/* Warm Amber */
.theme-warm-amber {
    --bg: #1A1410;
    --surface: #2C2319;
    --surface-elevated: #3A2D20;
    --border: #3D3226;
    --accent: #D4A45A;
    --accent-hover: #E0B870;
    --accent-soft: rgba(212, 164, 90, 0.15);
    --text: #E8DCC8;
    --text-dim: #A89880;
    --error: #F4A8A8;
    --glow-1: rgba(212, 164, 90, 0.12);
    --glow-2: rgba(61, 50, 38, 0.4);
}

/* Deep Teal */
.theme-deep-teal {
    --bg: #2F3E46;
    --surface: #354F52;
    --surface-elevated: #3F5A5E;
    --border: #4A6A6E;
    --accent: #84A98C;
    --accent-hover: #9EC4A6;
    --accent-soft: rgba(132, 169, 140, 0.15);
    --text: #CAD2C5;
    --text-dim: #8A9A8E;
    --error: #F4A8A8;
    --glow-1: rgba(132, 169, 140, 0.12);
    --glow-2: rgba(74, 106, 110, 0.4);
}

/* Muted Sapphire */
.theme-muted-sapphire {
    --bg: #1B1F3B;
    --surface: #2A2D4A;
    --surface-elevated: #353A5A;
    --border: #3A3E5C;
    --accent: #5C7AEA;
    --accent-hover: #7B94F0;
    --accent-soft: rgba(92, 122, 234, 0.15);
    --text: #D0D4E8;
    --text-dim: #8A8FB0;
    --error: #F4A8A8;
    --glow-1: rgba(92, 122, 234, 0.12);
    --glow-2: rgba(58, 62, 92, 0.4);
}


/* ====================================================================
   TYPE STACKS + RADIUS
   ==================================================================== */
:root {
    --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Spectral', Georgia, 'Times New Roman', serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}


/* ====================================================================
   BASE
   ==================================================================== */
* {
    box-sizing: border-box;
}

/* Global guard - any element with hidden attribute stays hidden */
[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.dusk-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 50% at 50% 35%, var(--glow-1), transparent 70%),
        radial-gradient(ellipse 80% 60% at 50% 100%, var(--glow-2), transparent 70%);
    transition: background 0.4s ease;
}

.page {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}


/* ====================================================================
   GATE CARD (initial view)
   ==================================================================== */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    text-align: center;
    box-shadow:
        0 24px 48px -16px rgba(0, 0, 0, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    animation: card-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.card--gate {
    margin: auto 0;
}

@keyframes card-rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.brand {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 144, 'wght' 500, 'SOFT' 100;
    font-size: clamp(2.5rem, 6vw, 3rem);
    color: var(--text);
    margin: 0 0 0.35rem 0;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.brand--button {
    cursor: pointer;
    transition: color 0.25s ease, text-shadow 0.25s ease;
    user-select: none;
    display: inline-block;
}

.brand--button:hover,
.brand--button:focus-visible {
    outline: none;
    color: var(--accent);
    text-shadow: 0 0 24px var(--accent-soft);
}

.brand__tagline {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 300;
    color: var(--text-dim);
    margin: 0;
    font-size: 1.05rem;
}


/* ====================================================================
   JOURNAL APP LAYOUT (after unlock)
   ==================================================================== */
.journal {
    width: 100%;
    max-width: 880px;
    animation: card-rise 0.5s ease both;
}

.journal__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.journal__brand {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 144, 'wght' 500, 'SOFT' 100;
    font-size: 2.2rem;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.01em;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 4px;
    gap: 4px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    /* Viewport-based max-width bypasses a flex sizing quirk where max-width:100%
       on a flex item in an align-items:center column parent resolves to "auto".
       100vw is always defined; the 40px buffer covers .page padding + scrollbar. */
    max-width: calc(100vw - 40px);
    box-sizing: border-box;
    min-width: 0;
}

.tab {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dim);
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease;
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    background-color: var(--accent);
    color: var(--bg);
}


/* --- + Add tab (gateway to pack catalog) -----------------------------------
   Default state matches the other tabs visually — no gold tint, no animation —
   so the row stays calm. On hover the gold treatment reveals itself with a
   gentle breathing shine around the "+ Add" text, like the tab warms up under
   the cursor. Active state defers to the theme accent like every other tab.
   --------------------------------------------------------------------------- */
.tab--add {
    /* Smooth transitions so the gold appearance feels like it warms in, not snaps */
    transition: background-color 0.25s ease,
                color 0.25s ease,
                box-shadow 0.25s ease,
                text-shadow 0.25s ease;
}

.tab--add:hover {
    /* Hover reveals the gold: translucent warm tint + thin gold border + brighter text */
    background-color: rgba(212, 175, 55, 0.12);
    color: #FFE4A0;
    box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.40);
    animation: tab-add-shine 2.2s ease-in-out infinite;
}

.tab--add.is-active {
    /* Selected state matches every other active tab — theme accent fill */
    background-color: var(--accent);
    color: var(--bg);
    box-shadow: none;
    text-shadow: none;
    animation: none;
}

@keyframes tab-add-shine {
    /* Soft gold halo around the "+ Add" text breathes in and out while hovered */
    0%, 100% { text-shadow: 0 0 4px rgba(255, 220, 130, 0.28); }
    50%      { text-shadow: 0 0 14px rgba(255, 220, 130, 0.62); }
}

/* Pack catalog rendered inside the + Add panel ----------------------------- */
.pack-catalog {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
}

.pack-catalog__empty {
    color: var(--text-dim);
    font-style: italic;
    margin: 0;
}

.pack-catalog-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.pack-catalog-row__info {
    flex: 1;
    min-width: 0;
}

.pack-catalog-row__name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--text);
    margin: 0 0 4px;
}

.pack-catalog-row__desc {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.4;
}

/* Buy button uses gold styling to echo the + Add tab — clear call-to-action */
.pack-catalog-row__buy {
    background-color: rgba(212, 175, 55, 0.15);
    color: #FFE4A0;
    border: 1px solid rgba(212, 175, 55, 0.45);
    flex-shrink: 0;
}

.pack-catalog-row__buy:hover {
    background-color: rgba(230, 195, 90, 0.30);
    border-color: rgba(230, 195, 90, 0.65);
}

/* Owned button is neutral/ghost — debug-mode click still toggles ownership off */
.pack-catalog-row__owned {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.pack-catalog-row__owned:hover {
    color: var(--text);
    border-color: var(--text-dim);
}


/* Shared dashboard layout for pack panels --------------------------------- */
/* Packs drop in HTML with .pack-dashboard + .dashboard-card classes and get */
/* consistent styling across the whole app.                                  */
.pack-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.dashboard-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
}

/* Modifier — makes a card span the full row width of the .pack-dashboard grid */
.dashboard-card--full {
    grid-column: 1 / -1;
}

.dashboard-card__title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--accent);
    margin: 0 0 8px;
}

.dashboard-card__body {
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.5;
}


/* Christian pack — Today's Word card content ----------------------------- */
.christian-verse__emotion {
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--text-dim);
    font-style: italic;
    margin: 0 0 12px;
}

.christian-verse__text {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.6;
    margin: 0 0 10px;
}

.christian-verse__ref {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent);
    margin: 0;
    font-style: italic;
}

.christian-verse__loading {
    opacity: 0.6;
}

/* Thin divider between stacked verses in the Helpful Verses card */
.christian-verse__sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}


/* Helpful Verses card — two-column layout: verse | pie+legend ---------- */
.christian-helpful__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
    margin-top: 6px;
}

/* On narrow viewports, stack the two columns */
@media (max-width: 720px) {
    .christian-helpful__grid {
        grid-template-columns: 1fr;
    }
}

.christian-helpful__chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}


/* Clickable pie chart (matches Trends "Feels Like" colors) ------------- */
.christian-pie {
    width: 200px;
    max-width: 100%;
}

.christian-pie__svg {
    width: 100%;
    height: auto;
    display: block;
}

.christian-pie__slice {
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform-origin: 100px 100px;
}

.christian-pie__slice:hover {
    opacity: 0.85;
}

.christian-pie__slice.is-active {
    stroke: var(--text);
    stroke-width: 3;
}

.christian-pie__empty {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-style: italic;
    padding: 16px;
}


/* Clickable legend list — color swatch, label, percentage -------------- */
.christian-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.christian-legend__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.18s ease;
}

.christian-legend__row:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.christian-legend__row.is-active {
    background-color: rgba(255, 255, 255, 0.08);
}

.christian-legend__label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.christian-legend__swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.christian-legend__percent {
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.85rem;
}

/* --- Christian panel header (title + translation dropdown side-by-side) ---- */
.christian-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

/* Override the default h2 margin-bottom inside the header row */
.christian-panel-header .panel__title {
    margin: 0;
}

.christian-translation {
    display: flex;
    flex-direction: column;     /* stack label above select so long version names don't overflow on mobile */
    align-items: stretch;       /* select fills the column width */
    gap: 6px;                   /* tighter gap since rows are now adjacent vertically */
    min-width: 0;               /* allow the column to shrink below select's natural width */
}

.christian-translation__label {
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.christian-translation__select {
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 6px 28px 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;                /* fill the stacked column so long version names fit */
    box-sizing: border-box;     /* keep padding inside the 100% width */
    /* Custom caret since native select arrows vary wildly across browsers */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                      linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    transition: border-color 120ms ease;
}

.christian-translation__select:hover {
    border-color: var(--text-dim);
}

.christian-translation__select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}


/* --- Christian Prayer card (entry dropdown + composed prayer body) --------- */
.christian-prayer__hint {
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.9rem;
    margin: 0 0 10px;
}

.christian-prayer__select {
    width: 100%;
    box-sizing: border-box;
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 8px 28px 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    /* Mirror the translation dropdown's custom caret so the two look consistent */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                      linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    transition: border-color 120ms ease;
    margin-bottom: 14px;
}

.christian-prayer__select:hover {
    border-color: var(--text-dim);
}

.christian-prayer__select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.christian-prayer__body {
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    /* Composed prayer is a single 3-sentence string; line-height does the breathing */
    white-space: pre-wrap;
}

.christian-prayer__empty {
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-style: italic;
    margin: 0;
}

/* Two-column layout under the dropdown — sentiment context | composed prayer.
   Mirrors .christian-helpful__grid so the two full-width cards feel related.   */
.christian-prayer__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 28px;
    align-items: start;
    margin-top: 6px;
}

@media (max-width: 720px) {
    .christian-prayer__grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

/* Sentiment context column — feels-like phrase, polarity label, top emotions */
.christian-prayer__context {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.christian-prayer__feels {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text);
}

.christian-prayer__feels strong {
    color: var(--accent);
    font-weight: 600;
}

.christian-prayer__label {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-dim);
    font-style: italic;
}

.christian-prayer__emotions {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.christian-prayer__emotion-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text);
}

.christian-prayer__emotion-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.christian-prayer__emotion-name {
    flex: 1;
    min-width: 0;
}

.christian-prayer__emotion-pct {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}


/* ====================================================================
   PANELS
   ==================================================================== */
.panel {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow:
        0 12px 32px -10px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel__title {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 80, 'wght' 500, 'SOFT' 100;
    font-size: 1.6rem;
    color: var(--text);
    margin: 0 0 20px 0;
}

.panel__head .panel__title {
    margin-bottom: 0;
}


/* ====================================================================
   WRITE FORM
   ==================================================================== */
.write-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.write-form__actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.write-form__status {
    flex: 1;
    font-style: italic;
    color: var(--text-dim);
    font-size: 0.9rem;
}


/* ====================================================================
   INPUTS
   ==================================================================== */
.field__input {
    background-color: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 1.05rem;
    font-family: var(--font-body);
    width: 100%;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.field__input:hover {
    border-color: var(--text-dim);
}

.field__input:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--surface-elevated);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.field__textarea {
    resize: vertical;
    line-height: 1.65;
    min-height: 200px;
}

.field__error {
    color: var(--error);
    font-size: 0.9rem;
    margin: -4px 0 0 0;
    font-style: italic;
    text-align: center;
}


/* ====================================================================
   BUTTONS
   ==================================================================== */
.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.08s ease,
                box-shadow 0.18s ease, color 0.18s ease;
    letter-spacing: 0.01em;
}

.btn--small {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn--primary {
    background-color: var(--accent);
    color: var(--bg);
    box-shadow: 0 2px 8px var(--accent-soft);
}

.btn--primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 4px 14px var(--accent-soft);
}

.btn--primary:active {
    transform: translateY(1px);
}

.btn--ghost {
    background-color: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn--ghost:hover {
    color: var(--text);
    border-color: var(--text-dim);
    background-color: var(--surface-elevated);
}

.btn--danger {
    background-color: #b5504d;
    color: #fff;
    box-shadow: 0 2px 8px rgba(181, 80, 77, 0.35);
}

.btn--danger:hover {
    background-color: #c75c58;
    box-shadow: 0 4px 14px rgba(181, 80, 77, 0.45);
}

.btn--danger:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--accent-soft);
}


/* ====================================================================
   ENTRY LIST (Browse + Search)
   ==================================================================== */
.entry-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.entry-item {
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-dim);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.08s ease;
}

.entry-item:hover {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background-color: var(--surface-elevated);
}

.entry-item:active {
    transform: translateY(1px);
}

/* Sentiment-tinted left border */
.entry-item--bright   { border-left-color: var(--accent); }
.entry-item--heavy    { border-left-color: var(--error); }
.entry-item--balanced { border-left-color: var(--text-dim); }

.entry-item__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}

.entry-item__title {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 24, 'wght' 500, 'SOFT' 100;
    color: var(--text);
    font-size: 1.1rem;
}

.entry-item__date {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-style: italic;
    white-space: nowrap;
}

.entry-item__preview {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
}

.entry-empty {
    color: var(--text-dim);
    font-style: italic;
    padding: 16px;
    text-align: center;
    list-style: none;
}


/* ====================================================================
   SEARCH FORM
   ==================================================================== */
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-form .field__input {
    flex: 1;
}


/* ====================================================================
   SETTINGS - theme switcher
   ==================================================================== */
.setting-group {
    margin-bottom: 32px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group__title {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 36, 'wght' 500, 'SOFT' 100;
    font-size: 1.15rem;
    color: var(--text);
    margin: 0 0 4px 0;
}

.setting-group__hint {
    color: var(--text-dim);
    font-size: 0.9rem;
    font-style: italic;
    margin: 0 0 16px 0;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.theme-card {
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-family: var(--font-body);
    color: var(--text);
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.theme-card:hover {
    border-color: var(--text-dim);
    background-color: var(--surface-elevated);
}

.theme-card.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-card__swatch {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--swatch-bg) 0%, var(--swatch-accent) 100%);
}

/* Per-theme swatch palettes (independent of active theme - so previews always show) */
.theme-card__swatch[data-palette="soft-lavender"]  { --swatch-bg: #1E1B2E; --swatch-accent: #B085F5; }
.theme-card__swatch[data-palette="warm-amber"]     { --swatch-bg: #1A1410; --swatch-accent: #D4A45A; }
.theme-card__swatch[data-palette="deep-teal"]      { --swatch-bg: #2F3E46; --swatch-accent: #84A98C; }
.theme-card__swatch[data-palette="muted-sapphire"] { --swatch-bg: #1B1F3B; --swatch-accent: #5C7AEA; }

.theme-card__label {
    font-size: 0.9rem;
    color: var(--text);
}


/* ====================================================================
   MODALS (gate + detail)
   ==================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13, 11, 22, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: backdrop-fade 0.25s ease both;
}

@keyframes backdrop-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow:
        0 32px 64px -20px rgba(0, 0, 0, 0.7),
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: modal-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal--detail {
    max-width: 640px;
    text-align: left;
}

@keyframes modal-rise {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.modal__title {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 80, 'wght' 500, 'SOFT' 100;
    font-size: 1.75rem;
    color: var(--text);
    margin: 0;
    text-align: center;
    flex: 1;
}

.modal--detail .modal__title {
    text-align: left;
    font-size: 1.5rem;
}

.modal__close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-top: 4px;
    transition: color 0.18s ease;
}

.modal__close:hover {
    color: var(--accent);
}

.modal__sub {
    color: var(--text-dim);
    text-align: center;
    margin: 0 0 1.5rem 0;
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 300;
}

.modal__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal__actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-end;
}

.modal--detail .modal__actions {
    margin-top: 24px;
}


/* ====================================================================
   DETAIL MODAL CONTENT
   ==================================================================== */
.detail__meta {
    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 18px;
}

.detail__sentiment {
    padding: 2px 10px;
    border-radius: 12px;
    background-color: var(--surface-elevated);
    font-style: normal;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.detail__sentiment--bright   { color: var(--accent); }
.detail__sentiment--heavy    { color: var(--error); }
.detail__sentiment--balanced { color: var(--text-dim); }

.detail__text {
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 8px;
}


/* ====================================================================
   REDUCED MOTION
   ==================================================================== */
@media (prefers-reduced-motion: reduce) {
    .card,
    .modal-backdrop,
    .modal,
    .journal {
        animation: none;
    }
    * {
        transition-duration: 0.01ms !important;
    }
}


/* ====================================================================
   AUTH FORMS (login + register) - lives inside .card--gate
   ==================================================================== */

.auth-tabs {
    /* Pull the auth tab row inside the gate card and add breathing room */
    margin-top: 1.5rem;
    margin-bottom: 1.25rem;
    justify-content: center;
}

.auth-form {
    /* Stacked inputs + button, full width of gate card */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form:not(.is-active) {
    /* Hidden form stays out of the layout flow */
    display: none;
}


/* ====================================================================
   AUTH SECONDARY (change-password link + status messages)
   ==================================================================== */

.auth-secondary {
    /* Sits under the login/register form, holds the "Change password" link */
    margin-top: 1rem;
    text-align: center;
}

.auth-link {
    /* Plain text link styled as a button so it picks up focus rings cleanly */
    background: transparent;
    border: 0;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s ease;
}

.auth-link:hover,
.auth-link:focus-visible {
    color: var(--accent);
    outline: none;
}

.auth-status {
    /* Soft success-style line (e.g. after password change) */
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.95rem;
    margin: 0;
}


/* ====================================================================
   SETTINGS FORM (used by the Change password section)
   ==================================================================== */

.settings-form {
    /* Stacked inputs + button, matches the visual rhythm of auth forms */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    max-width: 380px;
}


/* ====================================================================
   WRITE-FORM PREDICTED SENTIMENT (live label under the textarea)
   ==================================================================== */

.write-form__predict {
    /* Stacked: label on top, percentage breakdown below */
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    font-family: var(--font-body);
}

.write-form__predict-label {
    /* The full "X Conversation Sentiment" line — primary read */
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.write-form__predict-breakdown {
    /* Percentage breakdown — secondary, dimmer, smaller */
    color: var(--text-dim);
    font-size: 0.8rem;
    font-style: italic;
}


/* ====================================================================
   DETAIL MODAL SENTIMENT BLOCK (label + breakdown beneath the date)
   ==================================================================== */

.detail__sentiment-block {
    /* Stacked under the date, before the body text */
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 18px 0;
    font-family: var(--font-body);
}

.detail__sentiment-label {
    /* Full "X Conversation Sentiment" line */
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.detail__sentiment-breakdown {
    /* Percentage breakdown — secondary */
    color: var(--text-dim);
    font-size: 0.8rem;
    font-style: italic;
}


/* ====================================================================
   FEELS-LIKE LINE (sits between label and breakdown in both
   the Write predict block and the Detail modal sentiment block)
   ==================================================================== */

.write-form__predict-feels,
.detail__sentiment-feels {
    /* Same color family as the label so it reads as part of the headline,
       slightly smaller so the heirarchy is: label > feels > breakdown.
       line-height bumped to handle the longer percentage breakdown wrapping. */
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 400;
    line-height: 1.6;
}


/* ====================================================================
   TRENDS TAB (pie charts of sentiment / emotions / polarity)
   ==================================================================== */

/* Range toggle (Last 30 / Last 90 / All) — sits in the panel head */
.trend-range {
    display: flex;
    gap: 0.4rem;
}

.trend-range__btn {
    /* Tighter than the main .tab styling — segmented-control vibe */
    font-size: 0.8rem !important;
    padding: 0.3rem 0.75rem !important;
}

/* Summary row above the pies */
.trend-summary {
    display: flex;
    gap: 1.75rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1.5rem 0;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-style: italic;
}

.trend-summary strong {
    color: var(--text);
    font-style: normal;
    font-weight: 500;
}

.trend-summary__empty {
    color: var(--text-dim);
    font-style: italic;
}

/* Grid of pie cards — responsive: 3 across on wide, 1 column on narrow */
.trend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.trend-card {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem 1.25rem 1rem 1.25rem;
}

.trend-card__title {
    font-family: var(--font-display);
    font-variation-settings: 'opsz' 24, 'wght' 500;
    color: var(--text);
    font-size: 1.05rem;
    margin: 0 0 1rem 0;
    text-align: center;
}

.trend-pie {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.trend-pie__svg {
    width: 200px;
    height: 200px;
    max-width: 100%;
}

.trend-pie__empty {
    color: var(--text-dim);
    font-style: italic;
    text-align: center;
    padding: 3.5rem 0;
}

.trend-legend {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.trend-legend__row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--text);
}

.trend-legend__swatch {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
}

.trend-legend__label {
    flex: 1;
}

.trend-legend__value {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}


/* ====================================================================
   MOBILE / NARROW VIEWPORT (single breakpoint at 640px)
   Tab row wraps onto multiple rows so nothing gets clipped.
   Padding tightens across cards / panels / modals.
   Trends grid collapses to a single column.
   ==================================================================== */

@media (max-width: 640px) {
    /* Page wrapper — slightly tighter side gutter */
    .page {
        padding: 20px 14px;
    }

    /* Tab row already wraps at any width thanks to the base styling. Mobile-only
       tweak: slightly smaller text + bigger tap target on the buttons. */
    .tab {
        font-size: 0.88rem;
        padding: 10px 14px;
    }

    /* Panels: less padding so content has room to breathe */
    .panel {
        padding: 18px;
        border-radius: var(--radius-md);
    }

    /* Gate / auth card: trim heavy padding */
    .card {
        padding: 28px 22px;
    }

    /* Brand wordmark: smaller display size on phone */
    .brand {
        font-size: clamp(2rem, 8vw, 2.5rem);
    }

    .journal__brand {
        font-size: 1.7rem;
    }

    .journal__header {
        gap: 16px;
        margin-bottom: 20px;
    }

    /* Modals: take full screen width minus a small gutter */
    .modal {
        padding: 24px 20px;
        max-width: calc(100vw - 24px);
    }

    .modal--detail {
        max-width: calc(100vw - 24px);
    }

    /* Detail modal: bigger close target on touch */
    .modal__close {
        font-size: 1.8rem;
        padding: 4px 10px;
    }

    /* Trends summary: stack the three stat spans vertically */
    .trend-summary {
        flex-direction: column;
        gap: 0.4rem;
    }

    /* Trends grid: force one card per row on narrow screens */
    .trend-grid {
        grid-template-columns: 1fr;
    }

    /* Trends pie a touch smaller so legend has room */
    .trend-pie__svg {
        width: 180px;
        height: 180px;
    }

    /* Panel head: stack title above range buttons */
    .panel__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Trend range toggle: take the full row width when stacked */
    .trend-range {
        width: 100%;
        justify-content: stretch;
    }

    .trend-range__btn {
        flex: 1;
        text-align: center;
    }

    /* Write form action row: stack so Save/Clear buttons aren't squished */
    .write-form__actions {
        flex-wrap: wrap;
    }
}


/* ====================================================================
   OFFLINE VERSION BUTTON
   One gold button (echoes the + Add tab / Buy button) with the same
   breathing gold shine. Top copy sits under the login; bottom copy
   shows at the page bottom after login. Toggled in app.js.
   ==================================================================== */
.gate-view {
    margin: auto 0;            /* keeps the login card vertically centered */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.gate-view[hidden] { display: none; }   /* let JS hidden win over display:flex */

/* Self-contained gold button (does not rely on .btn), echoes the + Add tab */
.offline-btn {
    display: inline-block;
    margin: 18px auto 0;       /* sits just under the login card */
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    background-color: rgba(212, 175, 55, 0.15);
    color: #FFE4A0;
    border: 1px solid rgba(212, 175, 55, 0.45);
    animation: tab-add-shine 2.2s ease-in-out infinite;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}
.offline-btn[hidden] { display: none; }  /* same fix for the bottom button */

.offline-btn:hover {
    background-color: rgba(230, 195, 90, 0.30);
    border-color: rgba(230, 195, 90, 0.65);
    color: #FFE4A0;
}

.offline-btn--bottom {
    margin: 32px auto 8px;     /* breathing room at the page bottom */
}

/* Public copy under the gold button — refined: centered, narrow column,
   dim text, with a short hairline divider above. Also gives search engines
   real sentences to index. */
.gate-about {
    position: relative;
    max-width: 460px;
    margin: 34px auto 0;
    padding-top: 26px;
    text-align: center;
    font-family: var(--font-body);
    color: var(--text-dim);
    font-size: 0.98rem;
    line-height: 1.7;
}
/* short centered hairline that matches the card borders (theme-aware) */
.gate-about::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 48px;
    height: 1px;
    transform: translateX(-50%);
    background: var(--border);
}
.gate-about p { margin: 0 0 0.9rem 0; }
.gate-about p:last-child { margin-bottom: 0; }

/* ===== Mood pack ===== */
.mood-card { margin-bottom: 16px; }
.mood-empty { color: var(--text-dim); font-size: 0.9rem; padding: 8px 2px; }

/* --- Calendar header + month nav --- */
.mood-cal__head {
    display: flex; align-items: center; justify-content: center;
    gap: 14px; margin-bottom: 10px;
}
.mood-cal__nav {
    background: var(--surface-elevated); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    width: 30px; height: 30px; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.mood-cal__nav:hover { border-color: var(--accent); color: var(--accent); }

/* --- Calendar grid (Sun -> Sat) --- */
.mood-cal {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.mood-cal__dow {
    text-align: center; font-size: 0.72rem; color: var(--text-dim);
    padding-bottom: 2px; text-transform: uppercase; letter-spacing: 0.04em;
}
.mood-cal__cell {
    min-height: 92px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 4px; display: flex; flex-direction: column;
    cursor: pointer; transition: min-height 0.12s ease;
}
.mood-cal__cell--pad { background: transparent; border-color: transparent; cursor: default; }
.mood-cal__cell--empty { opacity: 0.5; }
.mood-cal__day { font-size: 0.72rem; color: var(--text-dim); margin-bottom: 3px; }
.mood-cal__bars {
    flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1px;
}
/* Each bar takes an equal share, so more emotions = thinner rows (auto-scaled).
   Full-width track (faded remainder, set inline) with an absolute colored fill;
   the label sits centered above the fill so it always reads in full. */
.mood-bar {
    flex: 1 1 0; min-height: 3px; border-radius: 3px; overflow: hidden;
    position: relative; display: flex; align-items: center; justify-content: center;
}
.mood-bar__fill {
    position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px;
}
.mood-bar__txt {
    position: relative; z-index: 1;
    color: #fff; font-size: 0.62rem; white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
/* Expanded day — full labels, lifted above neighbours */
.mood-cal__cell.is-open {
    min-height: 200px; position: relative; z-index: 2;
    border-color: var(--accent); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* --- Emotion map --- */
.mood-emap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mood-emap__list {
    max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px;
}
.mood-emap__row {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
    padding: 5px 6px; border-radius: var(--radius-sm); cursor: pointer;
}
.mood-emap__row:hover { background: var(--surface-elevated); }
.mood-emap__check { accent-color: var(--accent); }
.mood-emap__title {
    color: var(--text); font-size: 0.85rem; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.mood-emap__date { color: var(--text-dim); font-size: 0.72rem; }
.mood-emap__bars { display: flex; flex-direction: column; gap: 6px; }

/* Ranked emotion bars (largest -> smallest) */
.mood-rank { display: grid; grid-template-columns: 90px 1fr 42px; align-items: center; gap: 8px; }
.mood-rank__name { color: var(--text); font-size: 0.82rem; }
.mood-rank__track { background: var(--surface-elevated); border-radius: 6px; height: 12px; overflow: hidden; }
.mood-rank__fill { display: block; height: 100%; border-radius: 6px; }
.mood-rank__pct { color: var(--text-dim); font-size: 0.78rem; text-align: right; }

/* --- Word cloud (renders above its button) --- */
.mood-cloud {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
    line-height: 1.5; margin-bottom: 12px; min-height: 24px;
}
.mood-cloud__word { color: var(--text); font-family: var(--font-display); }
.mood-cloud__word:nth-child(3n)   { color: var(--accent); }
.mood-cloud__word:nth-child(5n)   { color: var(--text-dim); }
.mood-cloud__btn { align-self: flex-start; }

/* --- Mobile: 7 columns get tight, so hide bar labels until a day is tapped --- */
@media (max-width: 560px) {
    .mood-cal { gap: 2px; }
    .mood-cal__cell { min-height: 72px; padding: 3px; }
    .mood-bar__txt { display: none; }
    .mood-cal__cell.is-open .mood-bar__txt { display: inline; }
    .mood-emap { grid-template-columns: 1fr; }
    .mood-rank { grid-template-columns: 76px 1fr 38px; }
}


/* ===== Planner pack ===== */
/* ====================================================================
   PLANNER PACK — Today card
   Three priority inputs + intent dropdown + emotion-aware prompt callout.
   Uses the shared .dashboard-card foundation; only the inner layout is new.
   ==================================================================== */
.planner-today__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.planner-today__date {
    color: var(--text-dim);
    font-size: 0.95rem;
    font-style: italic;
}

.planner-prompt {
    background-color: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 18px;
}

.planner-prompt__label {
    display: block;
    color: var(--accent);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    font-weight: 600;
}

.planner-prompt__text {
    margin: 0;
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.5;
}

.planner-intent {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.planner-intent__label {
    color: var(--text-dim);
    font-size: 0.95rem;
}

.planner-intent__select {
    background-color: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.95rem;
    font-family: var(--font-body);
    cursor: pointer;
    min-width: 180px;
}

.planner-intent__select:hover {
    border-color: var(--text-dim);
}

.planner-intent__select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.planner-priorities {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.planner-priorities__label {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.planner-priority {
    /* Inherits .field__input styling; tighten padding slightly so the three
       inputs feel like a list rather than three giant boxes */
    padding: 10px 14px;
    font-size: 1rem;
}

.planner-priorities__saved {
    color: var(--accent);
    font-size: 0.85rem;
    font-style: italic;
    margin: 4px 0 0 0;
    align-self: flex-end;
}

/* This Week + Goals placeholder cards — slightly dimmed so they read as
   "coming soon" without screaming about it */
.planner-week-placeholder .dashboard-card__title,
.planner-goals-placeholder .dashboard-card__title {
    color: var(--text-dim);
}
.planner-week-placeholder .dashboard-card__body,
.planner-goals-placeholder .dashboard-card__body {
    font-style: italic;
}


/* ====================================================================
   PLANNER PACK — This Week card
   Auto-generated summary block at top, three review textareas below.
   ==================================================================== */
.planner-week__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.planner-week__range {
    color: var(--text-dim);
    font-size: 0.95rem;
    font-style: italic;
}

.planner-week__summary {
    background-color: var(--surface-elevated);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.planner-week__loading,
.planner-week__empty {
    color: var(--text-dim);
    margin: 0;
    font-style: italic;
}

.planner-week__stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.planner-week__stat:last-child {
    border-bottom: none;
}

.planner-week__stat-label {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.planner-week__stat-value {
    color: var(--text);
    font-size: 1rem;
    text-align: right;
    /* Allow long entry titles to wrap rather than overflow the card */
    overflow-wrap: anywhere;
}

.planner-week__stat-day {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9rem;
}

.planner-review {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.planner-review__label {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}

.planner-review__field {
    /* Smaller min-height than journal textarea — three of these stack so each
       only needs a few lines visible by default. User can drag taller. */
    min-height: 80px;
    max-height: 180px;
}

.planner-review__saved {
    color: var(--accent);
    font-size: 0.85rem;
    font-style: italic;
    margin: 4px 0 0 0;
    align-self: flex-end;
}


/* ====================================================================
   PLANNER PACK — history dropdowns + read-only past states
   The dropdown sits next to the date/range label on Today + Week cards.
   When a past date/week is selected, the wrapper card gets a "--readonly"
   class to visually dim the inputs.
   ==================================================================== */
.planner-history {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.planner-history__select {
    /* Mirrors the existing field__input styling but compact for header use */
    background-color: var(--surface-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    max-width: 220px;
}

.planner-history__select:hover {
    border-color: var(--accent);
}

.planner-history__select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(176, 133, 245, 0.25);
}

/* ----- Read-only state shared by both cards -----
   Dim the inputs slightly + show a not-allowed cursor so it's obvious
   you're looking at saved history, not the live editable form. */
.planner-today--readonly .planner-priority,
.planner-today--readonly .planner-intent,
.planner-week--readonly .planner-review__field {
    opacity: 0.72;
    cursor: not-allowed;
}

.planner-today--readonly .planner-priority:focus,
.planner-week--readonly .planner-review__field:focus {
    /* No focus ring on read-only fields — they're not actionable */
    box-shadow: none;
    border-color: var(--border);
}

.planner-today--readonly .planner-review__saved,
.planner-week--readonly .planner-review__saved {
    /* Hide the "Saved" indicator entirely on past records */
    display: none !important;
}


/* ====================================================================
   PLANNER PACK — Save action row + donut chart + snapshot history boxes
   New in Step 9d. Replaces the old auto-save indicator with an explicit
   Save button + visible past-saves list.
   ==================================================================== */
.planner-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.planner-actions__save {
    /* Primary CTA — matches the app's existing .btn--primary styling */
    padding: 8px 18px;
    font-size: 0.95rem;
}

.planner-actions__hint {
    color: var(--accent);
    font-size: 0.9rem;
    font-style: italic;
}

/* ----- Donut chart for intent distribution ----- */
.planner-donut {
    margin-top: 18px;
    padding: 14px 16px;
    background-color: var(--surface-elevated);
    border-radius: var(--radius-sm);
}

.planner-donut__title {
    margin: 0 0 10px 0;
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.planner-donut__row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.planner-donut__chart {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
}

.planner-donut__svg {
    width: 100%;
    height: 100%;
    display: block;
}

.planner-donut__count {
    /* Big number in the hole of the donut */
    fill: var(--text);
    font-size: 22px;
    font-weight: 600;
}

.planner-donut__count-label {
    fill: var(--text-dim);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.planner-donut__legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.planner-donut__legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.planner-donut__swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.planner-donut__legend-label {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planner-donut__legend-pct {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ----- Snapshot history list ----- */
.planner-snapshots {
    margin-top: 18px;
}

.planner-snapshots__title {
    margin: 0 0 10px 0;
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.planner-snapshots__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.planner-snapshots__empty {
    color: var(--text-dim);
    font-style: italic;
    margin: 0;
}

.planner-snapshots__toggle {
    /* Plain text-style button — not a CTA */
    margin-top: 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.planner-snapshots__toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}

/* ----- Individual snapshot box ----- */
.snapshot-box {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    position: relative;
}

.snapshot-box:first-child {
    /* Latest snapshot — subtle accent left border so it stands out */
    border-left: 3px solid var(--accent);
    padding-left: 14px;
}

.snapshot-box__header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.snapshot-box__time {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.snapshot-box__badge {
    background-color: var(--accent);
    color: #1a1130;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 999px;
}

.snapshot-box__intent {
    /* Colored chip indicating the saved intent_emotion */
    color: #1a1130;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.snapshot-box__delete {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.snapshot-box__delete:hover {
    color: #d97070;
    background-color: rgba(217, 112, 112, 0.1);
}

.snapshot-box__body {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.snapshot-box__line {
    color: var(--text);
    font-size: 0.95rem;
    /* Allow long priority text to wrap rather than overflow */
    overflow-wrap: anywhere;
}

.snapshot-box__line--empty {
    color: var(--text-dim);
    font-style: italic;
}

/* When viewing a past date, hide save button entirely (handled in JS),
   but also dim the box body line wrapping a touch */
.planner-today--readonly .planner-actions,
.planner-week--readonly .planner-actions {
    display: none;
}


/* ====================================================================
   PLANNER PACK — donut empty state (Step 9f)
   The donut card is always visible now. When there are no snapshots,
   the chart area renders this centered message instead of the SVG.
   ==================================================================== */
.planner-donut__empty {
    /* Match the chart's square footprint so layout doesn't jump when
       data appears for the first time */
    width: 100%;
    height: 100%;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
}

.planner-donut__empty-title {
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.planner-donut__empty-hint {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-style: italic;
}

/* Planner week nav arrows (step any week) */
.planner-week__nav {
    background: var(--surface-elevated); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    width: 30px; height: 30px; font-size: 1.1rem; line-height: 1; cursor: pointer;
    align-self: center;
}
.planner-week__nav:hover { border-color: var(--accent); color: var(--accent); }
.planner-week__nav:disabled { opacity: 0.4; cursor: default; }
.planner-week__nav:disabled:hover { border-color: var(--border); color: var(--text); }

/* --- Site footer (legal links) ------------------------------------------------ */
.site-footer {
    text-align: center;
    padding: 28px 16px 36px;
    font-size: 0.9rem;
    color: var(--text-soft, #B9B3CC);
}
.site-footer a { color: inherit; text-decoration: none; opacity: 0.75; }
.site-footer a:hover { color: var(--accent); opacity: 1; }
.footer-sep { margin: 0 10px; opacity: 0.5; }

/* Legal links inside the login gate view */
.gate-links {
    text-align: center;
    margin-top: 22px;
    font-size: 0.9rem;
    color: var(--text-soft, #B9B3CC);
}
.gate-links a { color: inherit; text-decoration: none; opacity: 0.75; }
.gate-links a:hover { color: var(--accent); opacity: 1; }
