:root {
    --ink: #10201c;
    --muted: #66746f;
    --line: #dfe8e4;
    --surface: #ffffff;
    --soft: #f3f8f6;
    --brand: #116854;
    --brand-dark: #084b3d;
    --brand-light: #dff3ec;
    --accent: #d8a54a;
    --danger: #a23939;
    --shadow: 0 24px 70px rgba(12, 61, 49, 0.14);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background: #f5f8f7;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.app-root,
.login-view,
.chat-view {
    min-height: 100vh;
}

.centered-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.loading-orbit,
.is-thinking .message-bubble {
    display: flex;
    gap: 6px;
    align-items: center;
}

.loading-orbit span,
.is-thinking .message-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--brand);
    animation: pulse 1.1s infinite ease-in-out;
}

.loading-orbit span:nth-child(2),
.is-thinking .message-bubble span:nth-child(2) { animation-delay: 0.14s; }
.loading-orbit span:nth-child(3),
.is-thinking .message-bubble span:nth-child(3) { animation-delay: 0.28s; }

@keyframes pulse {
    0%, 70%, 100% { transform: translateY(0); opacity: .35; }
    35% { transform: translateY(-5px); opacity: 1; }
}

.login-view {
    display: grid;
    grid-template-columns: minmax(480px, 1.1fr) minmax(420px, .9fr);
    background: var(--surface);
}

.login-visual {
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    padding: 64px clamp(48px, 7vw, 110px);
    color: white;
    background:
        radial-gradient(circle at 70% 18%, rgba(126, 210, 179, .26), transparent 34%),
        linear-gradient(145deg, #063d32 0%, #0d5c4b 58%, #0e725b 100%);
    display: flex;
    align-items: center;
}

.login-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom right, black, transparent 72%);
}

.aura-glow {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.16);
}

.aura-glow-one {
    width: 440px;
    height: 440px;
    right: -170px;
    top: -110px;
    box-shadow: 0 0 100px rgba(124, 221, 184, .12) inset;
}

.aura-glow-two {
    width: 620px;
    height: 620px;
    left: -360px;
    bottom: -390px;
}

.visual-copy {
    position: relative;
    z-index: 1;
    max-width: 640px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 13px;
    font-weight: 650;
    letter-spacing: .01em;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: white;
    font-family: Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(145deg, #36a986, #0b6651);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.26), 0 8px 20px rgba(4,39,31,.2);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.eyebrow.light {
    margin-top: clamp(100px, 16vh, 170px);
    color: #9fe1cb;
}

.visual-copy h1 {
    margin: 0;
    font-family: Georgia, "Songti SC", serif;
    font-size: clamp(48px, 5vw, 78px);
    line-height: 1.13;
    letter-spacing: -.035em;
}

.visual-copy > p:not(.eyebrow) {
    max-width: 520px;
    margin: 26px 0 0;
    color: rgba(255,255,255,.73);
    font-size: 18px;
    line-height: 1.8;
}

.privacy-note {
    margin-top: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,.8);
    font-size: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: #52d8a8;
    box-shadow: 0 0 0 5px rgba(82,216,168,.12);
}

.login-panel {
    padding: 48px;
    display: grid;
    place-items: center;
}

.login-form {
    width: min(100%, 420px);
}

.mobile-brand {
    display: none;
}

.login-form h2 {
    margin: 0;
    font-family: Georgia, "Songti SC", serif;
    font-size: 42px;
    letter-spacing: -.03em;
}

.form-intro,
.setup-intro {
    margin: 12px 0 32px;
    color: var(--muted);
    line-height: 1.7;
}

.login-form label,
.setup-form label {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    color: #34433e;
    font-size: 14px;
    font-weight: 650;
}

.login-form input,
.setup-form input {
    width: 100%;
    height: 52px;
    padding: 0 15px;
    border: 1px solid #cedbd6;
    border-radius: 12px;
    color: var(--ink);
    outline: none;
    background: #fbfdfc;
    transition: border .2s, box-shadow .2s;
}

.login-form input:focus,
.setup-form input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(17,104,84,.1);
}

.primary-button {
    width: 100%;
    min-height: 52px;
    border: 0;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 12px 28px rgba(10,82,65,.2);
}

.primary-button:disabled {
    cursor: wait;
    opacity: .64;
}

.form-error,
.chat-error,
.setup-message.is-error {
    color: var(--danger);
    background: #fff0f0;
    border: 1px solid #f0caca;
}

.form-error {
    margin: 0 0 16px;
    padding: 11px 13px;
    border-radius: 10px;
    font-size: 14px;
}

.small-print {
    margin: 18px 0 0;
    text-align: center;
    color: #8a9692;
    font-size: 12px;
}

.chat-view {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    min-height: 0;
    padding: 28px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    background: #0a4438;
    color: white;
}

.sidebar-brand .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 21px;
}

.sidebar-brand > div:last-child {
    display: grid;
    gap: 2px;
}

.sidebar-brand span {
    color: rgba(255,255,255,.48);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.new-chat-button {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 11px;
    color: white;
    text-align: left;
    background: rgba(255,255,255,.07);
}

.new-chat-button:hover {
    background: rgba(255,255,255,.12);
}

.profile-card,
.usage-card,
.runtime-card {
    padding: 17px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 14px;
    background: rgba(0,0,0,.09);
}

.sidebar-label {
    margin: 0 0 14px;
    color: rgba(255,255,255,.45);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.profile-heading {
    display: flex;
    align-items: center;
    gap: 11px;
}

.profile-avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #093d32;
    font-family: Georgia, serif;
    font-size: 19px;
    font-weight: 750;
    background: #b7ead8;
}

.profile-heading > div:last-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.profile-heading span {
    overflow: hidden;
    color: rgba(255,255,255,.56);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-age-row {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    justify-content: space-between;
    color: rgba(255,255,255,.54);
    font-size: 12px;
}

.profile-age-row strong {
    color: white;
}

.usage-title-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.usage-title-row span {
    color: rgba(255,255,255,.7);
    font-size: 11px;
}

.usage-progress {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
}

.usage-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #5bd7ad, #d8b55f);
    transition: width .3s ease;
}

.usage-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.usage-grid div {
    display: grid;
    gap: 4px;
}

.usage-grid span {
    color: rgba(255,255,255,.4);
    font-size: 10px;
}

.usage-grid strong {
    font-size: 13px;
}

.runtime-model-row {
    display: grid;
    gap: 4px;
}

.runtime-model-row span,
.runtime-grid span {
    color: rgba(255,255,255,.4);
    font-size: 10px;
}

.runtime-model-row strong {
    overflow-wrap: anywhere;
    font-size: 12px;
}

.runtime-grid {
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.runtime-grid div {
    display: grid;
    gap: 4px;
}

.runtime-grid strong {
    color: #b7ead8;
    font-size: 12px;
    text-transform: capitalize;
}

.logout-button {
    margin-top: auto;
    padding: 10px;
    border: 0;
    color: rgba(255,255,255,.55);
    background: transparent;
}

.logout-button:hover { color: white; }

.chat-main {
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: 66px minmax(0, 1fr) auto;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% -30%, rgba(55,159,126,.09), transparent 42%),
        #f8faf9;
}

.chat-header {
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(12px);
}

.chat-header > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-badge {
    padding: 6px 9px;
    border-radius: 999px;
    color: var(--brand);
    background: var(--brand-light);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.messages {
    min-height: 0;
    width: min(100%, 900px);
    margin: 0 auto;
    padding: 36px 28px 44px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.message {
    margin-bottom: 27px;
    display: flex;
    align-items: flex-start;
    gap: 13px;
}

.message-user {
    flex-direction: row-reverse;
}

.message-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    color: white;
    font-family: Georgia, serif;
    font-weight: 700;
    background: var(--brand);
}

.message-user .message-avatar {
    color: var(--brand-dark);
    background: #d9e8e3;
}

.message-content {
    max-width: min(74%, 680px);
    display: grid;
    gap: 7px;
}

.message-user .message-content {
    justify-items: end;
}

.message-content > strong {
    padding: 0 3px;
    color: #50605a;
    font-size: 12px;
}

.message-bubble {
    padding: 15px 17px;
    border: 1px solid #dfe7e4;
    border-radius: 4px 16px 16px 16px;
    color: #263630;
    background: white;
    box-shadow: 0 8px 24px rgba(30,70,57,.055);
    line-height: 1.72;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-user .message-bubble {
    border: 0;
    border-radius: 16px 4px 16px 16px;
    color: white;
    background: var(--brand);
}

.message-meta {
    padding: 0 3px;
    color: #8b9893;
    font-size: 10px;
}

.composer-wrap {
    position: relative;
    z-index: 1;
    padding: 12px 28px 18px;
    background: linear-gradient(to top, #f8faf9 72%, rgba(248,250,249,0));
}

.composer,
.chat-error,
.composer-note {
    width: min(100%, 900px);
    margin-left: auto;
    margin-right: auto;
}

.composer {
    padding: 9px 9px 9px 17px;
    border: 1px solid #cddbd6;
    border-radius: 17px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
    box-shadow: 0 12px 38px rgba(30,70,57,.1);
}

.composer:focus-within {
    border-color: #68a996;
    box-shadow: 0 0 0 4px rgba(17,104,84,.08), 0 12px 38px rgba(30,70,57,.1);
}

.composer textarea {
    width: 100%;
    min-height: 38px;
    max-height: 160px;
    padding: 8px 0 6px;
    resize: none;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    line-height: 1.5;
}

.composer textarea::placeholder { color: #98a49f; }

.composer button {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--brand);
}

.composer button:disabled { opacity: .45; cursor: wait; }
.composer svg { width: 20px; height: 20px; fill: currentColor; }

.composer-note {
    margin-top: 9px;
    margin-bottom: 0;
    color: #8b9893;
    text-align: center;
    font-size: 10px;
}

.chat-error {
    margin-top: 0;
    margin-bottom: 9px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 12px;
}

.setup-page {
    min-height: 100vh;
    padding: 44px 20px;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 0, #e4f4ef, #f5f8f7 48%);
}

.setup-card {
    width: min(100%, 560px);
    padding: 38px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: white;
    box-shadow: var(--shadow);
}

.setup-card .brand-mark { margin-bottom: 24px; }
.setup-card h1 { margin: 0; font-family: Georgia, serif; font-size: 34px; }
.setup-form { margin-top: 24px; }
.setup-message { margin: 18px 0; padding: 12px 14px; border-radius: 10px; line-height: 1.5; font-size: 13px; }
.setup-message.is-success { color: #145c47; border: 1px solid #b9dfd2; background: #eaf8f3; }

@media (max-width: 900px) {
    .login-view {
        grid-template-columns: 1fr;
    }
    .login-visual { display: none; }
    .login-panel { min-height: 100vh; padding: 28px; }
    .mobile-brand { margin-bottom: 60px; display: flex; align-items: center; gap: 12px; font-weight: 700; }

    .chat-view {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }
    .sidebar {
        padding: 12px 16px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    .sidebar-brand { margin-right: auto; }
    .sidebar-brand > div:last-child span,
    .new-chat-button,
    .profile-card,
    .usage-card,
    .runtime-card { display: none; }
    .logout-button { margin: 0; padding: 8px; font-size: 12px; }
    .chat-main { min-height: 0; grid-template-rows: 58px minmax(0, 1fr) auto; }
    .messages { padding: 25px 16px 34px; }
    .message-content { max-width: 83%; }
    .composer-wrap { padding: 10px 14px 14px; }
}

@media (max-width: 520px) {
    .login-panel { padding: 22px; align-items: start; }
    .login-form { padding-top: 20px; }
    .mobile-brand { margin-bottom: 70px; }
    .login-form h2 { font-size: 36px; }
    .chat-header { padding: 0 16px; }
    .message { gap: 9px; }
    .message-avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
    .message-content { max-width: 86%; }
    .message-bubble { padding: 13px 14px; font-size: 14px; }
    .header-badge { display: none; }
    .setup-card { padding: 28px 22px; }
}
