:root {
    color-scheme: light dark;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #6b7280;
    --border: #d9dee5;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #b42318;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    /* Own chat messages: WeChat-style green bubble with black text. */
    --bubble-mine-bg: #95ec69;
    --bubble-mine-text: #111827;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111827;
        --surface: #1f2937;
        --text: #f3f4f6;
        --muted: #9ca3af;
        --border: #374151;
        --primary: #60a5fa;
        --primary-hover: #93c5fd;
        --danger: #fca5a5;
        --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
        /* Keep the same green/black bubble in dark mode: it stays legible. */
        --bubble-mine-bg: #95ec69;
        --bubble-mine-text: #111827;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    line-height: 1.6;
}

h1,
h2,
p {
    margin-top: 0;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.user-name {
    font-weight: 600;
}

.role-badge {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
}

/* Unread-message badge: editor console lists and the author article list. */
.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.nav-link {
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--primary);
}

.logout-button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.logout-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.container {
    width: min(920px, calc(100% - 32px));
    margin: 40px auto;
}

.welcome {
    color: var(--muted);
}

.placeholder {
    margin-top: 28px;
    padding: 28px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.placeholder p {
    margin-bottom: 0;
    color: var(--muted);
}

.page-login {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(380px, 100%);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin-bottom: 4px;
    font-size: 26px;
}

.subtitle {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 14px;
}

.login-card label {
    display: block;
    margin: 14px 0 6px;
    font-size: 14px;
    font-weight: 600;
}

.login-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.login-card input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
    border-color: var(--primary);
}

.login-card button[type="submit"] {
    width: 100%;
    margin-top: 20px;
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.login-card button[type="submit"]:hover:not(:disabled) {
    background: var(--primary-hover);
}

.login-card button[type="submit"]:disabled {
    opacity: 0.65;
    cursor: progress;
}

.form-error {
    margin: 14px 0 0;
    color: var(--danger);
    font-size: 14px;
}

.error-page {
    padding-top: 80px;
    text-align: center;
}

.error-code {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.button {
    display: inline-block;
    margin-top: 16px;
    padding: 8px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
