@font-face {
    font-family: 'AraletN';
    src: url('/assets/AraletN%20Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'FOT-Yuruka';
    src: url('/assets/FOT-Yuruka%20Std.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #090b12;
    --surface: rgba(20, 24, 38, 0.7);
    --text: #eef1f7;
    --muted: #9ca6b7;
    --blue: #7dd3fc;
    --orange: #fdba74;
    --border: rgba(255, 255, 255, 0.1);
}

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

html { min-height: 100%; }

body {
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    color: var(--text);
    font-family: 'FOT-Yuruka', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    isolation: isolate;
}

button, input { font: inherit; }

.gate-shell,
.session-check {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.gate-card {
    width: min(100%, 440px);
    padding: clamp(2rem, 8vw, 3.25rem);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: clamp(1.5rem, 4vw, 2.5rem);
    background: linear-gradient(145deg, rgba(24, 29, 46, 0.58), rgba(12, 15, 25, 0.36));
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px);
}

.eyebrow {
    margin: 0 0 0.4rem;
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1, h2 { font-family: 'AraletN', 'FOT-Yuruka', system-ui, sans-serif; }

h1 {
    margin: 0;
    font-size: clamp(2.4rem, 9vw, 3.6rem);
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text) 0%, var(--blue) 58%, var(--orange) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 18px rgba(125, 211, 252, 0.3));
}

.welcome-copy {
    margin: 0.65rem 0 2rem;
    color: var(--muted);
    line-height: 1.55;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: #cbd2de;
    font-size: 0.9rem;
}

.key-field { position: relative; }

input {
    width: 100%;
    min-height: 52px;
    padding: 0.8rem 4.2rem 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    outline: none;
    background: rgba(4, 6, 11, 0.55);
    color: var(--text);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
    border-color: rgba(125, 211, 252, 0.65);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.12);
}

.reveal-button {
    position: absolute;
    top: 50%;
    right: 0.55rem;
    transform: translateY(-50%);
    min-height: 36px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.primary-button,
.secondary-button {
    min-height: 48px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
}

.primary-button {
    width: 100%;
    margin-top: 1rem;
    border: 1px solid rgba(125, 211, 252, 0.35);
    background: rgba(125, 211, 252, 0.12);
    color: var(--blue);
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(125, 211, 252, 0.55);
    background: rgba(125, 211, 252, 0.2);
}

button:disabled { cursor: wait; opacity: 0.6; }

button:focus-visible {
    outline: 3px solid rgba(125, 211, 252, 0.65);
    outline-offset: 3px;
}

.form-status {
    min-height: 1.5em;
    margin: 0.85rem 0 0;
    color: var(--orange);
    font-size: 0.88rem;
    text-align: center;
}

.room-shell {
    position: relative;
    z-index: 1;
    width: min(100% - 2rem, 960px);
    margin: 0 auto;
    padding: clamp(1.5rem, 6vw, 4rem) 0;
}

.ambient {
    position: fixed;
    z-index: 0;
    width: min(68vw, 780px);
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.42;
    filter: blur(80px);
    transition: background 400ms ease, opacity 400ms ease, filter 400ms ease;
}

.ambient-blue {
    top: -34vw;
    left: 10vw;
    background: rgba(125, 211, 252, 0.34);
}

.ambient-orange {
    right: 3vw;
    bottom: -38vw;
    background: rgba(253, 186, 116, 0.25);
}

body.is-thinking .ambient {
    opacity: 0.62;
    filter: blur(72px);
    animation: ambientDance 1.35s ease-in-out infinite alternate;
}

body.is-thinking .ambient-orange { animation-delay: -0.67s; }

body.has-error .ambient {
    opacity: 0.66;
    background: rgba(248, 113, 113, 0.42);
    filter: blur(70px);
    animation: errorFlash 1.2s ease-out both;
}

body.has-success .ambient {
    opacity: 0.68;
    filter: blur(65px);
    animation: successBloom 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ambientDance {
    from { transform: translate3d(-2.5vw, 1.5vw, 0) scale(0.96); }
    to { transform: translate3d(3vw, -2vw, 0) scale(1.07); }
}

@keyframes errorFlash {
    0% { transform: scale(0.94); }
    35% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes successBloom {
    0% { transform: scale(0.92); }
    48% { transform: scale(1.13); }
    100% { transform: scale(1); }
}

.room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.room-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.model-controls {
    display: flex;
    gap: 0.5rem;
}

.model-controls label {
    display: grid;
    gap: 0.2rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.model-controls select {
    min-height: 38px;
    max-width: 120px;
    padding: 0.35rem 1.85rem 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    outline: none;
    background: rgba(20, 24, 38, 0.72);
    color: var(--text);
    font-family: inherit;
    font-size: 0.82rem;
    letter-spacing: normal;
    text-transform: none;
}

.model-controls select:focus {
    border-color: rgba(125, 211, 252, 0.65);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.12);
}

.secondary-button {
    padding: 0.65rem 1.1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.chat-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    background: var(--surface);
    backdrop-filter: blur(18px);
}

.message-list {
    min-height: 360px;
    max-height: min(60vh, 620px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: clamp(1.25rem, 4vw, 2rem);
}

.message {
    max-width: min(82%, 620px);
    padding: 0.8rem 1rem;
    border-radius: 1.1rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.assistant-message {
    align-self: flex-start;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.18);
}

.user-message {
    align-self: flex-end;
    background: rgba(125, 211, 252, 0.13);
    border: 1px solid rgba(125, 211, 252, 0.25);
}

.error-message { color: var(--orange); }

.composer {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.13);
}

textarea {
    width: 100%;
    min-height: 48px;
    max-height: 150px;
    resize: none;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    outline: none;
    background: rgba(4, 6, 11, 0.55);
    color: var(--text);
    line-height: 1.4;
}

textarea:focus {
    border-color: rgba(125, 211, 252, 0.65);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.12);
}

.send-button {
    width: auto;
    min-width: 76px;
    margin: 0;
    padding: 0.7rem 1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    margin-top: 0.55rem;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 16px rgba(125, 211, 252, 0.65);
}

.session-check { color: var(--muted); }
[hidden] { display: none !important; }

@media (max-width: 520px) {
    .gate-card { border-radius: 1.5rem; }
    .room-header { align-items: flex-start; }
    .room-actions { align-items: flex-end; flex-direction: column-reverse; }
    .secondary-button { min-width: max-content; }
    .model-controls { width: 100%; }
    .model-controls label { flex: 1; }
    .model-controls select { width: 100%; max-width: none; }
    .composer { align-items: stretch; flex-direction: column; }
    .send-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; }
    body.is-thinking .ambient,
    body.has-error .ambient,
    body.has-success .ambient { animation: none; }
}
