:root {
    color-scheme: light;
    --ink: #1d2926;
    --muted: #66736f;
    --paper: #f5f1e8;
    --card: rgba(255, 253, 248, 0.94);
    --line: #d8d4ca;
    --accent: #e95d3c;
    --accent-dark: #c8472b;
    --green: #287a61;
    --shadow: 0 24px 70px rgba(48, 57, 52, 0.13);
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 20%, rgba(233, 93, 60, 0.13), transparent 28rem),
        radial-gradient(circle at 85% 75%, rgba(40, 122, 97, 0.12), transparent 30rem),
        var(--paper);
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    width: min(100% - 40px, 920px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px 0 20px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 28px;
}

.site-header,
.chat-header,
.site-footer,
.connection-row,
.brand,
.primary-button {
    display: flex;
    align-items: center;
}

.site-header,
.chat-header,
.site-footer {
    justify-content: space-between;
}

.brand {
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50% 50% 50% 10%;
    color: #fff;
    background: var(--accent);
    font-family: Georgia, serif;
    font-size: 22px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    letter-spacing: 0.12em;
}

.brand small,
.site-footer {
    color: var(--muted);
    font-size: 12px;
}

.text-button,
.leave-button {
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.text-button:hover,
.leave-button:hover {
    border-color: var(--ink);
}

.welcome-card,
.chat-card {
    align-self: center;
    width: 100%;
    overflow: hidden;
    border: 1px solid rgba(93, 101, 97, 0.16);
    border-radius: 28px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.welcome-card {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(34px, 7vw, 72px);
}

.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.welcome-card h1 {
    max-width: 620px;
    margin: 18px 0;
    font-family: Georgia, "Noto Serif SC", serif;
    font-size: clamp(34px, 6vw, 62px);
    font-weight: 500;
    line-height: 1.16;
    letter-spacing: -0.035em;
}

.welcome-card > p {
    max-width: 560px;
    margin: 0 0 34px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.8;
}

.name-field {
    display: block;
    max-width: 500px;
}

.name-field span {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
}

.name-field input {
    width: 100%;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: none;
    background: #fff;
}

.name-field input:focus,
.composer textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(40, 122, 97, 0.12);
}

.primary-button {
    width: min(100%, 500px);
    margin-top: 14px;
    padding: 16px 18px;
    justify-content: space-between;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: var(--ink);
    cursor: pointer;
}

.primary-button:hover {
    background: #30403b;
}

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

.privacy-note {
    margin-top: 20px;
    color: var(--muted);
    font-size: 12px;
}

.pulse-dot,
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--green);
}

.chat-card {
    height: min(720px, calc(100vh - 180px));
    min-height: 520px;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.chat-header {
    padding: 22px 26px;
    border-bottom: 1px solid var(--line);
}

.connection-row {
    color: var(--muted);
    font-size: 12px;
}

.status-dot {
    background: #d6a632;
}

.status-dot.is-online {
    background: var(--green);
}

.chat-header h1 {
    margin: 5px 0 0;
    font-family: Georgia, "Noto Serif SC", serif;
    font-size: 24px;
    font-weight: 500;
}

.messages {
    overflow-y: auto;
    padding: 30px 26px;
}

.message {
    max-width: min(76%, 520px);
    margin: 10px 0;
    padding: 12px 15px;
    border-radius: 16px 16px 16px 4px;
    background: #ece9e1;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message.is-own {
    margin-left: auto;
    border-radius: 16px 16px 4px 16px;
    color: #fff;
    background: var(--green);
}

.system-message {
    margin: 12px auto;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 18px 20px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.55);
}

.composer textarea {
    min-height: 48px;
    max-height: 120px;
    resize: none;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
    background: #fff;
}

.composer button {
    min-width: 78px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: var(--accent);
    cursor: pointer;
}

.composer button:hover:not(:disabled) {
    background: var(--accent-dark);
}

.composer button:disabled,
.composer textarea:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.site-footer {
    gap: 20px;
}

.is-hidden {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ui-dialog {
    max-width: calc(100vw - 32px);
}

.rules-content {
    max-width: 430px;
    color: var(--ink);
    line-height: 1.75;
}

.rules-content ol {
    margin: 0;
    padding-left: 22px;
}

@media (max-width: 620px) {
    .app-shell {
        width: min(100% - 24px, 920px);
        padding-top: 18px;
        gap: 18px;
    }

    .brand small,
    .site-footer span:last-child {
        display: none;
    }

    .welcome-card {
        padding: 32px 24px;
        border-radius: 20px;
    }

    .welcome-card h1 {
        font-size: 38px;
    }

    .chat-card {
        height: calc(100vh - 126px);
        min-height: 480px;
        border-radius: 20px;
    }

    .chat-header,
    .messages {
        padding-left: 18px;
        padding-right: 18px;
    }

    .message {
        max-width: 86%;
    }
}
