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

:root {
    --cream: #f7f2eb;
    --warm: #ede5d8;
    --sand: #d4c4aa;
    --clay: #b8956a;
    --bark: #7a5c3a;
    --ink: #2e2018;
    --mist: #f0ece4;
    --shadow: rgba(90, 55, 20, 0.1);
}

html,
body {
    height: 100%;
    background: var(--cream);
    color: var(--ink);
    font-family: "DM Sans", sans-serif;
    font-weight: 300;
}

/* ── Noise texture overlay ── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 200px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

/* ── Warm ambient blobs ── */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(
            ellipse 60% 50% at 15% 10%,
            rgba(212, 196, 170, 0.35) 0%,
            transparent 70%
        ),
        radial-gradient(
            ellipse 50% 60% at 85% 90%,
            rgba(184, 149, 106, 0.2) 0%,
            transparent 70%
        ),
        radial-gradient(
            ellipse 40% 40% at 80% 20%,
            rgba(237, 229, 216, 0.4) 0%,
            transparent 60%
        );
    pointer-events: none;
    z-index: 0;
}

/* ── Layout ── */
.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px 64px;
    max-width: 480px;
    margin: 0 auto;
}

/* ── Header ── */
header {
    width: 100%;
    text-align: center;
    margin-bottom: 40px;
    animation: fadeUp 0.8s ease both;
}

.wordmark {
    font-family: "Cormorant Garamond", serif;
    font-size: 2.8rem;
    font-weight: 300;
    letter-spacing: 0.12em;
    color: var(--bark);
    line-height: 1;
}

.tagline {
    margin-top: 6px;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sand);
}

/* ── Dietary toggles ── */
.toggles {
    display: flex;
    gap: 10px;
    margin-bottom: 32px;
    animation: fadeUp 0.8s 0.1s ease both;
}

.toggle-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--sand);
    background: transparent;
    font-family: "DM Sans", sans-serif;
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--bark);
    cursor: pointer;
    transition:
        background 0.2s,
        border-color 0.2s,
        color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.toggle-pill.active {
    background: var(--bark);
    border-color: var(--bark);
    color: var(--cream);
}

.toggle-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    flex-shrink: 0;
}

/* ── Mode switcher ── */
.mode-switcher {
    display: flex;
    background: var(--warm);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 36px;
    animation: fadeUp 0.8s 0.15s ease both;
}

.mode-btn {
    flex: 1;
    padding: 9px 22px;
    border: none;
    border-radius: 999px;
    background: transparent;
    font-family: "DM Sans", sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--clay);
    cursor: pointer;
    transition:
        background 0.25s,
        color 0.25s;
    -webkit-tap-highlight-color: transparent;
}

.mode-btn.active {
    background: var(--cream);
    color: var(--bark);
    box-shadow: 0 1px 6px var(--shadow);
}

/* ── Mood input ── */
.mood-wrap {
    width: 100%;
    margin-bottom: 28px;
    animation: fadeUp 0.8s 0.2s ease both;
}

.mood-label {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sand);
    margin-bottom: 8px;
    display: block;
}

.mood-input {
    width: 100%;
    background: var(--mist);
    border: 1.5px solid var(--warm);
    border-radius: 16px;
    padding: 14px 18px;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.05rem;
    font-style: italic;
    color: var(--ink);
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}

.mood-input::placeholder {
    color: var(--sand);
}
.mood-input:focus {
    border-color: var(--clay);
}

/* ── Suggest button ── */
.suggest-btn {
    width: 100%;
    padding: 20px;
    border: none;
    border-radius: 20px;
    background: var(--bark);
    color: var(--cream);
    font-family: "Cormorant Garamond", serif;
    font-size: 1.35rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition:
        transform 0.15s,
        box-shadow 0.2s,
        background 0.2s;
    box-shadow: 0 4px 20px rgba(90, 55, 20, 0.22);
    animation: fadeUp 0.8s 0.25s ease both;
    -webkit-tap-highlight-color: transparent;
}

.suggest-btn:hover {
    background: #6a4e30;
    box-shadow: 0 6px 28px rgba(90, 55, 20, 0.3);
}
.suggest-btn:active {
    transform: scale(0.98);
}
.suggest-btn.loading {
    pointer-events: none;
    opacity: 0.75;
}

/* ── Result card ── */
.result-card {
    width: 100%;
    margin-top: 32px;
    background: var(--mist);
    border: 1.5px solid var(--warm);
    border-radius: 24px;
    padding: 28px 26px;
    box-shadow: 0 8px 32px var(--shadow);
    animation: cardReveal 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.result-eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sand);
    margin-bottom: 10px;
}

.result-title {
    font-family: "Cormorant Garamond", serif;
    font-size: 1.9rem;
    font-weight: 400;
    line-height: 1.15;
    color: var(--bark);
    margin-bottom: 14px;
}

.result-body {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--ink);
    opacity: 0.8;
}

.result-divider {
    height: 1px;
    background: var(--warm);
    margin: 18px 0;
}

.result-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-tag {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--warm);
    color: var(--clay);
}

.result-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 18px;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--bark);
    text-decoration: none;
    border-bottom: 1px solid var(--sand);
    padding-bottom: 1px;
    transition:
        color 0.2s,
        border-color 0.2s;
}

.result-link:hover {
    color: var(--clay);
    border-color: var(--clay);
}

/* ── History ── */
.history-section {
    width: 100%;
    margin-top: 40px;
    animation: fadeUp 0.6s 0.1s ease both;
}

.history-label {
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sand);
    margin-bottom: 14px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--mist);
    border: 1px solid var(--warm);
    border-radius: 12px;
    font-size: 0.85rem;
    gap: 12px;
}

.history-name {
    font-family: "Cormorant Garamond", serif;
    font-size: 1rem;
    color: var(--bark);
    flex: 1;
}

.history-time {
    font-size: 0.72rem;
    color: var(--sand);
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(247, 242, 235, 0.4);
    border-top-color: var(--cream);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

/* ── Animations ── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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