:root {
    --gold: #d4af77;
    --gold-soft: #e8d5a8;
    --cream: #f4eee4;
    --mute: rgba(244, 238, 228, 0.62);
    --ink: #000;
    --kb: 0px;
    --app-h: 100svh;
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body,
.ana-page {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
}

.ana-page {
    position: fixed;
    inset: 0;
    height: var(--app-h, 100svh);
    background: var(--ink);
    color: var(--cream);
    font-family: "Outfit", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.ana-stage {
    position: absolute;
    inset: 0;
    background: #050403;
}

.ana-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 18%;
    opacity: 0;
    z-index: 2;
    background: transparent;
    transition: opacity 120ms ease;
    filter: saturate(0.62);
}

.ana-stage #ana-idle {
    opacity: 1;
    z-index: 1;
    transition: none;
}

.ana-stage video.is-active,
.ana-stage video.is-visible {
    opacity: 1;
    z-index: 2;
}

.ana-stage video.is-front {
    z-index: 3;
}

@media (prefers-reduced-motion: reduce) {
    .ana-stage video {
        transition: none;
    }
    .ana-messages {
        scroll-behavior: auto;
    }
}

.ana-veil {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.12) 42%, rgba(0, 0, 0, 0.55) 100%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 22%, transparent 58%, rgba(0, 0, 0, 0.72) 100%);
    box-shadow: inset 0 0 180px 40px rgba(0, 0, 0, 0.65);
}

.ana-grain {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    opacity: 0.07;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.7'/></svg>");
}

.ana-credits {
    position: absolute;
    z-index: 6;
    left: 56px;
    bottom: 56px;
    max-width: 440px;
    pointer-events: none;
}

.ana-kicker {
    font-size: 11px;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 14px;
}

.ana-credits h1 {
    font-family: "Cormorant Garamond", "Palatino Linotype", serif;
    font-weight: 500;
    font-size: clamp(4.2rem, 8vw, 7.4rem);
    line-height: 0.86;
    margin: 0;
    letter-spacing: -0.03em;
}

.ana-credits h1 em {
    font-style: italic;
    font-weight: 400;
    display: block;
    font-size: 0.46em;
    letter-spacing: 0.08em;
    color: var(--gold-soft);
    margin-top: 10px;
}

.ana-line {
    width: 72px;
    height: 1px;
    background: var(--gold);
    margin: 22px 0 16px;
}

.ana-tag {
    margin: 0;
    font-weight: 300;
    font-size: 15px;
    color: var(--mute);
    max-width: 34ch;
}

.ana-chat {
    position: absolute;
    z-index: 7;
    top: 28px;
    right: 28px;
    bottom: 28px;
    width: min(400px, 34vw);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(212, 175, 119, 0.22);
    background: rgba(8, 6, 4, 0.42);
    backdrop-filter: blur(28px) saturate(1.3);
    border-radius: 4px;
    overflow: hidden;
}

.ana-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(212, 175, 119, 0.14);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
}

#ana-status {
    flex: 1;
}

.ana-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7dffb3;
    box-shadow: 0 0 10px #7dffb3;
    flex-shrink: 0;
}

.ana-stage.is-speaking .ana-dot,
.ana-stage.is-live .ana-dot {
    animation: ana-pulse 1.4s ease-in-out infinite;
}

@keyframes ana-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.ana-voice-toggle {
    position: relative;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(212, 175, 119, 0.35);
    background: transparent;
    color: var(--cream);
    cursor: pointer;
    border-radius: 999px;
    flex-shrink: 0;
}

.ana-voice-toggle__ico {
    width: 18px;
    height: 18px;
    display: block;
}

.ana-voice-toggle::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 1.6px;
    background: currentColor;
    transform: rotate(-38deg);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.ana-voice-toggle.is-on {
    background: var(--gold);
    color: #1a140c;
    border-color: var(--gold);
}

.ana-voice-toggle.is-on::after {
    display: none;
}

.ana-thread {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ana-thread::before,
.ana-thread::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 28px;
    z-index: 2;
    pointer-events: none;
}

.ana-thread::before {
    top: 0;
    background: linear-gradient(180deg, rgba(8, 6, 4, 0.78) 0%, rgba(8, 6, 4, 0) 100%);
}

.ana-thread::after {
    bottom: 0;
    background: linear-gradient(0deg, rgba(8, 6, 4, 0.78) 0%, rgba(8, 6, 4, 0) 100%);
}

.ana-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 22px 14px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    overflow-anchor: none;
    scroll-behavior: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 119, 0.5) transparent;
}

.ana-messages::-webkit-scrollbar {
    width: 5px;
}

.ana-messages::-webkit-scrollbar-track {
    background: transparent;
    margin: 12px 0;
}

.ana-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(232, 213, 168, 0.7), rgba(212, 175, 119, 0.32));
    border-radius: 99px;
}

.ana-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 119, 0.85);
}

.ana-messages::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.ana-bubble {
    max-width: 92%;
    line-height: 1.35;
}

.ana-bubble--bot {
    font-family: "Cormorant Garamond", "Palatino Linotype", serif;
    font-size: 22px;
    font-weight: 400;
    color: #f7f1e6;
}

.ana-bubble__text {
    display: flex;
    flex-direction: column;
    gap: 0.55em;
}

.ana-bubble__p {
    margin: 0;
}

.ana-list {
    margin: 0.1em 0 0.15em;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.42em;
}

.ana-list li {
    position: relative;
    padding-left: 1em;
    font-size: 0.9em;
    line-height: 1.38;
    color: var(--gold-soft);
}

.ana-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.62em;
    width: 7px;
    height: 1px;
    background: var(--gold);
}

.ana-bubble--user {
    align-self: flex-end;
    color: var(--gold-soft);
    font-size: 13px;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(212, 175, 119, 0.35);
    padding-bottom: 6px;
}

.ana-reserve {
    display: inline-flex;
    align-items: center;
    margin-top: 12px;
    margin-right: 8px;
    padding: 10px 14px;
    border: 1px solid rgba(212, 175, 119, 0.55);
    background: rgba(212, 175, 119, 0.12);
    color: var(--gold-soft);
    font: 600 11px/1 "Outfit", sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 999px;
}

.ana-reserve:hover {
    background: var(--gold);
    color: #1a140c;
    border-color: var(--gold);
}

.ana-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid rgba(212, 175, 119, 0.14);
}

.ana-form input[type="text"] {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--cream);
    font: 400 16px/1.3 "Outfit", system-ui, sans-serif;
}

.ana-form input[type="text"]::placeholder {
    color: rgba(244, 238, 228, 0.38);
}

.ana-form button[type="submit"] {
    border: 0;
    background: var(--gold);
    color: #1a140c;
    font: 600 11px/1 "Outfit", sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 12px 14px;
    cursor: pointer;
}

.ana-mic {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 44px;
    padding: 0 14px 0 10px;
    border: 1px solid rgba(212, 175, 119, 0.38);
    background: rgba(212, 175, 119, 0.08);
    color: var(--gold-soft);
    font: 600 10px/1 "Outfit", sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-radius: 999px;
    cursor: pointer;
    overflow: hidden;
}

.ana-mic__pulse {
    display: none;
}

.ana-mic__icon {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(212, 175, 119, 0.16);
    color: var(--gold);
}

.ana-mic__icon svg {
    width: 14px;
    height: 14px;
}

.ana-mic__icon--stop,
.ana-mic__label--on {
    display: none;
}

.ana-mic:hover:not(:disabled) {
    background: rgba(212, 175, 119, 0.18);
    border-color: var(--gold);
}

.ana-mic.is-on {
    background: var(--gold);
    color: #1a140c;
    border-color: var(--gold);
}

.ana-mic.is-on .ana-mic__icon {
    background: #1a140c;
    color: var(--gold);
}

.ana-mic.is-on .ana-mic__icon--mic,
.ana-mic.is-on .ana-mic__label--idle {
    display: none;
}

.ana-mic.is-on .ana-mic__icon--stop,
.ana-mic.is-on .ana-mic__label--on {
    display: grid;
}

.ana-mic.is-on .ana-mic__label--on {
    display: inline;
}

.ana-mic.is-on .ana-mic__pulse {
    display: none;
}

.ana-mic__timer {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 5px;
    height: 4px;
    border-radius: 999px;
    background: rgba(26, 20, 12, 0.22);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}

.ana-mic.is-on .ana-mic__timer {
    opacity: 1;
}

.ana-mic__timer-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #1a140c;
    transform-origin: left center;
}

.ana-mic.is-on.is-timing .ana-mic__timer-fill {
    animation: ana-mic-timer 15s linear forwards;
}

@keyframes ana-mic-timer {
    from { width: 0; }
    to { width: 100%; }
}

.ana-mic:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.ana-hint {
    padding: 0 14px 12px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: rgba(154, 140, 120, 0.9);
}

@media (max-width: 860px) {
    .ana-credits {
        left: 22px;
        right: 22px;
        bottom: auto;
        top: max(20px, env(safe-area-inset-top, 0px));
        max-width: none;
    }

    .ana-credits h1 {
        font-size: 3.2rem;
    }

    .ana-chat {
        top: auto;
        right: 12px;
        left: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--kb, 0px));
        width: auto;
        height: min(42svh, 420px);
        max-height: calc(var(--app-h, 100svh) - var(--kb, 0px) - 7.5rem);
    }

    .ana-messages {
        padding: 14px 12px 14px 16px;
        gap: 12px;
    }

    .ana-bubble--bot {
        font-size: 16px;
        line-height: 1.32;
    }

    .ana-mic__label {
        display: none;
    }

    .ana-mic {
        width: 42px;
        height: 42px;
        padding: 0;
        justify-content: center;
    }

    .ana-mic.is-on .ana-mic__label--on {
        display: none;
    }

    .ana-mic__timer {
        left: 8px;
        right: 8px;
        bottom: 6px;
    }
}

@media (max-width: 860px) and (orientation: landscape) {
    .ana-credits {
        top: auto;
        bottom: max(16px, env(safe-area-inset-bottom, 0px));
        left: 20px;
        right: auto;
        max-width: 48%;
    }

    .ana-credits h1 {
        font-size: 2.2rem;
    }

    .ana-tag {
        display: none;
    }

    .ana-chat {
        top: 12px;
        right: 12px;
        left: auto;
        bottom: calc(12px + var(--kb, 0px));
        width: min(340px, 46vw);
        height: auto;
        max-height: none;
    }
}
