:root {
    color-scheme: light;
    --ink: #172522;
    --muted: #687570;
    --soft: #8b9792;
    --line: #d9e0dc;
    --paper: #f3f5f2;
    --surface: #ffffff;
    --surface-muted: #edf1ee;
    --green: #176b63;
    --green-deep: #123b38;
    --green-soft: #dcece7;
    --coral: #ef7359;
    --coral-soft: #fbe5df;
    --amber: #bd7a22;
    --shadow: 0 18px 45px rgba(24, 55, 50, 0.08);
    --radius: 18px;
    --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--ink);
    background: var(--paper);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

[hidden] {
    display: none !important;
}

.boot-screen {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 18px;
    color: var(--green-deep);
    background: var(--paper);
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0.04em;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: var(--green-deep);
    box-shadow: 0 8px 18px rgba(18, 59, 56, 0.18);
}

.brand-mark svg {
    width: 19px;
    height: 19px;
}

.brand-mark--large {
    width: 54px;
    height: 54px;
    border-radius: 17px;
}

.brand-mark--large svg {
    width: 27px;
    height: 27px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.brand-lockup strong {
    font-size: 17px;
    line-height: 1.1;
    letter-spacing: 0.04em;
}

.brand-lockup span {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
}

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 28px;
    background: #edf1ee;
}

.auth-visual {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.wave {
    position: absolute;
    border: 1px solid rgba(23, 107, 99, 0.17);
    border-radius: 50%;
}

.wave--one {
    top: -38vw;
    left: -18vw;
    width: 74vw;
    height: 74vw;
}

.wave--two {
    right: -22vw;
    bottom: -42vw;
    width: 82vw;
    height: 82vw;
    border-color: rgba(239, 115, 89, 0.18);
}

.wave--three {
    top: 18%;
    right: 13%;
    width: 180px;
    height: 180px;
    border-width: 18px;
    border-color: rgba(23, 107, 99, 0.06);
}

.auth-card {
    position: relative;
    width: min(100%, 420px);
    padding: 34px;
    border: 1px solid rgba(217, 224, 220, 0.95);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.auth-card .brand-lockup {
    margin-bottom: 54px;
}

.auth-copy {
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--coral);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.17em;
}

.auth-copy h1,
.panel-heading h1,
.persona-header h2 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(24px, 3vw, 32px);
    line-height: 1.18;
    letter-spacing: -0.02em;
}

.field {
    display: grid;
    gap: 9px;
    margin-bottom: 18px;
}

.field > span:first-child {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.field-control {
    display: flex;
    height: 52px;
    align-items: center;
    gap: 11px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #f8faf8;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field-control:focus-within {
    border-color: var(--green);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(23, 107, 99, 0.09);
}

.field-control svg {
    width: 18px;
    color: var(--soft);
}

.field-control input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
}

.field-control input::placeholder,
.composer textarea::placeholder {
    color: #9da7a3;
}

.primary-button,
.secondary-button,
.send-button,
.icon-button {
    border: 0;
    cursor: pointer;
    transition: transform 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.primary-button {
    display: flex;
    width: 100%;
    height: 52px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 13px;
    color: #fff;
    background: var(--green-deep);
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(18, 59, 56, 0.18);
}

.primary-button:hover {
    background: #0b2f2c;
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.send-button:disabled {
    cursor: wait;
    opacity: 0.62;
    transform: none;
}

.primary-button svg {
    width: 18px;
}

.form-error {
    min-height: 20px;
    margin: 12px 0 0;
    color: #b94835;
    font-size: 12px;
    text-align: center;
}

.app-shell {
    display: grid;
    height: 100dvh;
    grid-template-rows: 72px minmax(0, 1fr);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(243, 245, 242, 0.94);
    backdrop-filter: blur(14px);
}

.topbar-actions,
.model-status {
    display: flex;
    align-items: center;
}

.topbar-actions {
    gap: 12px;
}

.model-status {
    height: 34px;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface);
    font-size: 12px;
    font-weight: 650;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2fa77b;
    box-shadow: 0 0 0 4px rgba(47, 167, 123, 0.12);
}

.icon-button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
}

.icon-button:hover {
    color: var(--ink);
    background: var(--surface-muted);
}

.icon-button svg {
    width: 18px;
}

.workspace {
    display: grid;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
    gap: 16px;
    padding: 16px;
}

.chat-panel,
.persona-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 9px 30px rgba(24, 55, 50, 0.045);
}

.chat-panel {
    overflow: hidden;
}

.persona-panel {
    overflow: auto;
    padding: 22px;
}

.panel-heading,
.persona-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-heading {
    padding: 22px 24px 17px;
    border-bottom: 1px solid #edf0ee;
}

.panel-heading h1 {
    font-size: 23px;
}

.message-counter {
    display: flex;
    align-items: baseline;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.message-counter strong {
    color: var(--green);
    font-size: 22px;
    line-height: 1;
}

.chat-log {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.empty-chat {
    display: grid;
    min-height: 100%;
    place-content: center;
    justify-items: center;
    padding: 36px;
    text-align: center;
}

.empty-orbit {
    display: grid;
    width: 66px;
    height: 66px;
    margin-bottom: 20px;
    place-items: center;
    border: 1px solid #cddbd6;
    border-radius: 50%;
    color: var(--green);
    background: var(--green-soft);
}

.empty-orbit svg {
    width: 27px;
}

.empty-chat h2,
.persona-empty h3 {
    margin: 0 0 7px;
    font-size: 17px;
}

.empty-chat p,
.persona-empty p {
    max-width: 270px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.message {
    display: grid;
    max-width: min(82%, 760px);
    gap: 7px;
}

.message--user {
    align-self: flex-end;
}

.message--assistant {
    align-self: flex-start;
}

.message-label {
    color: var(--soft);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.12em;
}

.message--user .message-label {
    text-align: right;
}

.message-bubble {
    padding: 13px 16px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message--user .message-bubble {
    border-bottom-right-radius: 5px;
    color: #fff;
    background: var(--green-deep);
}

.message--assistant .message-bubble {
    border: 1px solid var(--line);
    border-bottom-left-radius: 5px;
    background: #f8faf8;
}

.message--pending .message-bubble {
    display: flex;
    width: 62px;
    height: 42px;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--soft);
    animation: typing 1.15s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.14s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.28s;
}

.composer {
    margin: 0 18px 18px;
    border: 1px solid #ccd6d1;
    border-radius: 16px;
    background: #fbfcfb;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(23, 107, 99, 0.07);
}

.composer textarea {
    display: block;
    width: 100%;
    max-height: 150px;
    min-height: 54px;
    resize: none;
    border: 0;
    outline: 0;
    padding: 16px 17px 8px;
    color: var(--ink);
    background: transparent;
    font-size: 14px;
    line-height: 1.55;
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 9px 9px 17px;
}

.composer-note {
    color: var(--soft);
    font-size: 11px;
}

.send-button {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: var(--coral);
    box-shadow: 0 7px 16px rgba(239, 115, 89, 0.22);
}

.send-button:hover {
    background: #df6248;
    transform: translateY(-1px);
}

.send-button svg {
    width: 18px;
}

.persona-panel {
    scrollbar-width: thin;
}

.persona-header {
    flex: 0 0 auto;
}

.persona-header h2 {
    font-size: 25px;
}

.progress-orb {
    position: relative;
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(var(--coral) var(--progress), #e5ebe8 0deg);
    box-shadow: inset 0 0 0 1px rgba(23, 107, 99, 0.04);
}

.progress-orb::before {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--surface);
    content: "";
}

.progress-orb span {
    position: relative;
    z-index: 1;
    font-size: 11px;
    font-weight: 750;
}

.persona-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 13px 0 24px;
    color: var(--soft);
    font-size: 11px;
}

.meta-divider {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #b8c2bd;
}

.persona-empty {
    display: grid;
    flex: 1;
    min-height: 280px;
    place-content: center;
    justify-items: center;
    text-align: center;
}

.persona-empty-icon {
    display: grid;
    width: 58px;
    height: 58px;
    margin-bottom: 18px;
    place-items: center;
    border-radius: 17px;
    color: var(--coral);
    background: var(--coral-soft);
}

.persona-empty-icon svg {
    width: 25px;
}

.persona-content {
    display: grid;
    gap: 23px;
    padding-bottom: 22px;
}

.persona-summary {
    padding: 17px;
    border-left: 3px solid var(--coral);
    border-radius: 0 12px 12px 0;
    background: #faf6f3;
}

.persona-summary h3,
.section-title h3 {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.persona-summary p {
    margin: 9px 0 0;
    color: #43514d;
    font-size: 13px;
    line-height: 1.75;
}

.persona-section {
    display: grid;
    gap: 12px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title span {
    display: grid;
    min-width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    color: var(--green);
    background: var(--green-soft);
    font-size: 10px;
    font-weight: 750;
}

.trait-list {
    display: grid;
    gap: 9px;
}

.trait-card {
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fcfdfc;
}

.trait-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.trait-card strong {
    font-size: 12px;
}

.confidence {
    color: var(--green);
    font-size: 10px;
    font-weight: 750;
}

.trait-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.token {
    padding: 7px 10px;
    border: 1px solid #d7e4df;
    border-radius: 999px;
    color: var(--green);
    background: #f2f8f5;
    font-size: 11px;
}

.rule-list {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rule-list li {
    position: relative;
    padding-left: 17px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.rule-list li::before {
    position: absolute;
    top: 0.62em;
    left: 1px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
    content: "";
}

.persona-section--avoid .rule-list li::before {
    background: var(--coral);
}

.secondary-button {
    display: flex;
    width: 100%;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--green-deep);
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
}

.secondary-button:hover {
    border-color: #bfcfca;
    background: var(--surface-muted);
}

.secondary-button svg {
    width: 16px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 80;
    max-width: min(380px, calc(100vw - 44px));
    padding: 12px 15px;
    border-radius: 11px;
    color: #fff;
    background: var(--green-deep);
    box-shadow: 0 12px 30px rgba(18, 59, 56, 0.2);
    font-size: 12px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-error {
    background: #a64432;
}

@keyframes typing {
    0%,
    70%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 960px) {
    body {
        overflow: auto;
    }

    .app-shell {
        height: auto;
        min-height: 100dvh;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .chat-panel {
        min-height: 72dvh;
    }

    .persona-panel {
        overflow: visible;
        min-height: 560px;
    }
}

@media (max-width: 620px) {
    .topbar {
        height: 64px;
        padding: 0 15px;
    }

    .brand-lockup span,
    .model-status span:last-child {
        display: none;
    }

    .workspace {
        gap: 10px;
        padding: 10px;
    }

    .chat-panel,
    .persona-panel {
        border-radius: 15px;
    }

    .panel-heading {
        padding: 18px 17px 14px;
    }

    .chat-log {
        padding: 18px 15px;
    }

    .message {
        max-width: 91%;
    }

    .composer {
        margin: 0 10px 10px;
    }

    .persona-panel {
        padding: 18px 16px;
    }

    .auth-screen {
        padding: 15px;
    }

    .auth-card {
        padding: 27px 22px;
        border-radius: 19px;
    }

    .auth-card .brand-lockup {
        margin-bottom: 38px;
    }

    .toast {
        right: 12px;
        bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
