:root {
    --bg: #050810;
    --surface: rgba(12, 17, 32, 0.9);
    --surface-2: rgba(17, 24, 39, 0.9);
    --surface-input: rgba(255, 255, 255, 0.03);
    --border: rgba(99, 179, 255, 0.14);
    --border-soft: rgba(99, 179, 255, 0.07);
    --text: #e2e8f0;
    --muted: #8ea2bb;
    --blue: #3b82f6;
    --blue-light: #60a5fa;
    --cyan: #22d3ee;
    --purple: #a855f7;
    --success: #34d399;
    --danger: #fda4af;
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", sans-serif;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
}

.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    animation: orbFloat 12s ease-in-out infinite;
}

.orb-1 {
    width: 560px;
    height: 560px;
    top: -220px;
    left: -180px;
    background: radial-gradient(circle, #3b82f6, transparent);
}

.orb-2 {
    width: 460px;
    height: 460px;
    top: 44%;
    right: -130px;
    background: radial-gradient(circle, #a855f7, transparent);
    animation-delay: -4s;
}

.orb-3 {
    width: 360px;
    height: 360px;
    bottom: -110px;
    left: 35%;
    background: radial-gradient(circle, #22d3ee, transparent);
    animation-delay: -8s;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black, transparent);
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.hero {
    padding: 36px 0 36px;
}

.eyebrow {
    margin: 0 0 12px;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--blue-light);
}

.hero h1 {
    max-width: 11ch;
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 0.98;
}

.hero-line-1,
.hero-line-2 {
    display: block;
}

.hero-line-2 {
    background: linear-gradient(135deg, var(--blue-light), var(--cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-copy {
    max-width: 620px;
    margin: 18px 0 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--muted);
}

.auth-bar {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    max-width: 620px;
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 12px;
}

.auth-state {
    font-size: 0.82rem;
    color: #bfd0e6;
    font-weight: 600;
}

.auth-actions {
    display: flex;
    gap: 8px;
}

.auth-button {
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(59, 130, 246, 0.16);
    color: #dbeafe;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.auth-button.ghost {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: #c7d8ec;
}

.auth-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.workspace {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 22px;
}

.panel {
    padding: 26px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--surface), var(--surface-2));
    backdrop-filter: blur(18px);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
}

.panel-header h2 {
    margin: 0 0 8px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 2rem;
    letter-spacing: -0.02em;
}

.panel-header p {
    margin: 0 0 22px;
    color: var(--muted);
    line-height: 1.55;
}

.recipe-form {
    display: grid;
    gap: 16px;
}

.recipe-form label {
    display: grid;
    gap: 8px;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
    color: #bfd0e6;
}

.recipe-form input,
.recipe-form textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-input);
    font: inherit;
    color: var(--text);
}

.recipe-form input::placeholder,
.recipe-form textarea::placeholder {
    color: #6f85a3;
}

.recipe-form input:focus,
.recipe-form textarea:focus {
    outline: 2px solid rgba(59, 130, 246, 0.16);
    border-color: rgba(96, 165, 250, 0.45);
}

.primary-button {
    margin-top: 6px;
    padding: 15px 18px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
    color: white;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
    box-shadow: 0 14px 30px rgba(59, 130, 246, 0.33);
}

.story-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.story-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #dbeafe;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.story-link:hover {
    transform: translateY(-1px);
    border-color: rgba(96, 165, 250, 0.6);
    background: rgba(59, 130, 246, 0.28);
}

.story-link.ghost {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border);
    color: #c7d8ec;
}

.primary-button:hover {
    transform: translateY(-2px);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-soft);
    color: #b8c7da;
    font-size: 0.9rem;
    font-weight: 700;
}

.status-pill.loading {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.24);
    color: #bfdbfe;
}

.status-pill.success {
    background: rgba(52, 211, 153, 0.16);
    border-color: rgba(52, 211, 153, 0.28);
    color: var(--success);
}

.status-pill.error {
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(244, 63, 94, 0.24);
    color: var(--danger);
}

.recipe-output {
    min-height: 240px;
    padding: 22px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-soft);
    line-height: 1.7;
    white-space: pre-wrap;
}

.raw-response {
    margin: 10px 0 0;
    padding: 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #090d18;
    color: #c7d8ec;
    overflow-x: auto;
    font-size: 0.9rem;
}

.raw-response-wrap {
    margin-top: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.015);
    padding: 8px 10px 10px;
}

.raw-response-wrap summary {
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #9fb0c6;
}

.saved-actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.saved-recipes {
    margin-top: 16px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

.saved-recipes h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    font-family: "Space Grotesk", sans-serif;
}

.saved-recipes-list {
    display: grid;
    gap: 10px;
}

.saved-item {
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(6, 10, 20, 0.6);
}

.saved-item-header {
    margin: 0 0 6px;
    font-size: 0.85rem;
    color: #dbeafe;
    font-weight: 700;
}

.saved-item-meta {
    margin: 0;
    font-size: 0.75rem;
    color: #9fb0c6;
}

.saved-item-text {
    margin: 8px 0 0;
    white-space: pre-wrap;
    line-height: 1.5;
    color: #d6e2f1;
    font-size: 0.88rem;
}

.saved-empty {
    margin: 0;
    color: #9fb0c6;
    font-size: 0.86rem;
}

.pets-actions {
    margin-top: 18px;
}

.pets-panel {
    margin-top: 12px;
}

@media (max-width: 920px) {
    body {
        padding-top: max(env(safe-area-inset-top), 12px);
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        max-width: none;
        font-size: clamp(2.2rem, 10vw, 3.5rem);
        line-height: 1.02;
    }

    .page-shell {
        width: min(1180px, calc(100% - 16px));
        padding-top: 14px;
    }

    .hero {
        padding: 18px 0 24px;
    }

    .hero-copy {
        margin-top: 12px;
        font-size: 0.95rem;
        line-height: 1.55;
    }

    .auth-bar {
        flex-direction: column;
        align-items: stretch;
        margin-top: 14px;
        padding: 10px;
    }

    .auth-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .hero,
    .panel {
        animation: rise-in 500ms ease both;
    }

    .panel:nth-child(2) {
        animation-delay: 90ms;
    }
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes orbFloat {
    0%,
    100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-40px) scale(1.05);
    }
}