/* =========================================================================
   Bali AI — chat page
   Theme: "Emerald Hour"
   -------------------------------------------------------------------------
   Moonlit jungle. Rice-terrace horizon, waterfall trickle on the edge,
   ocean ripple at the hem, four big botanical leaves framing the view.
   Fraunces (display) + Instrument Sans (body) + IBM Plex Mono (meta).
   ========================================================================= */

:root {
    /* Core greens — jungle/rice terrace */
    --night:      #07140d;
    --jungle:     #0a1f16;
    --moss:       #0f2a20;
    --forest:     #1c3d2e;
    --jade:       #2d6a4f;
    --leaf:       #52b788;
    --fresh:      #95d5b2;
    --mist:       #d8f3dc;

    /* Warmth — light/flowers/sand */
    --ivory:      #faf3e0;
    --cream:      #f4e4bc;
    --sand:       #d4a373;
    --gold:       #d4a017;
    --ember:      #e09f3e;

    /* Accents — hibiscus, ocean */
    --hibiscus:   #c9453c;
    --coral:      #e76f51;
    --ocean:      #118ab2;
    --teal:       #2a9d8f;

    /* Greys */
    --shade:      rgba(149, 213, 178, 0.10);
    --rule:       rgba(149, 213, 178, 0.16);
    --whisper:    rgba(149, 213, 178, 0.55);

    /* Typography */
    --font-display: "Fraunces", "Iowan Old Style", "Palatino", Georgia, serif;
    --font-body:    "Instrument Sans", "Helvetica Neue", system-ui, sans-serif;
    --font-mono:    "IBM Plex Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;

    /* Geometry */
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 6px;
    --page-pad:  clamp(1.25rem, 3vw, 2.5rem);
    --column:    860px;
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

body {
    font-family: var(--font-body);
    background: var(--night);
    color: var(--mist);
    line-height: 1.55;
    overflow-x: hidden;
    min-height: 100dvh;
    position: relative;
    font-optical-sizing: auto;
}

/* Soft film grain — keeps the illustration cinematic */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
}

/* ======================================================================
   BACKDROP — sky, mist, rice terraces, waterfall, ocean ripple
   ====================================================================== */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.sky {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(80% 60% at 50% -10%, rgba(212, 160, 23, 0.12), transparent 60%),
        radial-gradient(70% 50% at 10% 15%, rgba(42, 157, 143, 0.13), transparent 60%),
        radial-gradient(60% 45% at 90% 20%, rgba(17, 138, 178, 0.12), transparent 60%),
        linear-gradient(180deg, #0a1f16 0%, #07140d 55%, #050d08 100%);
}

/* Low-lying mist layers drifting slowly */
.mist {
    position: absolute;
    left: -10%;
    width: 140%;
    height: 280px;
    filter: blur(30px);
    opacity: 0.45;
    background:
        radial-gradient(60% 80% at 20% 50%, rgba(149, 213, 178, 0.18), transparent 70%),
        radial-gradient(60% 80% at 70% 50%, rgba(17, 138, 178, 0.14), transparent 70%);
    animation: drift 60s linear infinite;
}
.mist-1 { bottom: 26%; }
.mist-2 { bottom: 12%; animation-duration: 90s; animation-direction: reverse; opacity: 0.3; }
@keyframes drift {
    from { transform: translateX(-8%); }
    to   { transform: translateX(8%); }
}

/* Rice-terrace SVG horizon */
.terraces {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 56vh;
    min-height: 420px;
    opacity: 0.9;
}

/* Waterfall — vertical shimmering lines on the right edge */
.waterfall {
    position: absolute;
    top: 10vh;
    right: 3vw;
    width: 34px;
    height: 60vh;
    opacity: 0.6;
    pointer-events: none;
    filter: blur(0.6px);
}
.waterfall span {
    position: absolute;
    top: 0; bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom,
        transparent 0%,
        rgba(216, 243, 220, 0) 8%,
        rgba(216, 243, 220, 0.45) 25%,
        rgba(149, 213, 178, 0.55) 55%,
        rgba(42, 157, 143, 0.25) 85%,
        transparent 100%);
    animation: fall 3.6s linear infinite;
}
.waterfall span:nth-child(1) { left: 0;   animation-delay: 0s; }
.waterfall span:nth-child(2) { left: 14px; animation-delay: -1.3s; opacity: 0.8; }
.waterfall span:nth-child(3) { left: 28px; animation-delay: -2.5s; opacity: 0.6; }
@keyframes fall {
    0%   { background-position: 0 -100%; opacity: 0; }
    20%  { opacity: 1; }
    80%  { opacity: 1; }
    100% { background-position: 0 100%; opacity: 0; }
}
@media (max-width: 860px) {
    .waterfall { display: none; }
}

/* Ocean ripple at very bottom */
.ripple {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 60px;
    animation: shimmer 8s ease-in-out infinite;
}
@keyframes shimmer {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-20px); }
}

/* Fireflies */
.fireflies {
    position: absolute;
    inset: 20% 0 10% 0;
    pointer-events: none;
}
.fireflies i {
    position: absolute;
    width: 3px; height: 3px;
    border-radius: 50%;
    background: #f4e4bc;
    box-shadow: 0 0 8px 2px rgba(244, 228, 188, 0.7);
    opacity: 0;
    animation: float 7s ease-in-out infinite;
}
.fireflies i:nth-child(1)  { left:  6%; top:  40%; animation-delay: 0s;    }
.fireflies i:nth-child(2)  { left: 14%; top:  12%; animation-delay: 1.2s;  }
.fireflies i:nth-child(3)  { left: 22%; top:  65%; animation-delay: 2.4s;  }
.fireflies i:nth-child(4)  { left: 35%; top:  20%; animation-delay: 3.6s;  }
.fireflies i:nth-child(5)  { left: 48%; top:  55%; animation-delay: 0.6s;  }
.fireflies i:nth-child(6)  { left: 58%; top:  18%; animation-delay: 4.2s;  }
.fireflies i:nth-child(7)  { left: 68%; top:  42%; animation-delay: 1.8s;  }
.fireflies i:nth-child(8)  { left: 76%; top:  10%; animation-delay: 5.4s;  }
.fireflies i:nth-child(9)  { left: 84%; top:  58%; animation-delay: 2.9s;  }
.fireflies i:nth-child(10) { left: 92%; top:  35%; animation-delay: 4.9s;  }
.fireflies i:nth-child(11) { left: 30%; top:  85%; animation-delay: 3.1s;  }
.fireflies i:nth-child(12) { left: 44%; top:  90%; animation-delay: 5.8s;  }
.fireflies i:nth-child(13) { left: 62%; top:  78%; animation-delay: 0.4s;  }
.fireflies i:nth-child(14) { left: 80%; top:  82%; animation-delay: 2.1s;  }
@keyframes float {
    0%, 100% { opacity: 0; transform: translateY(0); }
    30%, 70% { opacity: 0.9; }
    50%      { transform: translateY(-18px) translateX(8px); }
}
@media (prefers-reduced-motion: reduce) {
    .mist, .waterfall span, .ripple, .fireflies i { animation: none !important; }
}

/* ======================================================================
   BOTANICAL ORNAMENTS — four corner leaves
   ====================================================================== */
.leaf {
    position: fixed;
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.6));
    will-change: transform;
    transition: transform 400ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.leaf svg { width: 100%; height: auto; }

.leaf-monstera-tl {
    top: -60px;
    left: -80px;
    width: clamp(180px, 22vw, 340px);
    transform-origin: top left;
    animation: sway 12s ease-in-out infinite;
    opacity: 0.9;
}
.leaf-palm-tr {
    top: -40px;
    right: -60px;
    width: clamp(200px, 26vw, 420px);
    transform-origin: top right;
    animation: sway 14s ease-in-out infinite reverse;
    opacity: 0.85;
}
.leaf-banana-bl {
    bottom: -80px;
    left: -60px;
    width: clamp(200px, 24vw, 380px);
    transform-origin: bottom left;
    animation: sway 16s ease-in-out infinite;
    opacity: 0.8;
    transform: rotate(-6deg);
}
.leaf-fern-br {
    bottom: -50px;
    right: -40px;
    width: clamp(160px, 20vw, 300px);
    transform-origin: bottom right;
    animation: sway 18s ease-in-out infinite reverse;
    opacity: 0.75;
}

@keyframes sway {
    0%, 100% { rotate: 0deg; }
    50%      { rotate: 1.4deg; }
}

@media (prefers-reduced-motion: reduce) {
    .leaf { animation: none !important; }
}

@media (max-width: 860px) {
    .leaf-banana-bl, .leaf-fern-br { opacity: 0.5; }
    .leaf-palm-tr { opacity: 0.6; width: 40vw; }
    .leaf-monstera-tl { opacity: 0.6; width: 38vw; }
}

/* ======================================================================
   APP SHELL
   ====================================================================== */
.bali-app {
    position: relative;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    z-index: 2;
}

/* ======================================================================
   HEADER
   ====================================================================== */
.bali-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem var(--page-pad) 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(
        to bottom,
        rgba(7, 20, 13, 0.88) 0%,
        rgba(7, 20, 13, 0.55) 60%,
        rgba(7, 20, 13, 0) 100%
    );
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.55rem;
    letter-spacing: -0.01em;
    color: var(--mist);
    font-variation-settings: "opsz" 60;
}
.brand-mark {
    width: 1.9rem; height: 1.9rem;
    display: inline-grid;
    place-items: center;
    background: radial-gradient(circle at 30% 30%, #bdf0c7, #52b788 50%, #2d6a4f);
    border-radius: 50%;
    box-shadow:
        0 0 0 1px rgba(149, 213, 178, 0.3),
        0 6px 18px -4px rgba(82, 183, 136, 0.55),
        inset 0 -4px 8px rgba(7, 20, 13, 0.3);
}
.brand-mark svg { width: 66%; height: 66%; }
.brand-name em {
    font-style: italic;
    color: var(--fresh);
    font-weight: 500;
}

.header-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    color: var(--whisper);
    text-transform: uppercase;
}
.header-meta .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--leaf);
    box-shadow: 0 0 8px var(--leaf);
    animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

.header-right {
    justify-self: end;
    display: inline-flex;
    align-items: baseline;
    gap: 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    color: var(--whisper);
    text-transform: uppercase;
}
.header-right .clock {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    color: var(--cream);
    font-weight: 400;
    text-transform: none;
}

/* ======================================================================
   MAIN COLUMN
   ====================================================================== */
.bali-main {
    width: 100%;
    max-width: var(--column);
    margin: 0 auto;
    padding: 1rem var(--page-pad) 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* ---------- Intro ---------- */
.intro {
    padding: 1.25rem 0 0.5rem;
    text-align: left;
}
.intro-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2.4rem, 6vw, 4.2rem);
    line-height: 0.95;
    color: var(--ivory);
    margin: 0;
    letter-spacing: -0.02em;
    font-variation-settings: "opsz" 144;
}
.intro-title span {
    display: block;
    color: var(--fresh);
    font-weight: 300;
}
.intro-title em {
    display: block;
    font-style: italic;
    color: var(--ember);
    font-weight: 400;
}
.intro-sub {
    margin: 1rem 0 0;
    max-width: 52ch;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--whisper);
    line-height: 1.65;
}

/* ---------- Prompt chips ---------- */
.prompt-board {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
    padding: 0.4rem 0;
}
.prompt-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    color: var(--whisper);
    text-transform: uppercase;
}
.prompt-hint .tick {
    width: 22px; height: 1px;
    background: var(--jade);
}
.prompt-chips {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.prompt-chips button {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(28, 61, 46, 0.35);
    color: var(--mist);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 0.42rem 0.95rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    letter-spacing: 0.005em;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: border-color 220ms ease, color 220ms ease, background 220ms ease, transform 220ms ease;
}
.prompt-chips .chip-leaf {
    color: var(--leaf);
    font-size: 0.75rem;
    transform: translateY(-1px);
}
.prompt-chips button:hover {
    color: var(--ivory);
    border-color: var(--leaf);
    background: rgba(82, 183, 136, 0.18);
    transform: translateY(-1px);
}
.prompt-chips button:hover .chip-leaf { color: var(--ember); }

/* ======================================================================
   CHAT LOG
   ====================================================================== */
.chat-log {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 32vh;
    padding: 0.5rem 0;
}

.turn {
    display: grid;
    grid-template-columns: 2.2rem 1fr;
    gap: 0.9rem;
    align-items: flex-start;
    animation: enter 520ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes enter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.turn-avatar {
    width: 2.2rem; height: 2.2rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    margin-top: 0.25rem;
    background: linear-gradient(160deg, rgba(82, 183, 136, 0.18), rgba(28, 61, 46, 0.4));
    border: 1px solid var(--rule);
    color: var(--fresh);
    flex-shrink: 0;
}
.turn-avatar svg { width: 60%; height: 60%; }
.turn.you .turn-avatar {
    background: linear-gradient(160deg, rgba(231, 111, 81, 0.22), rgba(201, 69, 60, 0.35));
    border-color: rgba(231, 111, 81, 0.45);
    color: var(--coral);
}
.turn.system .turn-avatar {
    background: rgba(201, 69, 60, 0.2);
    border-color: var(--hibiscus);
    color: var(--hibiscus);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
}

.turn-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.turn-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--whisper);
}
.turn.you .turn-label    { color: var(--coral); }
.turn.ai  .turn-label    { color: var(--leaf); }
.turn.system .turn-label { color: var(--hibiscus); }

.turn-body {
    font-family: var(--font-display);
    font-size: 1.18rem;
    line-height: 1.55;
    color: var(--ivory);
    max-width: 62ch;
    font-variation-settings: "opsz" 48;
    font-weight: 400;
    letter-spacing: -0.005em;
}
.turn.you .turn-body {
    font-family: var(--font-body);
    font-size: 1.02rem;
    font-weight: 500;
    color: var(--mist);
    line-height: 1.6;
}
.turn.system .turn-body {
    font-family: var(--font-mono);
    font-size: 0.84rem;
    color: var(--hibiscus);
    letter-spacing: 0.03em;
}
.turn.ai em {
    color: var(--ember);
    font-style: italic;
}

/* Thinking indicator */
.thinking {
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
    padding-top: 0.3rem;
}
.thinking span {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--leaf);
    animation: blink 1.3s infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.22s; }
.thinking span:nth-child(3) { animation-delay: 0.44s; }
@keyframes blink {
    0%, 100% { opacity: 0.25; transform: translateY(0); }
    50%      { opacity: 1;    transform: translateY(-3px); }
}

/* ======================================================================
   PARTNER POSTCARDS
   ====================================================================== */
.cards {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card-postcard {
    position: relative;
    background:
        linear-gradient(180deg, rgba(250, 243, 224, 0.98) 0%, rgba(244, 228, 188, 0.96) 100%);
    color: #2a1a0f;
    border-radius: var(--radius-md);
    padding: 1.2rem 1.2rem 1rem;
    border: 1px solid rgba(212, 163, 115, 0.45);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.4) inset,
        0 14px 28px -14px rgba(0, 0, 0, 0.6),
        0 2px 6px -2px rgba(0, 0, 0, 0.3);
    transition: transform 320ms cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 320ms ease, border-color 320ms ease;
    transform: rotate(-0.4deg);
}
.card-postcard:nth-child(even) { transform: rotate(0.3deg); }
.card-postcard::before {
    /* inner deckle border */
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px dashed rgba(122, 78, 42, 0.25);
    border-radius: 8px;
    pointer-events: none;
}
.card-postcard::after {
    /* twine/hole for luggage-tag feel */
    content: "";
    position: absolute;
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    width: 12px; height: 12px;
    background: var(--night);
    border: 1px solid rgba(212, 163, 115, 0.45);
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.card-punch {
    /* small sticker in corner */
    position: absolute;
    top: 10px; right: 10px;
    width: 32px; height: 32px;
    background:
        radial-gradient(circle, var(--hibiscus) 0%, var(--hibiscus) 40%, transparent 41%);
    opacity: 0.12;
    pointer-events: none;
}
.card-postcard:hover {
    transform: translateY(-3px) rotate(0deg);
    border-color: var(--leaf);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.45) inset,
        0 22px 38px -18px rgba(0, 0, 0, 0.7),
        0 0 0 3px rgba(82, 183, 136, 0.15);
}

.card-name {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.25rem;
    line-height: 1.15;
    margin: 0 0 0.3rem;
    color: #1a1008;
    letter-spacing: -0.01em;
    font-variation-settings: "opsz" 60;
}
.card-title {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: #5e4226;
    margin: 0 0 0.7rem;
    font-style: italic;
}
.card-seal {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    margin: 0.2rem 0 0.6rem;
    border: 1px solid rgba(201, 69, 60, 0.4);
    border-radius: 999px;
    background: rgba(231, 111, 81, 0.08);
}
.card-seal .seal-cur {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--hibiscus);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.card-seal .seal-amt {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.05rem;
    color: #1a1008;
    letter-spacing: 0;
}
.card-seal .seal-lbl {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: #7a4e2a;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.card-meta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #5e4226;
    text-transform: uppercase;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.9rem;
    margin-top: 0.7rem;
    padding-top: 0.65rem;
    border-top: 1px dashed rgba(122, 78, 42, 0.3);
}
.card-meta .meta-pin::before {
    content: "◉ ";
    color: var(--hibiscus);
}
.card-meta a {
    color: var(--hibiscus);
    text-decoration: none;
    border-bottom: 1px dotted rgba(201, 69, 60, 0.5);
}
.card-meta a:hover {
    color: var(--coral);
    border-bottom-color: var(--coral);
}

/* ======================================================================
   COMPOSER
   ====================================================================== */
.composer {
    position: sticky;
    bottom: 0;
    padding: 1rem 0 1.4rem;
    background: linear-gradient(to top, rgba(7, 20, 13, 1) 40%, rgba(7, 20, 13, 0));
    z-index: 5;
}
.composer-bar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.65rem 0.65rem 1rem;
    background: linear-gradient(180deg, rgba(28, 61, 46, 0.6), rgba(15, 42, 32, 0.8));
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
        0 1px 0 rgba(149, 213, 178, 0.06) inset,
        0 18px 32px -18px rgba(0, 0, 0, 0.7);
    transition: border-color 200ms ease, box-shadow 200ms ease;
}
.composer-bar:focus-within {
    border-color: var(--leaf);
    box-shadow:
        0 1px 0 rgba(149, 213, 178, 0.08) inset,
        0 0 0 4px rgba(82, 183, 136, 0.15),
        0 18px 32px -18px rgba(0, 0, 0, 0.7);
}
.composer-icon {
    color: var(--leaf);
    width: 24px; height: 24px;
    display: inline-grid;
    place-items: center;
}
.composer-icon svg { width: 100%; height: 100%; }

#chat-input {
    background: transparent;
    color: var(--ivory);
    border: 0;
    outline: 0;
    font-family: var(--font-body);
    font-size: 1.02rem;
    padding: 0.55rem 0;
    width: 100%;
    letter-spacing: 0.005em;
}
#chat-input::placeholder {
    color: var(--whisper);
    font-style: italic;
    opacity: 0.7;
}

#chat-send {
    background: linear-gradient(180deg, #52b788, #2d6a4f);
    color: var(--night);
    border: 0;
    padding: 0.6rem 1.05rem;
    border-radius: 999px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 6px 14px -6px rgba(82, 183, 136, 0.5);
    transition: background 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}
#chat-send:hover:not(:disabled) {
    background: linear-gradient(180deg, #95d5b2, #52b788);
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 10px 18px -6px rgba(149, 213, 178, 0.6);
}
#chat-send:disabled {
    background: rgba(82, 183, 136, 0.15);
    color: var(--whisper);
    cursor: not-allowed;
    box-shadow: none;
}
#chat-send .arrow {
    width: 16px; height: 16px;
    display: inline-grid;
    place-items: center;
    transition: transform 200ms ease;
}
#chat-send:hover:not(:disabled) .arrow { transform: translateX(3px); }
#chat-send .arrow svg { width: 100%; height: 100%; }

.composer-meta {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    margin-top: 0.6rem;
    padding-left: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    color: var(--whisper);
    text-transform: uppercase;
}
.composer-meta kbd {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    background: rgba(28, 61, 46, 0.5);
    border: 1px solid var(--rule);
    border-bottom-width: 2px;
    color: var(--mist);
    padding: 0.05rem 0.45rem;
    border-radius: 4px;
}
.composer-meta .bullet { color: var(--jade); }

/* ======================================================================
   FOOTER
   ====================================================================== */
.bali-footer {
    padding: 1.5rem var(--page-pad) 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    color: var(--whisper);
    font-size: 0.95rem;
    position: relative;
    z-index: 2;
}
.bali-footer .bullet { color: var(--jade); font-style: normal; }

/* ======================================================================
   MOTION ON MOUNT
   ====================================================================== */
.bali-main > * {
    animation: rise 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.bali-main > *:nth-child(1) { animation-delay: 60ms;  }
.bali-main > *:nth-child(2) { animation-delay: 140ms; }
.bali-main > *:nth-child(3) { animation-delay: 220ms; }
.bali-main > *:nth-child(4) { animation-delay: 300ms; }
@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .bali-main > *, .turn { animation: none !important; }
}

/* ======================================================================
   SELECTION & SCROLLBAR
   ====================================================================== */
::selection { background: var(--leaf); color: var(--night); }

.chat-log, body {
    scrollbar-color: rgba(82, 183, 136, 0.35) transparent;
    scrollbar-width: thin;
}
.chat-log::-webkit-scrollbar, body::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb {
    background: rgba(82, 183, 136, 0.28);
    border-radius: 999px;
}

/* ======================================================================
   AUTH CHROME — user chip, sign-in links, flash
   ====================================================================== */
.auth-links {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
}
.auth-link {
    color: var(--mist);
    text-decoration: none;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}
.auth-link:hover { color: var(--fresh); border-color: var(--rule); }
.auth-link-cta {
    color: var(--night);
    background: linear-gradient(180deg, #95d5b2, #52b788);
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 6px 14px -6px rgba(82, 183, 136, 0.5);
}
.auth-link-cta:hover { color: var(--night); border-color: transparent; transform: translateY(-1px); }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.55rem 0.35rem 0.35rem;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: rgba(28, 61, 46, 0.45);
    font-family: var(--font-body);
    font-size: 0.88rem;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.user-chip-avatar {
    width: 1.75rem; height: 1.75rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(180deg, #95d5b2, #52b788);
    color: var(--night);
    font-weight: 700;
    font-family: var(--font-display);
    font-size: 0.95rem;
}
.user-chip-name { color: var(--mist); letter-spacing: 0.005em; }
.user-chip-logout { margin: 0; }
.user-chip-logout button {
    background: transparent;
    border: 0;
    color: var(--whisper);
    font-size: 1.05rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    transition: color 180ms ease, background 180ms ease;
}
.user-chip-logout button:hover { color: var(--hibiscus); background: rgba(201, 69, 60, 0.08); }

.flash-welcome {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    background: rgba(82, 183, 136, 0.14);
    border: 1px solid rgba(82, 183, 136, 0.32);
    color: var(--mist);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1rem;
}

.header-clock {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    color: var(--whisper);
}
.header-clock .clock {
    font-family: var(--font-display);
    color: var(--cream);
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    margin-right: 0.3rem;
}

/* ======================================================================
   QUOTA METER + EXHAUSTED BANNER
   ====================================================================== */
.quota-meter {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    align-self: flex-start;
    padding: 0.3rem 0.8rem 0.3rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: rgba(28, 61, 46, 0.35);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--whisper);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.quota-meter .quota-leaf { color: var(--leaf); font-size: 0.8rem; }
.quota-meter .quota-text { color: var(--mist); }
.quota-meter .quota-upgrade {
    color: var(--ember);
    text-decoration: none;
    border-bottom: 1px dotted rgba(224, 159, 62, 0.5);
    font-weight: 500;
}
.quota-meter .quota-upgrade:hover { color: var(--coral); border-bottom-color: var(--coral); }
.quota-meter-low { border-color: rgba(224, 159, 62, 0.45); }
.quota-meter-low .quota-leaf { color: var(--ember); }
.quota-meter-empty { border-color: rgba(201, 69, 60, 0.5); background: rgba(201, 69, 60, 0.08); }
.quota-meter-empty .quota-leaf { color: var(--hibiscus); }

.quota-banner {
    display: flex;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(180deg, rgba(250, 243, 224, 0.97), rgba(244, 228, 188, 0.95));
    color: #2a1a0f;
    border: 1px solid rgba(212, 163, 115, 0.45);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.4) inset,
        0 20px 38px -20px rgba(0, 0, 0, 0.6);
    position: relative;
    animation: enter 520ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.quota-banner-icon {
    width: 2.6rem; height: 2.6rem;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(201, 69, 60, 0.12);
    color: var(--hibiscus);
}
.quota-banner-icon svg { width: 55%; height: 55%; }
.quota-banner-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.15rem;
    color: #1a1008;
    margin: 0 0 0.4rem;
    letter-spacing: -0.01em;
    font-variation-settings: "opsz" 60;
}
.quota-banner-text {
    margin: 0 0 0.75rem;
    color: #5e4226;
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.55;
}
.quota-banner-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.quota-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(122, 78, 42, 0.35);
    color: #2a1a0f;
    background: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}
.quota-btn:hover {
    transform: translateY(-1px);
    background: #fff;
    border-color: rgba(122, 78, 42, 0.55);
}
.quota-btn-primary {
    background: linear-gradient(180deg, #52b788, #2d6a4f);
    color: var(--ivory);
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 6px 14px -6px rgba(45, 106, 79, 0.55);
}
.quota-btn-primary:hover { background: linear-gradient(180deg, #95d5b2, #52b788); color: var(--night); }

.composer.composer-locked {
    opacity: 0.45;
    pointer-events: none;
}

/* ======================================================================
   AUTH PAGES — login, signup
   ====================================================================== */
.auth-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem var(--page-pad);
    gap: 1.75rem;
    position: relative;
    z-index: 2;
}
.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 1.55rem;
    color: var(--mist);
    font-variation-settings: "opsz" 60;
}
.auth-brand em { font-style: italic; color: var(--fresh); font-weight: 500; }
.auth-brand-mark {
    width: 1.9rem; height: 1.9rem;
    display: inline-grid;
    place-items: center;
    background: radial-gradient(circle at 30% 30%, #bdf0c7, #52b788 50%, #2d6a4f);
    border-radius: 50%;
    box-shadow:
        0 0 0 1px rgba(149, 213, 178, 0.3),
        0 6px 18px -4px rgba(82, 183, 136, 0.55);
}
.auth-brand-mark svg { width: 66%; height: 66%; }

.auth-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, rgba(28, 61, 46, 0.7), rgba(15, 42, 32, 0.85));
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: 2rem 1.75rem 1.75rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 1px 0 rgba(149, 213, 178, 0.08) inset,
        0 24px 48px -24px rgba(0, 0, 0, 0.75);
}
.auth-card h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2rem;
    color: var(--ivory);
    margin: 0 0 0.4rem;
    letter-spacing: -0.01em;
    font-variation-settings: "opsz" 144;
}
.auth-lead {
    margin: 0 0 1.5rem;
    color: var(--whisper);
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.55;
}
.auth-field { margin-bottom: 0.9rem; }
.auth-field label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--whisper);
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}
.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    display: block;
    width: 100%;
    background: rgba(7, 20, 13, 0.5);
    color: var(--ivory);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.85rem;
    font-family: var(--font-body);
    font-size: 1rem;
    outline: 0;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}
.auth-field input:focus {
    border-color: var(--leaf);
    box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.14);
}
.auth-field.field-loginform-rememberme { display: inline-flex; align-items: center; gap: 0.5rem; }
.auth-field.field-loginform-rememberme label {
    margin: 0;
    letter-spacing: 0.04em;
    color: var(--mist);
    font-family: var(--font-body);
    font-size: 0.88rem;
    text-transform: none;
}
.auth-field .help-block,
.auth-field .invalid-feedback {
    display: block;
    color: var(--hibiscus);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    margin-top: 0.35rem;
}
.auth-actions { margin-top: 1.25rem; }
.auth-submit {
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg, #52b788, #2d6a4f);
    color: var(--night);
    border: 0;
    border-radius: 999px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 10px 22px -10px rgba(82, 183, 136, 0.55);
    transition: transform 180ms ease, background 180ms ease;
    cursor: pointer;
}
.auth-submit:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #95d5b2, #52b788);
}
.auth-alt {
    margin: 1.25rem 0 0;
    text-align: center;
    color: var(--whisper);
    font-family: var(--font-body);
    font-size: 0.9rem;
}
.auth-alt a {
    color: var(--fresh);
    text-decoration: none;
    border-bottom: 1px dotted rgba(149, 213, 178, 0.5);
}
.auth-alt a:hover { color: var(--ember); border-bottom-color: var(--ember); }

/* ======================================================================
   RESPONSIVE
   ====================================================================== */
@media (max-width: 720px) {
    :root { --page-pad: 1rem; }
    .bali-header { grid-template-columns: 1fr auto; gap: 0.75rem; }
    .header-meta { display: none; }
    .intro-title { font-size: 2.4rem; }
    .turn-body { font-size: 1.05rem; }
    .turn { grid-template-columns: 2rem 1fr; gap: 0.7rem; }
    .user-chip-name { display: none; }
    .auth-link { padding: 0.35rem 0.6rem; font-size: 0.82rem; }
    .auth-link-cta { padding: 0.45rem 0.85rem; }
    .quota-banner { flex-direction: column; }
}
