:root {
  --bg: #ffffff;
  --soft: #f7f7f5;
  --soft-2: #f0f0ed;
  --line: #e8e8e3;
  --text: #171714;
  --muted: #777770;
  --faint: #a5a59c;
  --accent: #dff3e5;
  --green: #2d8a50;
  --danger: #b74242;
  --radius: 14px;
  --shadow: 0 18px 55px rgba(24, 24, 18, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(45, 138, 80, .22); outline-offset: 2px; }
[hidden] { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 20px; font-weight: 750; letter-spacing: -.04em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--text); border-radius: 10px; font-family: Georgia, serif; font-size: 19px; font-weight: 500; }
.brand small { display: block; margin-top: 2px; color: var(--faint); font-size: 8px; font-weight: 650; letter-spacing: .18em; }
.eyebrow { margin: 0 0 12px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .19em; }
.muted { color: var(--muted); line-height: 1.7; }
.status-dot { display: inline-block; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #52aa71; box-shadow: 0 0 0 4px rgba(82, 170, 113, .1); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; background: var(--soft-2); font-size: 13px; font-weight: 750; text-transform: uppercase; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 650; transition: transform .16s, background .16s, border-color .16s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: var(--text); color: white; }
.button.primary:hover { background: #32322d; }
.button.subtle { border-color: var(--line); background: white; }
.button.subtle:hover { background: var(--soft); }
.button.small { min-height: 34px; padding: 7px 12px; font-size: 12px; }
.button.full { width: 100%; }
.text-button { padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 12px; text-align: left; }
.text-button:hover { color: var(--text); }
.danger-text { color: var(--danger); }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: white; cursor: pointer; font-size: 19px; line-height: 1; }

.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.auth-intro { display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; padding: 46px clamp(40px, 6vw, 96px); border-right: 1px solid var(--line); background: radial-gradient(circle at 12% 84%, #f0f6ef 0, transparent 35%), white; }
.intro-copy { max-width: 600px; padding: 70px 0; }
.intro-copy h1 { margin: 0 0 28px; font-size: clamp(36px, 4.2vw, 64px); font-weight: 580; letter-spacing: -.055em; line-height: 1.2; }
.intro-copy > p:last-child { max-width: 440px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.9; }
.auth-footnote { margin: 0; color: var(--faint); font-size: 11px; letter-spacing: .12em; }
.auth-panel { display: grid; place-items: center; padding: 40px; background: #fbfbfa; }
.auth-card { width: min(100%, 410px); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 42px; padding: 4px; border-radius: 11px; background: var(--soft-2); }
.segment { padding: 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.segment.active { background: white; color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.05); font-weight: 650; }
.auth-heading { margin-bottom: 28px; }
.auth-heading h1, .auth-heading h2 { margin: 0 0 9px; font-size: 28px; letter-spacing: -.04em; }
.auth-heading p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.form-stack { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; min-width: 0; color: var(--text); font-size: 12px; font-weight: 600; }
.field input, .field textarea, .field select, .filter-select { width: 100%; min-height: 45px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--text); font-size: 14px; font-weight: 400; transition: border .15s, box-shadow .15s; }
.field input::placeholder, .field textarea::placeholder { color: #b0b0a8; }
.field input:focus, .field textarea:focus, .field select:focus, .filter-select:focus { border-color: #a5a59c; outline: none; box-shadow: 0 0 0 3px rgba(23,23,20,.04); }
.field small { color: var(--faint); font-size: 10px; font-weight: 400; }
.field select[multiple] { min-height: 90px; }
.auth-help { margin: 22px 0 0; color: var(--faint); font-size: 12px; text-align: center; }
.admin-entry { display: block; margin-top: 34px; color: var(--muted); font-size: 12px; text-align: center; }
.admin-entry:hover { color: var(--text); }

.chat-shell { display: grid; height: 100vh; grid-template-columns: 272px minmax(0, 1fr); overflow: hidden; }
.chat-sidebar { display: flex; min-height: 0; flex-direction: column; padding: 27px 20px 20px; border-right: 1px solid var(--line); background: #fbfbfa; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 7px; }
.profile-row { display: flex; align-items: center; gap: 11px; margin: 30px 0 28px; padding: 15px 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.profile-copy { display: grid; min-width: 0; flex: 1; gap: 4px; }
.profile-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy span { color: var(--faint); font-size: 10px; }
.sidebar-section-title { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 10px; color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .08em; }
.room-list { min-height: 0; flex: 1; overflow-y: auto; }
.room-item { display: flex; width: 100%; align-items: center; gap: 10px; margin: 3px 0; padding: 11px 10px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; text-align: left; }
.room-item:hover { background: var(--soft-2); }
.room-item.active { background: #ededE8; }
.room-symbol { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--muted); font-size: 12px; }
.room-item-copy { display: grid; min-width: 0; flex: 1; gap: 3px; }
.room-item-copy strong { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.room-item-copy small { overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.unread-badge { min-width: 18px; padding: 2px 5px; border-radius: 20px; background: var(--text); color: white; font-size: 9px; text-align: center; }
.join-button { margin-top: 12px; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 20px 8px 0; }
.conversation { display: flex; min-width: 0; min-height: 0; flex-direction: column; background: white; }
.conversation-header { display: flex; min-height: 88px; align-items: center; gap: 16px; padding: 19px clamp(20px, 4vw, 50px); border-bottom: 1px solid var(--line); }
.conversation-heading { min-width: 0; flex: 1; }
.conversation-heading h1 { overflow: hidden; margin: 0 0 5px; font-size: 17px; font-weight: 680; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.conversation-heading p { overflow: hidden; margin: 0; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.presence { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 30px clamp(20px, 5vw, 72px); scroll-behavior: smooth; }
.empty-state { display: grid; height: 100%; min-height: 250px; place-content: center; justify-items: center; text-align: center; }
.empty-mark { display: grid; width: 58px; height: 58px; place-items: center; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--soft); font-family: Georgia, serif; font-size: 27px; }
.empty-state h2 { margin: 0 0 9px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--faint); font-size: 12px; }
.message-row { display: flex; gap: 11px; max-width: 850px; margin: 0 auto 22px; }
.message-row.own { flex-direction: row-reverse; }
.message-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 10px; font-weight: 700; }
.message-content { max-width: min(75%, 620px); }
.message-meta { display: flex; align-items: center; gap: 8px; margin: 0 0 6px 2px; color: var(--faint); font-size: 10px; }
.message-row.own .message-meta { justify-content: flex-end; margin-right: 2px; }
.message-meta strong { color: var(--muted); font-weight: 600; }
.admin-tag { padding: 1px 5px; border-radius: 4px; background: var(--accent); color: var(--green); font-size: 8px; }
.message-bubble { padding: 11px 14px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: var(--soft); font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-row.own .message-bubble { border-color: var(--text); border-radius: 14px 4px 14px 14px; background: var(--text); color: white; }
.day-divider { display: flex; max-width: 850px; align-items: center; gap: 14px; margin: 30px auto; color: var(--faint); font-size: 10px; }
.day-divider::before, .day-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.typing-indicator { min-height: 20px; padding: 0 clamp(20px, 5vw, 72px); color: var(--faint); font-size: 10px; }
.composer { display: flex; align-items: flex-end; gap: 12px; margin: 0 clamp(20px, 5vw, 72px) 24px; padding: 8px 8px 8px 16px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 8px 28px rgba(20,20,15,.045); }
.composer textarea { min-height: 36px; max-height: 130px; flex: 1; resize: none; padding: 8px 0; border: 0; outline: none; color: var(--text); font-size: 13px; line-height: 1.55; }
.send-button { display: flex; min-height: 37px; align-items: center; gap: 10px; padding: 8px 14px; border: 0; border-radius: 9px; background: var(--text); color: white; cursor: pointer; font-size: 12px; }
.send-button:disabled { opacity: .45; cursor: not-allowed; }

.toast { position: fixed; z-index: 100; top: 22px; left: 50%; max-width: min(90vw, 480px); padding: 11px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--text); color: white; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, -15px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8f3838; }
.dialog { width: min(92vw, 450px); padding: 0; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(20,20,16,.32); backdrop-filter: blur(3px); }
.dialog-body { display: grid; gap: 20px; padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.dialog-heading .eyebrow { margin-bottom: 7px; }
.dialog-body > .muted { margin: -6px 0 0; font-size: 12px; }
.mobile-only { display: none; }
.sidebar-overlay { display: none; }

/* 管理控制台 */
.admin-shell { display: grid; min-height: 100vh; grid-template-columns: 220px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 32px 22px 24px; border-right: 1px solid var(--line); background: #fbfbfa; }
.admin-nav { display: grid; gap: 5px; margin-top: 52px; }
.admin-nav button { display: flex; align-items: center; justify-content: space-between; padding: 12px 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; text-align: left; }
.admin-nav button span:last-child { color: var(--faint); font-family: Georgia, serif; font-size: 10px; }
.admin-nav button:hover { background: var(--soft-2); }
.admin-nav button.active { background: var(--text); color: white; }
.admin-nav button.active span:last-child { color: #aaa; }
.admin-sidebar-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding: 16px 4px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.admin-main { min-width: 0; padding: 0 clamp(24px, 4vw, 58px) 60px; }
.admin-header { display: flex; min-height: 145px; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.admin-header .eyebrow { margin-bottom: 7px; }
.admin-header h1 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.04em; }
.admin-header p:last-child { margin: 0; color: var(--faint); font-size: 11px; }
.admin-section { padding-top: 34px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { display: flex; min-height: 155px; flex-direction: column; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.stat-card > span { color: var(--muted); font-size: 11px; }
.stat-card strong { margin: 16px 0 8px; font-size: 37px; font-weight: 550; letter-spacing: -.05em; }
.stat-card small { margin-top: auto; color: var(--faint); font-size: 10px; }
.stat-card.accent { border-color: #d6e9da; background: #f4faf5; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 34px 0 18px; }
.section-heading h2 { margin: 0 0 7px; font-size: 16px; letter-spacing: -.02em; }
.section-heading p { margin: 0; color: var(--faint); font-size: 11px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.room-admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.room-admin-card { display: flex; min-height: 200px; flex-direction: column; padding: 20px; }
.room-admin-card.archived { opacity: .65; background: var(--soft); }
.room-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-card-top .room-symbol { width: 34px; height: 34px; }
.room-admin-card h3 { margin: 17px 0 7px; font-size: 15px; }
.room-admin-card > p { display: -webkit-box; overflow: hidden; min-height: 32px; margin: 0; color: var(--faint); font-size: 11px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.room-card-meta { display: flex; gap: 14px; margin: 16px 0; color: var(--muted); font-size: 10px; }
.room-card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.room-card-actions button { min-height: 29px; padding: 5px 9px; font-size: 10px; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px; background: var(--soft-2); color: var(--muted); font-size: 9px; white-space: nowrap; }
.badge.green { background: #e7f5ea; color: #347a4d; }
.badge.red { background: #faeaea; color: var(--danger); }
.badge.dark { background: var(--text); color: white; }
.empty-card { grid-column: 1 / -1; padding: 42px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--faint); font-size: 12px; text-align: center; }
.inline-create { display: flex; align-items: flex-end; gap: 13px; margin-bottom: 22px; padding: 18px; }
.inline-create .field { min-width: 180px; }
.inline-create .grow { flex: 1; }
.invite-create { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; margin-bottom: 18px; padding: 20px; }
.invite-create .button { align-self: end; }
.code-result { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding: 18px 20px; border: 1px solid #cde4d3; border-radius: 12px; background: #f3faf5; }
.code-result > div { display: grid; gap: 7px; }
.code-result span { color: var(--green); font-size: 10px; }
.code-result strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 20px; letter-spacing: .08em; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 13px 16px; border-bottom: 1px solid var(--line); background: #fbfbfa; color: var(--faint); font-size: 9px; font-weight: 650; letter-spacing: .06em; text-align: left; white-space: nowrap; }
td { max-width: 340px; padding: 15px 16px; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 12px; }
td small { color: var(--faint); font-size: 9px; }
td .message-cell { overflow: hidden; max-width: 330px; text-overflow: ellipsis; white-space: nowrap; }
.table-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-action { padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; white-space: nowrap; }
.table-action:hover { color: var(--text); text-decoration: underline; }
.table-action.danger { color: var(--danger); }
.code-preview { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 600; }
.filter-select { width: auto; min-width: 150px; min-height: 36px; padding: 7px 10px; font-size: 11px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { align-content: start; padding: 26px; }
.settings-card h2 { margin: 0 0 9px; font-size: 18px; }
.settings-card > p { margin: 0; font-size: 12px; }
.security-note { margin-top: 22px; padding: 14px; border-radius: 9px; background: var(--soft); color: var(--muted); font-size: 11px; line-height: 1.7; }
.checkbox-list { display: grid; max-height: 320px; gap: 8px; overflow-y: auto; }
.checkbox-item { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.checkbox-item input { accent-color: var(--text); }
.centered-auth { display: grid; min-height: 100vh; place-items: center; padding: 30px; background: #fbfbfa; }
.admin-login-card { padding: 34px; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 15px 50px rgba(20,20,15,.04); }
.admin-login-card .brand { margin-bottom: 48px; }

@media (max-width: 1100px) {
  .room-admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .invite-create { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-intro { min-height: auto; padding: 28px 25px 40px; border-right: 0; border-bottom: 1px solid var(--line); }
  .intro-copy { padding: 55px 0 25px; }
  .intro-copy h1 { font-size: 36px; }
  .auth-footnote { display: none; }
  .auth-panel { padding: 42px 25px 60px; }
  .chat-shell { grid-template-columns: 1fr; }
  .chat-sidebar { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  .chat-sidebar.open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; z-index: 15; inset: 0; background: rgba(0,0,0,.25); }
  .sidebar-overlay.show { display: block; }
  .mobile-only { display: grid; }
  .conversation-header { min-height: 76px; padding: 15px 17px; }
  .messages { padding: 24px 17px; }
  .message-content { max-width: 82%; }
  .composer { margin: 0 14px 15px; }
  .send-button span:first-child { display: none; }
  .typing-indicator { padding: 0 20px; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-nav { display: flex; gap: 5px; margin-top: 22px; overflow-x: auto; }
  .admin-nav button { flex: 0 0 auto; gap: 12px; }
  .admin-sidebar-bottom { margin-top: 15px; }
  .admin-main { padding: 0 17px 40px; }
  .admin-header { min-height: 130px; }
  .admin-header .button { padding: 8px 10px; font-size: 10px; }
  .room-admin-grid, .settings-grid { grid-template-columns: 1fr; }
  .inline-create { align-items: stretch; flex-direction: column; }
  .inline-create .field { min-width: 0; }
  .invite-create { grid-template-columns: 1fr; }
  .code-result { align-items: flex-start; flex-direction: column; }
  .section-heading { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
