/* Anam — Core layout, cottagecore theme, CSS variables, night mode */

/* ── Self-hosted fonts (no external Google Fonts dependency) ── */

/* Fredoka — Bubbly, rounded cottagecore body font (variable 400-700) */
@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/fredoka-latin.woff2') format('woff2');
}

/* Kalam — Handwritten cottagecore display font */
@font-face {
    font-family: 'Kalam';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/kalam-regular-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Kalam';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/kalam-bold-latin.woff2') format('woff2');
}

/* Princess Sofia — Fairy tale enchantment title font */
@font-face {
    font-family: 'Princess Sofia';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/princess-sofia-latin.woff2') format('woff2');
}

/* Cinzel Decorative — Elegant fantasy title font */
@font-face {
    font-family: 'Cinzel Decorative';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/cinzel-decorative-bold-latin.woff2') format('woff2');
}

/* Great Vibes — Flowing sparkly script title font */
@font-face {
    font-family: 'Great Vibes';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/great-vibes-latin.woff2') format('woff2');
}

/* Baloo 2 — Alternative bubbly body font (available to swap in) */
@font-face {
    font-family: 'Baloo 2';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/baloo2-latin.woff2') format('woff2');
}

/* Nunito — Soft rounded alternative (available to swap in) */
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/nunito-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Nunito';
    font-style: italic;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/nunito-italic-latin.woff2') format('woff2');
}

/* Lora — Elegant serif alternative (available to swap in) */
@font-face {
    font-family: 'Lora';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/lora-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Lora';
    font-style: italic;
    font-weight: 400 700;
    font-display: swap;
    src: url('/static/fonts/lora-italic-latin.woff2') format('woff2');
}

/* ── CSS Variables ── */
:root {
    /* Page */
    --bg-page: #FFF5F0;
    --bg-card: rgba(255, 250, 250, 0.72);
    --bg-chat: #FFFAF7;
    --bg-input: #FFFFFF;
    --surface-raised: rgba(255, 255, 255, 0.72);
    --surface-frost: rgba(255, 255, 255, 0.54);
    --surface-tint: rgba(255, 226, 234, 0.45);
    --surface-gingham: rgba(255, 240, 244, 0.58);
    --surface-ribbon: rgba(255, 247, 223, 0.72);

    /* Text */
    --text-primary: #7A3050;
    --text-secondary: #9B5070;
    --text-muted: #B87A95;

    /* Borders */
    --border-soft: rgba(255, 182, 193, 0.4);
    --border-card: rgba(255, 192, 203, 0.3);
    --border-strong: rgba(255, 206, 217, 0.64);

    /* Shauna's bubble */
    --user-bubble-top: #FADCE4;
    --user-bubble-bottom: #F2C4D0;
    --user-border: #C47A8A;

    /* Active identity (set by JS) */
    --identity-gingham: #F2B8C6;
    --identity-gingham-night: #8B5A68;
    --identity-accent: #C47A8A;
    --identity-accent-rgb: 196, 122, 138;
    --identity-bubble-top: #F9D2DC;
    --identity-bubble-bottom: #F2B8C6;
    --identity-bubble-night: #5A3040;
    --identity-check-size: 22px;

    /* Typography — cottagecore defaults (swap alternatives by changing these) */
    /* Title options: 'Princess Sofia' (fairy tale), 'Cinzel Decorative' (elegant fantasy), 'Great Vibes' (flowing script) */
    /* Display options: 'Kalam' (handwritten), 'Lora' (storybook serif) */
    /* Body options: 'Fredoka' (bubbly), 'Baloo 2' (bouncy), 'Nunito' (soft) */
    --font-title: 'Princess Sofia', 'Great Vibes', cursive;
    --font-display: 'Kalam', 'Segoe UI', cursive;
    --font-body: 'Fredoka', 'Nunito', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

    /* Semantic colors */
    --color-success: #5a9a6a;
    --color-danger: #C0392B;
    --color-danger-hover: #E74C3C;
    --color-sage: #7F9A86;
    --color-sage-soft: rgba(127, 154, 134, 0.18);
    --color-honey: #D9B36F;
    --color-honey-soft: rgba(217, 179, 111, 0.20);
    --color-status-connected: #5BA89A;
    --color-status-disconnected: #C47A8A;
    --color-status-reconnecting: #C9A840;

    /* Transitions */
    --transition-theme: 0.5s ease;
    --shadow-card:
        0 1px 2px rgba(139, 90, 90, 0.06),
        0 10px 26px rgba(139, 90, 90, 0.10),
        0 22px 60px rgba(139, 90, 90, 0.10);
    --shadow-float:
        0 12px 32px rgba(var(--identity-accent-rgb), 0.16),
        0 24px 54px rgba(139, 90, 90, 0.12);
}

/* ── Night Mode (Candlelight) ── */
body.night-mode {
    --bg-page: #2A1F1A;
    --bg-card: rgba(61, 46, 38, 0.88);
    --bg-chat: #332520;
    --bg-input: #3D2E26;
    --surface-raised: rgba(77, 59, 49, 0.78);
    --surface-frost: rgba(68, 50, 42, 0.62);
    --surface-tint: rgba(120, 79, 69, 0.24);
    --surface-gingham: rgba(82, 59, 52, 0.56);
    --surface-ribbon: rgba(111, 85, 58, 0.58);

    --text-primary: #E8D8C8;
    --text-secondary: #C9B89A;
    --text-muted: #9A7A70;

    --border-soft: rgba(139, 90, 60, 0.4);
    --border-card: rgba(100, 70, 50, 0.3);
    --border-strong: rgba(154, 112, 92, 0.48);

    --user-bubble-top: #5A3040;
    --user-bubble-bottom: #4A2835;
    --user-border: #8B5A68;
    --shadow-card:
        0 2px 4px rgba(0, 0, 0, 0.22),
        0 12px 28px rgba(0, 0, 0, 0.22),
        0 26px 64px rgba(0, 0, 0, 0.18);
    --shadow-float:
        0 16px 40px rgba(0, 0, 0, 0.35),
        0 24px 72px rgba(0, 0, 0, 0.18);
}

/* Night vignette — fades in/out smoothly with theme transition */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(20, 12, 8, 0.3) 100%
    );
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity var(--transition-theme);
}

body.night-mode::before {
    opacity: 1;
}

body::after {
    content: '';
    position: fixed;
    inset: auto auto -120px -100px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--identity-accent-rgb), 0.16) 0%, rgba(var(--identity-accent-rgb), 0) 72%);
    pointer-events: none;
    filter: blur(8px);
    z-index: 0;
    opacity: 0.8;
}

/* ── Selection styling ── */
::selection {
    background: rgba(196, 122, 138, 0.25);
    color: var(--text-primary);
}

body.night-mode ::selection {
    background: rgba(212, 165, 132, 0.3);
}

/* ── Focus-visible for keyboard navigation ── */
:focus-visible {
    outline: 2px solid var(--identity-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible {
    outline-offset: 3px;
}

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

html {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: var(--font-body);
    line-height: 1.5;
    background-color: var(--bg-page);
    background-image:
        radial-gradient(circle at top left, rgba(255, 222, 230, 0.92) 0%, rgba(255, 222, 230, 0) 34%),
        radial-gradient(circle at top right, rgba(255, 241, 205, 0.45) 0%, rgba(255, 241, 205, 0) 26%),
        linear-gradient(180deg, #FFF8F4 0%, #FFF4F6 42%, #FFF0EC 100%);
    color: var(--text-primary);
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    transition: background-color var(--transition-theme), color var(--transition-theme);
}

body.night-mode {
    background-image:
        radial-gradient(circle at top left, rgba(110, 72, 62, 0.48) 0%, rgba(110, 72, 62, 0) 32%),
        radial-gradient(circle at top right, rgba(137, 91, 72, 0.18) 0%, rgba(137, 91, 72, 0) 26%),
        linear-gradient(180deg, #32241E 0%, #2B201B 46%, #221915 100%);
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
}

/* ── Layout ── */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 980px;
    margin: 0 auto;
    padding: 0 18px;
    position: relative;
    z-index: 1;
}

/* ── Header ── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    flex-shrink: 0;
    margin: 10px 0 2px;
    background:
        linear-gradient(135deg, var(--surface-raised), var(--surface-frost)),
        var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(139, 90, 90, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-title {
    font-family: var(--font-title);
    font-size: 2.3rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    text-shadow: 0 2px 10px rgba(139, 90, 90, 0.12);
    line-height: 0.9;
}

/* Current identity label (shown next to title) */
.current-identity-label {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--identity-accent);
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.2s, color var(--transition-theme), transform 0.2s ease;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(var(--identity-accent-rgb), 0.16);
    background: rgba(var(--identity-accent-rgb), 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
    white-space: nowrap;
}

.current-identity-label:hover {
    opacity: 1;
    background: rgba(var(--identity-accent-rgb), 0.14);
    transform: translateY(-1px);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* Settings button */
.settings-btn {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(var(--identity-accent-rgb), 0.08));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--text-secondary);
    text-decoration: none;
    box-shadow:
        0 6px 14px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.settings-btn:hover {
    border-color: rgba(var(--identity-accent-rgb), 0.38);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.18);
}

/* Pack mail button */
.mail-btn {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(var(--identity-accent-rgb), 0.08));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
    box-shadow:
        0 6px 14px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.mail-btn:hover {
    border-color: rgba(var(--identity-accent-rgb), 0.38);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.18);
}

.mail-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--identity-accent);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    line-height: 1;
}

/* Offline/online detection banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 8px 16px;
    text-align: center;
    font-size: 0.8rem;
    font-family: var(--font-body);
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-banner.visible {
    transform: translateY(0);
}

.offline-banner.offline {
    background: rgba(180, 100, 100, 0.9);
    color: #fff;
    backdrop-filter: blur(8px);
}

.offline-banner.back-online {
    background: rgba(100, 160, 100, 0.9);
    color: #fff;
    backdrop-filter: blur(8px);
}

.offline-banner.cached-shell {
    background: rgba(168, 125, 74, 0.92);
    color: #fff7ec;
    backdrop-filter: blur(8px);
}

/* Autowake toast notification */
.autowake-toast {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 2px solid var(--border-soft);
    border-radius: 12px;
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-primary);
    z-index: 200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    animation: toastSlideIn 0.25s ease-out forwards;
    will-change: transform, opacity;
}

.autowake-toast.toast-leaving {
    animation: toastSlideOut 0.2s ease-in forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    to { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.95); }
}

@media screen and (max-width: 480px) {
    .autowake-toast {
        white-space: normal;
        text-align: center;
        padding: 8px 16px;
        font-size: 0.8rem;
    }
}

/* .autowake-toast.visible replaced by toastSlideIn/toastSlideOut keyframes */

/* Night mode toggle */
.night-toggle {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(var(--identity-accent-rgb), 0.08));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--text-secondary);
    box-shadow:
        0 6px 14px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.night-toggle:hover {
    border-color: rgba(var(--identity-accent-rgb), 0.38);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.18);
}

/* New conversation button */
.new-convo-btn {
    background: none;
    border: 2px solid var(--border-soft);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.new-convo-btn:hover {
    border-color: var(--identity-accent);
    color: var(--identity-accent);
}

/* ── Main content area ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 14px;
    padding-bottom: 8px;
}

/* ── Card style ── */
.card {
    background:
        linear-gradient(180deg, var(--surface-raised), var(--surface-frost) 52%, rgba(var(--identity-accent-rgb), 0.04)),
        var(--bg-card);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background var(--transition-theme), box-shadow var(--transition-theme),
                border-color var(--transition-theme), transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0, transparent 12px, rgba(255, 255, 255, 0.10) 12px, rgba(255, 255, 255, 0.10) 13px, transparent 13px),
        linear-gradient(0deg, transparent 0, transparent 12px, rgba(255, 255, 255, 0.08) 12px, rgba(255, 255, 255, 0.08) 13px, transparent 13px);
    background-size: 26px 26px;
    opacity: 0.35;
}

body.night-mode .card::before {
    opacity: 0.12;
}

body.night-mode .card {
    box-shadow: var(--shadow-card);
}

/* ── Scrollbar ── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

::-webkit-scrollbar {
    width: 5px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(var(--identity-accent-rgb), 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--identity-accent-rgb), 0.5);
}

/* ── Wellness button ── */
.wellness-btn {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(var(--identity-accent-rgb), 0.08));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--text-secondary);
    box-shadow:
        0 6px 14px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.wellness-btn:hover {
    border-color: rgba(var(--identity-accent-rgb), 0.38);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.18);
}

.wellness-btn.saved {
    border-color: var(--color-success);
    box-shadow: 0 0 8px rgba(90, 154, 106, 0.3);
}

/* ── Modal overlay + card ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background:
        linear-gradient(180deg, var(--surface-raised), var(--surface-frost)),
        var(--bg-page);
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    padding: 20px;
    width: 360px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-float);
    animation: modalSlideUp 0.25s ease-out;
    will-change: transform, opacity;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--border-soft);
}

.modal-close-btn:active {
    background: var(--border-soft);
    transform: scale(0.92);
}

/* ── Wellness form ── */
.wellness-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.wellness-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wellness-field.full-width {
    grid-column: 1 / -1;
}

.wellness-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.wellness-field select,
.wellness-field input,
.wellness-field textarea {
    padding: 8px 10px;
    border: 1.5px solid var(--border-soft);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-input);
    outline: none;
    box-sizing: border-box;
    width: 100%;
}

.wellness-field select:focus,
.wellness-field input:focus,
.wellness-field textarea:focus {
    border-color: var(--identity-accent);
}

.wellness-field textarea {
    resize: vertical;
    min-height: 48px;
}

.wellness-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.action-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.save {
    background: linear-gradient(180deg, color-mix(in srgb, var(--identity-accent) 88%, white 12%), var(--identity-accent));
    color: white;
    box-shadow: 0 12px 24px rgba(var(--identity-accent-rgb), 0.22);
}

.action-btn.save:hover {
    filter: brightness(0.95);
    transform: translateY(-1px) scale(1.02);
}

.action-btn.saved,
.action-btn.save.saved {
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-success) 82%, white 18%), var(--color-success));
    box-shadow: 0 12px 24px rgba(90, 154, 106, 0.24);
}

.action-btn.save:active {
    transform: scale(0.98);
}

/* ── Hub button (replaces individual header buttons) ── */
.hub-btn {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(var(--identity-accent-rgb), 0.08));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--text-secondary);
    position: relative;
    box-shadow:
        0 6px 14px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hub-btn:hover {
    border-color: rgba(var(--identity-accent-rgb), 0.38);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.18);
}

/* ── Hub overlay (home menu) ── */
.hub-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.hub-panel {
    background:
        linear-gradient(180deg, var(--surface-raised), var(--surface-frost)),
        var(--bg-page);
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    padding: 24px;
    width: 360px;
    max-width: 92vw;
    box-shadow: var(--shadow-float);
    animation: modalSlideUp 0.25s ease-out;
}

.hub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.hub-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hub-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}

.hub-close-btn:hover {
    color: var(--text-primary);
    background: var(--border-soft);
}

.hub-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.hub-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(var(--identity-accent-rgb), 0.08)),
        var(--bg-card);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 18px;
    cursor: pointer;
    font-family: var(--font-body);
    color: var(--text-primary);
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 8px 18px rgba(var(--identity-accent-rgb), 0.08);
}

.hub-card:hover {
    border-color: rgba(var(--identity-accent-rgb), 0.34);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(var(--identity-accent-rgb), 0.12)),
        var(--bg-card);
    transform: translateY(-3px);
    box-shadow:
        0 12px 24px rgba(var(--identity-accent-rgb), 0.16),
        0 18px 36px rgba(0, 0, 0, 0.08);
}

.hub-card:active {
    transform: scale(0.97) translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.hub-card-icon {
    width: 58px;
    height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-radius: 18px;
    line-height: 1;
    position: relative;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(var(--identity-accent-rgb), 0.10)),
        rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.14);
    box-shadow:
        0 8px 18px rgba(var(--identity-accent-rgb), 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.hub-card-icon-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.hub-card-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: var(--identity-accent);
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    line-height: 1;
}

.hub-card-label {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Hub 3-column responsive fallback */
@media (max-width: 400px) {
    .hub-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
    .hub-grid-3 .hub-card:last-child {
        grid-column: 1 / -1;
    }
}
