:root {
    color-scheme: light;
    --bg: #eef3f7;
    --panel: #ffffff;
    --panel-soft: #f7fafc;
    --text: #17212b;
    --muted: #667085;
    --line: #dbe4ed;
    --primary: #12b76a;
    --primary-dark: #07824f;
    --primary-soft: #e9fbf2;
    --blue: #2563eb;
    --blue-soft: #eef5ff;
    --danger: #d92d20;
    --danger-soft: #fff1f0;
    --success: #07875d;
    --success-soft: #ecfdf5;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --shadow: 0 24px 70px rgba(16, 24, 40, 0.12);
    --shadow-soft: 0 10px 28px rgba(16, 24, 40, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(18, 183, 106, 0.16), transparent 34vw),
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.10), transparent 32vw),
        linear-gradient(180deg, #f8fbfc 0, var(--bg) 420px);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--primary-dark);
}

.page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    width: 100%;
    border-bottom: 1px solid rgba(219, 228, 237, 0.76);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    width: 100%;
    margin: 0 auto;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.brand {
    position: relative;
    min-width: 0;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding-left: 56px;
}

.brand::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 44px;
    height: 44px;
    border-radius: 15px;
    background: url("logo.svg") center / 44px 44px no-repeat;
    box-shadow: 0 12px 26px rgba(18, 183, 106, 0.24);
    transform: translateY(-50%);
}

.brand strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    line-height: 1.2;
}

.brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 13px;
}

.account-area {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.account-area span {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 800;
}

.container {
    width: min(100%, 1060px);
    margin: 0 auto;
    padding: 34px 18px;
}

.login-box {
    width: min(100%, 920px);
    margin: 6vh auto 0;
}

.admin-panel,
.form-panel,
.message-card {
    background: var(--panel);
    border: 1px solid rgba(219, 228, 237, 0.92);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.admin-panel {
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 12px;
}

.auth-intro {
    position: relative;
    min-height: 530px;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    border-radius: 20px;
    background:
        radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.28), transparent 150px),
        linear-gradient(145deg, #0f9f67, #11c878);
    color: #ffffff;
}

.auth-intro::before {
    content: "";
    position: absolute;
    top: 34px;
    left: 34px;
    width: 74px;
    height: 74px;
    border-radius: 24px;
    background: url("logo.svg") center / 74px 74px no-repeat;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
}

.auth-intro::after {
    content: "";
    position: absolute;
    right: -72px;
    bottom: -72px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    border: 38px solid rgba(255, 255, 255, 0.13);
}

.auth-intro > span {
    position: relative;
    z-index: 1;
    width: fit-content;
    margin-bottom: 14px;
    padding: 7px 12px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.auth-intro h1 {
    position: relative;
    z-index: 1;
    margin: 0 0 12px;
    max-width: 420px;
    font-size: clamp(32px, 5vw, 50px);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.auth-intro p {
    position: relative;
    z-index: 1;
    margin: 0;
    max-width: 440px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 16px;
}

.auth-benefits {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

.auth-benefits span {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
}

.auth-card {
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.admin-header {
    margin-bottom: 20px;
}

.admin-header span {
    display: block;
    margin-bottom: 7px;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 900;
}

.admin-header h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.admin-header p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 18px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-soft);
}

.auth-tabs a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 800;
    text-decoration: none;
}

.auth-tabs a.active {
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: var(--shadow-soft);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 14px;
}

.field label {
    color: #344054;
    font-size: 14px;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    padding: 13px 14px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
    min-height: 108px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #98a2b3;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.14);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    padding: 0 17px;
    background: var(--primary);
    color: #ffffff;
    font: inherit;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.button:hover {
    background: var(--primary-dark);
    box-shadow: 0 12px 24px rgba(18, 183, 106, 0.20);
}

.button:active {
    transform: translateY(1px);
}

.button.secondary {
    background: var(--blue-soft);
    color: #1d4ed8;
    box-shadow: none;
}

.button.secondary:hover {
    background: #dbeafe;
}

.button.danger {
    background: var(--danger-soft);
    color: var(--danger);
    box-shadow: none;
}

.button.danger:hover {
    background: #ffe4e2;
}

.button.full {
    width: 100%;
}

.alert {
    margin-bottom: 14px;
    border-radius: 16px;
    padding: 12px 14px;
    line-height: 1.55;
}

.alert.success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid #b7efcf;
}

.alert.error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #ffd0cc;
}

.chat-shell {
    width: min(100%, 900px);
    margin: 0 auto;
    padding: 0 18px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 69px);
    min-height: calc(100dvh - 69px);
}

.chat-toolbar {
    position: sticky;
    top: 78px;
    z-index: 20;
    margin-top: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid rgba(184, 230, 210, 0.95);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.90);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

.sync-status {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sync-status > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.status-dot {
    position: relative;
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 6px rgba(18, 183, 106, 0.13);
}

.status-dot::after {
    content: "";
    position: absolute;
    inset: -7px;
    border-radius: 50%;
    border: 1px solid rgba(18, 183, 106, 0.32);
    animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.6);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.chat-toolbar strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
}

.chat-toolbar span {
    color: var(--muted);
    font-size: 13px;
}

.toolbar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-actions form {
    margin: 0;
}

.toolbar-actions .button {
    min-height: 40px;
    border-radius: 12px;
    padding: 0 14px;
    font-size: 14px;
}

.chat-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 0 20px;
}

.chat-list::before {
    content: "消息记录";
    align-self: center;
    margin-bottom: 2px;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    color: #7a8794;
    font-size: 12px;
    font-weight: 800;
}

.bubble-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.bubble-row.user {
    justify-content: flex-end;
}

.bubble {
    position: relative;
    width: fit-content;
    min-width: min(220px, 82%);
    max-width: min(74%, 620px);
    padding: 13px 14px 10px;
    border: 1px solid rgba(164, 226, 186, 0.95);
    border-radius: 18px 4px 18px 18px;
    background: linear-gradient(180deg, #e6fbea, #d6f5df);
    box-shadow: 0 10px 26px rgba(16, 24, 40, 0.08);
}

.bubble.user::after {
    content: "";
    position: absolute;
    top: 12px;
    right: -7px;
    width: 14px;
    height: 14px;
    background: #e2f9e7;
    border-top: 1px solid rgba(164, 226, 186, 0.95);
    border-right: 1px solid rgba(164, 226, 186, 0.95);
    transform: rotate(45deg);
}

.bubble p {
    margin: 0;
    color: #25313f;
    line-height: 1.68;
}

.message-bubble p {
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(145deg, #12b76a, #0e9f62);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(18, 183, 106, 0.22);
    font-size: 13px;
    font-weight: 900;
}

.message-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    color: #6b7a89;
    font-size: 12px;
}

.copy-message {
    min-height: 28px;
    border: 0;
    border-radius: 9px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--primary-dark);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 900;
}

.copy-message:hover {
    background: #ffffff;
}

.empty {
    width: min(100%, 520px);
    margin: 30px auto;
    border: 1px dashed #c9d6e2;
    border-radius: 22px;
    padding: 34px 24px;
    color: var(--muted);
    text-align: center;
    background: rgba(255, 255, 255, 0.72);
}

.empty::before {
    content: "暂无消息";
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 900;
}

.empty p {
    margin: 0;
}

.composer {
    position: sticky;
    bottom: 0;
    padding: 12px 0 16px;
    background: linear-gradient(180deg, rgba(238, 243, 247, 0), var(--bg) 28%);
}

.form-panel {
    padding: 12px;
    border-radius: 22px;
}

.send-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 86px;
    align-items: center;
    gap: 10px;
}

.send-form .field {
    margin-bottom: 0;
}

.send-form textarea {
    min-height: 62px;
    max-height: 180px;
}

.send-form .button {
    align-self: center;
    min-height: 62px;
    padding: 0 16px;
    border-radius: 14px;
}

.compose-hint {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.message-list,
.admin-layout {
    display: grid;
    gap: 16px;
}

.message-card {
    padding: 16px;
}

.message-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 14px;
}

.message-card h2 {
    margin: 0 0 10px;
    font-size: 18px;
}

.message-body {
    margin: 0 0 12px;
    white-space: pre-wrap;
    line-height: 1.7;
}

.message-actions {
    display: flex;
    justify-content: flex-end;
}

.footer-note {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    padding: 18px 0 28px;
}

@media (max-width: 820px) {
    .admin-panel {
        grid-template-columns: 1fr;
    }

    .auth-intro {
        min-height: 300px;
    }

    .chat-toolbar {
        top: 64px;
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .toolbar-actions .button {
        width: 100%;
        padding: 0 10px;
    }
}

@media (max-width: 560px) {
    body {
        font-size: 15px;
    }

    .topbar-inner {
        padding: 10px 12px;
        gap: 10px;
    }

    .brand {
        min-height: 40px;
        padding-left: 48px;
    }

    .brand::before {
        width: 40px;
        height: 40px;
        border-radius: 13px;
        background-size: 40px 40px;
    }

    .brand strong {
        font-size: 16px;
    }

    .brand span {
        max-width: 190px;
        font-size: 12px;
    }

    .account-area {
        gap: 7px;
    }

    .account-area span {
        max-width: 86px;
        font-size: 13px;
    }

    .account-area .button {
        min-height: 38px;
        border-radius: 12px;
        padding: 0 12px;
        font-size: 13px;
    }

    .container {
        padding: 18px 12px;
    }

    .login-box {
        margin-top: 10px;
    }

    .admin-panel {
        padding: 8px;
        border-radius: 22px;
    }

    .auth-intro {
        min-height: auto;
        padding: 24px;
        justify-content: flex-start;
        border-radius: 18px;
    }

    .auth-intro::before {
        display: none;
    }

    .auth-intro > span {
        margin-bottom: 12px;
    }

    .auth-intro h1 {
        max-width: 100%;
        font-size: 32px;
        line-height: 1.12;
        letter-spacing: -0.03em;
    }

    .auth-intro p {
        font-size: 15px;
    }

    .auth-benefits {
        margin-top: 18px;
        gap: 7px;
    }

    .auth-benefits span {
        padding: 7px 10px;
        font-size: 12px;
    }

    .auth-card {
        padding: 20px 12px 14px;
    }

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

    .chat-shell {
        padding: 0 12px;
        min-height: calc(100vh - 61px);
        min-height: calc(100dvh - 61px);
    }

    .chat-toolbar {
        margin-top: 12px;
        border-radius: 18px;
    }

    .toolbar-actions {
        gap: 7px;
    }

    .bubble {
        max-width: calc(100% - 46px);
        min-width: min(210px, calc(100% - 46px));
    }

    .send-form {
        grid-template-columns: minmax(0, 1fr) 78px;
        gap: 8px;
        align-items: center;
    }

    .send-form textarea {
        min-height: 62px;
    }

    .send-form .button {
        width: 100%;
        min-height: 62px;
        padding: 0 12px;
        border-radius: 13px;
    }

    .send-form .field {
        margin-bottom: 0;
    }
}

@media (max-width: 390px) {
    .brand span {
        display: none;
    }

}

@media (max-width: 340px) {
    .toolbar-actions {
        grid-template-columns: 1fr;
    }

    .send-form {
        grid-template-columns: minmax(0, 1fr) 72px;
    }

    .send-form .button {
        min-height: 60px;
    }
}
