:root {
    --bg-base: #f4efe6;
    --bg-surface: #fffaf2;
    --bg-surface-strong: #f6ead8;
    --ink-primary: #1e1a16;
    --ink-muted: #6b6258;
    --ink-faint: #9b9186;
    --accent-primary: #e96b4c;
    --accent-secondary: #1d7f7a;
    --accent-tertiary: #f0b33a;
    --outline: rgba(30, 26, 22, 0.12);
    --shadow: 0 18px 45px rgba(32, 24, 17, 0.18);
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: 0.25s ease;
}

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

[hidden] {
    display: none !important;
}

body {
    font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
    color: var(--ink-primary);
    background: radial-gradient(circle at top, rgba(240, 179, 58, 0.2), transparent 50%),
        radial-gradient(circle at 10% 70%, rgba(29, 127, 122, 0.18), transparent 55%),
        linear-gradient(160deg, #f7f1e8 0%, #f1e4d4 60%, #efe1cf 100%);
    min-height: 100vh;
}

body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 999px;
    z-index: -1;
    filter: blur(0px);
}

body::before {
    width: 220px;
    height: 220px;
    background: rgba(233, 107, 76, 0.18);
    top: -60px;
    right: 8%;
}

body::after {
    width: 160px;
    height: 160px;
    background: rgba(29, 127, 122, 0.15);
    bottom: 8%;
    left: 12%;
}

.app {
    max-width: 520px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 20px 18px 96px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--bg-surface-strong);
    font-size: 18px;
    color: var(--accent-secondary);
    box-shadow: var(--shadow);
}

.brand-title {
    font-family: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.screen {
    display: none;
    flex-direction: column;
    gap: 18px;
}

.screen.active {
    display: flex;
    animation: screenFade 0.35s ease;
}

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

.panel {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--outline);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.avatar-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(233, 107, 76, 0.2), rgba(29, 127, 122, 0.2));
    display: grid;
    place-items: center;
    font-weight: 600;
}

.avatar-name {
    font-weight: 600;
    font-size: 15px;
}

.avatar-day {
    font-size: 12px;
    color: var(--ink-faint);
}

.time-chip {
    background: var(--bg-surface-strong);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--ink-muted);
}

.stats-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
}

.stat-pill {
    background: var(--bg-surface);
    border-radius: 999px;
    padding: 10px 12px;
    border: 1px solid var(--outline);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    gap: 8px;
}

.stat-pill strong {
    font-size: 13px;
}

.moment-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid var(--outline);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.moment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.moment-header h2 {
    font-family: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
    font-size: 20px;
}

.moment-tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(233, 107, 76, 0.18);
    color: var(--accent-primary);
    font-weight: 600;
}

.moment-scene {
    font-size: 14px;
    color: var(--ink-muted);
    line-height: 1.6;
}

.moment-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-item {
    border-radius: var(--radius-md);
    border: 1px solid var(--outline);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fff;
    transition: var(--transition);
    cursor: pointer;
}

.choice-item:hover {
    border-color: rgba(233, 107, 76, 0.5);
    transform: translateY(-1px);
}

.choice-item input {
    margin-top: 2px;
}

.choice-label {
    font-size: 14px;
    font-weight: 500;
}

.moment-effects {
    background: var(--bg-surface-strong);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 12px;
    color: var(--ink-muted);
    display: none;
}

.moment-effects.active {
    display: block;
}

.moment-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.moment-status {
    min-height: 18px;
    font-size: 12px;
    color: var(--ink-muted);
}

.loading-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skeleton-line {
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(30, 26, 22, 0.08), rgba(30, 26, 22, 0.18), rgba(30, 26, 22, 0.08));
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
}

.skeleton-line.wide {
    height: 14px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.status-card {
    background: rgba(29, 127, 122, 0.08);
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px dashed rgba(29, 127, 122, 0.35);
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--ink-muted);
}

.status-card h3 {
    color: var(--accent-secondary);
    font-size: 16px;
}

.resolve-card {
    background: rgba(233, 107, 76, 0.12);
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid rgba(233, 107, 76, 0.35);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.resolve-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.toast {
    opacity: 0;
    transform: translateY(8px);
    transition: var(--transition);
    font-size: 12px;
    color: var(--accent-secondary);
    min-height: 16px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 15, 0.65);
    display: grid;
    place-items: center;
    z-index: 300;
}

.auth-card {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--outline);
    text-align: center;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-card h3 {
    font-size: 18px;
}

.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.screen-header h2 {
    font-family: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
    font-size: 20px;
}

.diary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diary-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    border: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diary-card h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-faint);
}

.diary-card button {
    align-self: flex-start;
}

.empty-state {
    text-align: center;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 26px 20px;
    border: 1px dashed var(--outline);
    color: var(--ink-muted);
}

.catchup-banner {
    background: rgba(29, 127, 122, 0.12);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--accent-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid rgba(29, 127, 122, 0.3);
}

.stats-grid {
    display: grid;
    gap: 12px;
}

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    border: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.stat-bar {
    height: 8px;
    background: rgba(30, 26, 22, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
    border-radius: 999px;
    transition: width 0.4s ease;
}

.stats-meta {
    font-size: 12px;
    color: var(--ink-muted);
    display: flex;
    justify-content: space-between;
}

.bottom-nav {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 36px);
    max-width: 520px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(255, 250, 242, 0.9);
    border: 1px solid var(--outline);
    padding: 8px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.nav-btn {
    border: none;
    background: transparent;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    color: var(--ink-muted);
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn.active {
    background: var(--bg-surface-strong);
    color: var(--ink-primary);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.primary-btn {
    background: var(--accent-primary);
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 12px 25px rgba(233, 107, 76, 0.25);
}

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

.secondary-btn {
    background: var(--bg-surface);
    color: var(--ink-primary);
    border: 1px solid var(--outline);
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 600;
}

.ghost-btn {
    background: transparent;
    color: var(--ink-muted);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
}

.ghost-btn:hover {
    border-color: var(--outline);
    color: var(--ink-primary);
}

.icon-btn {
    background: var(--bg-surface-strong);
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 18, 15, 0.4);
}

.modal-card {
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    width: min(90%, 420px);
    border: 1px solid var(--outline);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.modal-subtitle {
    font-size: 13px;
    color: var(--ink-muted);
}

textarea {
    width: 100%;
    min-height: 120px;
    border-radius: 12px;
    border: 1px solid var(--outline);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: #fff;
}

textarea:focus {
    outline: none;
    border-color: rgba(233, 107, 76, 0.6);
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 12px;
    color: var(--ink-faint);
}

.modal-status {
    min-height: 18px;
    font-size: 12px;
    color: var(--ink-muted);
}

[data-reveal] {
    opacity: 0;
    transform: translateY(10px);
}

body.is-loaded [data-reveal] {
    animation: revealUp 0.5s ease forwards;
}

body.is-loaded [data-reveal]:nth-child(2) {
    animation-delay: 0.05s;
}

body.is-loaded [data-reveal]:nth-child(3) {
    animation-delay: 0.1s;
}

body.is-loaded [data-reveal]:nth-child(4) {
    animation-delay: 0.15s;
}

@keyframes revealUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 420px) {
    .app {
        padding: 16px 14px 96px;
    }

    .stats-strip {
        grid-template-columns: repeat(2, 1fr);
    }

    .moment-actions {
        grid-template-columns: 1fr;
    }

    .stats-meta {
        flex-direction: column;
        gap: 6px;
    }
}
