:root {
  color-scheme: light;
  --bg: #f2f6fb; --surface: #fff; --panel: #e9f2fc; --text: #10213a;
  --muted: #52647c; --line: #d8e2ef; --primary: #1265d4; --on-primary: #fff;
  --error: #b72f38; --success: #12734e;
  --shadow: 0 24px 70px rgb(55 78 112 / 16%);
  --rail: #f0f6fd; --active: #e0edff; --quiet: #eaf2fc;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f; --surface: #0d1b2f; --panel: #0a1a2d; --text: #eef6ff;
  --muted: #a5b5cc; --line: #263b55; --primary: #88baff; --on-primary: #07172d;
  --error: #ff9b9f; --success: #61d4a1;
  --shadow: 0 28px 90px rgb(0 0 0 / 30%);
  --rail: #0b1829; --active: #173558; --quiet: #142b46;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scrollbar-color: var(--muted) var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font: 16px/1.6 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
::selection { color: var(--on-primary); background: var(--primary); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-underline-offset: .24em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
button { min-height: 44px; padding: 10px 16px; border-radius: 11px; cursor: pointer; font-weight: 650; }
button:disabled { cursor: wait; opacity: .65; }
.primary { border: 0; color: var(--on-primary); background: var(--primary); }
.primary:hover:not(:disabled) { filter: brightness(.94); }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.secondary:hover:not(:disabled) { border-color: var(--primary); }
.muted, .field-hint { color: var(--muted); }
.small, .field-hint { font-size: 13px; }
h1, h2, p { overflow-wrap: anywhere; }
h1, h2 { margin: 0; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 24px; }
label { display: grid; gap: 8px; font-size: 14px; font-weight: 600; }
input { width: 100%; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--bg); caret-color: var(--primary); }
input:focus { border-color: var(--primary); }
input::placeholder { color: var(--muted); opacity: 1; }
.feedback { padding: 12px 14px; border: 1px solid currentColor; border-radius: 10px; color: var(--success); font-size: 14px; }
.feedback.error { color: var(--error); }
.login-page { background: radial-gradient(circle at 16% 18%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 34%), linear-gradient(145deg, var(--bg), var(--panel)); }
.theme-button { position: absolute; top: 22px; right: 24px; z-index: 1; }
.login-layout { width: min(1180px, calc(100% - 48px)); min-height: 100svh; margin: auto; padding: 90px 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); align-items: center; gap: 72px; }
.brand-panel { padding: 30px 24px; }
.brand-logo { display: block; margin-bottom: 30px; }
.brand-panel h1 { font-size: clamp(44px, 5vw, 72px); letter-spacing: -.025em; line-height: 1.16; }
.subtitle { margin: 24px 0 16px; color: var(--primary); font-size: 23px; }
.brand-note { max-width: 26em; margin: 0; color: var(--muted); font-size: 17px; }
.login-panel { display: flex; justify-content: center; }
.login-card { width: min(100%, 430px); padding: 42px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.login-card > .muted { margin: 10px 0 30px; font-size: 14px; }
.login-card form { display: grid; gap: 20px; }
.login-card .feedback { margin: 0; }
.login-footnote { margin: 26px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.app-shell { width: min(1080px, calc(100% - 48px)); margin: auto; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; min-height: 100px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.brand-link { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 750; text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.header-actions, #currentUser { min-width: 0; max-width: 100%; }
#currentUser { overflow-wrap: anywhere; }
.page-heading { margin: 48px 0 32px; }
.page-heading h1 { font-size: clamp(28px, 4vw, 38px); }
.page-heading p { max-width: 70ch; margin: 12px 0 0; }
.page-heading .breadcrumb { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.api-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.api-links a { display: grid; gap: 8px; padding: 22px 16px; text-decoration: none; }
.api-links a:hover { background: var(--panel); }
.api-links span { font-size: 14px; color: var(--muted); }
.content-section { margin: 36px 0; padding-top: 28px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.status-line { font-variant-numeric: tabular-nums; }
.channel-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin-top: 18px; }
.channel-link { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none; overflow-wrap: anywhere; }
.channel-link span { color: var(--muted); font-size: 13px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.create-user-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: start; gap: 20px; margin-top: 24px; }
.create-user-form button { margin-top: 30px; }
.user-list { list-style: none; padding: 0; margin: 20px 0 0; }
.user-list li { display: flex; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.page-footer { margin: 40px 0 28px; color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 20px; top: -80px; z-index: 20; padding: 12px 20px; color: var(--on-primary); background: var(--primary); border-radius: 10px; }
.skip-link:focus { top: 12px; }
.icon { display: inline-block; flex-shrink: 0; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.workbench { background: var(--surface); }
.workbench-header { min-height: 76px; padding: 14px 34px; display: flex; align-items: center; justify-content: space-between; gap: 30px; border-bottom: 1px solid var(--line); background: var(--surface); }
.workbench .brand-link { gap: 16px; font-size: 25px; letter-spacing: -.02em; white-space: nowrap; }
.workbench .header-actions { gap: 24px; flex-wrap: nowrap; font-size: 16px; }
.utility-link { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 6px 0; border: 0; border-radius: 8px; color: var(--text); background: transparent; text-decoration: none; font-weight: 500; }
.utility-link:hover { color: var(--primary); text-decoration: none; }
.account-name { border-left: 1px solid var(--line); padding-left: 26px; max-width: 160px; overflow-wrap: anywhere; font-size: 14px; }
.workbench-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100svh - 76px); }
.channel-rail { padding: 24px 10px 14px; background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; position: sticky; top: 0; height: calc(100svh - 76px); max-height: calc(100svh - 76px); }
.rail-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 7px 16px; }
.rail-heading h2 { font-size: 16px; font-weight: 650; }
.channel-search { position: relative; display: block; margin: 0 7px 6px; }
.channel-search > .icon { position: absolute; left: 11px; top: 13px; width: 18px; height: 18px; color: var(--muted); }
.channel-search input { height: 44px; padding-left: 35px; padding-right: 8px; background: var(--surface); border-radius: 9px; font-weight: 400; font-size: 14px; }
.search-hint { margin: 0 7px 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.channel-nav { min-height: 160px; overflow: auto; overscroll-behavior: contain; flex: 1; scrollbar-width: thin; }
.channel-row { display: flex; align-items: center; min-width: 0; border-radius: 9px; margin-bottom: 1px; }
.channel-row:hover { background: var(--quiet); }
.channel-row.is-active { background: var(--active); box-shadow: inset 1px 0 var(--primary); }
.channel-item { width: auto; min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 9px; padding: 8px; min-height: 44px; text-align: left; background: transparent; color: var(--text); font-size: 14px; font-weight: 400; }
.channel-item.is-active { color: var(--primary); font-weight: 650; }
.channel-avatar-mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: var(--avatar-size); height: var(--avatar-size); color: inherit; }
.channel-avatar-fallback { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
/* Original portraits keep their own white canvas in both interface themes. */
.channel-avatar { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; border-radius: var(--avatar-radius, 5px); }
.channel-mark { --avatar-size: 26px; }
.channel-mark .icon { width: 18px; height: 18px; }
.channel-name { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.channel-total { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pin-button { flex: 0 0 32px; min-height: 44px; padding: 6px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; }
.pin-button .icon { width: 17px; height: 17px; }
.pin-button:hover, .pin-button[aria-pressed="true"] { color: var(--primary); background: var(--active); }
.channel-empty { padding: 12px 8px; font-size: 13px; color: var(--muted); }
.original-apis { margin: 18px 7px 0; padding-top: 16px; border-top: 1px solid var(--line); flex-shrink: 0; scroll-margin: 16px; }
.original-apis h2 { display: flex; align-items: center; gap: 16px; font-size: 16px; font-weight: 650; }
.raw-links { display: grid; gap: 4px; margin: 10px 0 16px; padding: 10px 12px; border-radius: 9px; background: var(--quiet); }
.raw-links a { color: var(--muted); font-size: 15px; text-decoration: none; min-height: 27px; }
.raw-links a:hover { color: var(--primary); text-decoration: underline; }
.rail-footnote { color: var(--muted); margin: 0; font-size: 12px; line-height: 1.6; }
.message-main { padding: 12px 36px 24px; min-width: 0; outline: none; scroll-margin-top: 12px; }
.workbench-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 8px; }
.reading-heading { min-width: 0; max-width: min(100%, 240px); }
.selected-channel-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
#selectedChannelMark { display: inline-flex; flex-shrink: 0; }
.heading-channel-mark { --avatar-size: 28px; --avatar-radius: 5px; }
.heading-channel-mark .icon { width: 22px; height: 22px; color: var(--primary); }
.workbench-heading h1 { font-size: 22px; letter-spacing: -.025em; line-height: 1.3; font-weight: 750; }
.selected-channel-heading h1 { min-width: 0; overflow-wrap: anywhere; }
.reading-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.feed-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px 12px; margin-left: auto; min-width: 0; }
.feed-status-slot { display: grid; align-items: center; width: 224px; min-width: 0; max-width: 100%; min-height: 44px; }
.feed-status, .new-message-slot { grid-area: 1 / 1; min-width: 0; }
.feed-status { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.collector-indicator { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.feed-status:has([data-state="ready"]) .collector-indicator { background: var(--success); }
.feed-status:has([data-state="error"]) .collector-indicator { background: var(--error); }
.refresh-time { border-left: 1px solid var(--line); padding-left: 8px; margin-left: 2px; }
.feed-actions { display: flex; align-items: center; gap: 8px; }
.auto-update { position: relative; display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; min-height: 44px; border: 1px solid var(--line); border-radius: 9px; font-size: 16px; font-weight: 500; cursor: pointer; }
.auto-update input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.auto-update:has(:focus-visible) { outline: 3px solid var(--primary); outline-offset: 4px; }
.switch-track { width: 38px; height: 23px; border-radius: 14px; background: var(--muted); padding: 3px; }
.switch-track::after { content: ''; display: block; width: 17px; height: 17px; border-radius: 50%; background: var(--surface); }
.auto-update input:checked + .switch-track { background: var(--primary); }
.auto-update input:checked + .switch-track::after { transform: translateX(15px); background: var(--on-primary); }
.workbench-heading .auto-update { gap: 8px; padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.refresh-button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; color: var(--primary); border-radius: 9px; min-width: 76px; font-size: 13px; font-weight: 500; }
.refresh-button .icon { width: 18px; height: 18px; }
.channel-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.channel-controls > button { padding: 6px 10px; font-size: 13px; }
.pinned-feed-toggle { white-space: nowrap; }
.pinned-feed-toggle .switch-track { flex-shrink: 0; }
.channel-selector { display: block; width: 160px; max-width: 100%; }
.channel-selector select { width: 100%; max-width: 100%; min-height: 44px; padding: 6px 28px 6px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--surface); font: inherit; font-size: 13px; cursor: pointer; }
.mobile-channel-toggle { display: none; }
/* The notice reuses the status area: no blank spacer and no reading-position jump. */
.new-message-slot:has(> [hidden]) { display: none; }
.feed-status-slot:has(.new-messages-button:not([hidden])) .feed-status { visibility: hidden; }
.new-messages-button { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; min-height: 44px; padding: 6px 10px; color: var(--primary); background: var(--active); border: 0; border-radius: 9px; font-size: 13px; font-weight: 500; text-align: left; }
.new-messages-button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-messages-button .icon { width: 18px; height: 18px; }
.new-messages-button:hover { background: color-mix(in srgb, var(--active) 85%, var(--primary)); }
.message-state { color: var(--muted); text-align: center; padding: 80px 16px; margin: 0; background: var(--bg); border-radius: 12px; }
.message-list { overflow-anchor: none; }
.date-divider { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.date-divider::before, .date-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.message-card { padding: 0 0 4px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.message-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; font-size: 14px; }
.channel-badge { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; color: var(--primary); background: var(--active); border-radius: 6px; padding: 2px 8px; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.channel-badge > span:last-child { min-width: 0; }
.badge-channel-mark { --avatar-size: 20px; --avatar-radius: 3px; }
.badge-channel-mark .icon { width: 17px; height: 17px; }
.message-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; flex-shrink: 0; }
.message-body { max-width: 72ch; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.4; letter-spacing: 0; margin: 0; }
.feed-footer { display: flex; justify-content: space-between; gap: 24px; color: var(--muted); font-size: 12px; margin: 32px 0 0; }
.feed-footer p { max-width: 75ch; margin: 0; }
.feed-footer a { flex-shrink: 0; }
.search-pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 24px; }
.search-pagination:has([hidden]):not(:has(:not([hidden]))) { display: none; }
.settings-tabs { display: flex; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.settings-tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 18px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 14px; }
.settings-tabs a:hover { background: var(--quiet); }
.settings-tabs a[aria-current="page"] { background: var(--active); color: var(--primary); font-weight: 650; }
.monitor-section { margin-top: 32px; }
.monitor-section h2 { font-size: 22px; }
.monitor-description { max-width: 78ch; margin: 14px 0 24px; font-size: 14px; line-height: 1.8; }
.monitor-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.monitor-search { width: min(100%, 340px); }
.monitor-search input { background: var(--surface); }
.monitor-apply-status { margin: 0 0 10px; color: var(--muted); }
.monitor-apply-status[data-state="ready"] { color: var(--success); }
.monitor-channel-list { border-top: 1px solid var(--line); }
.monitor-row { display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.monitor-icon { --avatar-size: 34px; background: var(--primary); color: var(--on-primary); }
.monitor-icon .icon { width: 20px; height: 20px; }
.monitor-label { display: grid; gap: 4px; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.monitor-label strong { font-size: 15px; font-weight: 550; }
.monitor-toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; min-width: 75px; font-size: 14px; font-weight: 400; cursor: pointer; }
.monitor-toggle input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.monitor-toggle input:checked + .switch-track { background: var(--primary); }
.monitor-toggle input:checked + .switch-track::after { transform: translateX(15px); background: var(--on-primary); }
.monitor-toggle:has(:focus-visible) { outline: 3px solid var(--primary); outline-offset: 4px; border-radius: 8px; }
.monitor-toggle:has(:disabled) { opacity: .6; cursor: wait; }
.monitor-toggle input:disabled { cursor: wait; }
.monitor-empty { padding: 32px 0; }
@media (prefers-reduced-motion: no-preference) {
  .switch-track, .switch-track::after { transition: background-color .18s ease-out, transform .18s cubic-bezier(.16, 1, .3, 1); }
  .new-messages-button { animation: new-message-notice .24s cubic-bezier(.16, 1, .3, 1); }
  @keyframes new-message-notice { from { background-color: var(--quiet); } to { background-color: var(--active); } }
}
@media (max-width: 1320px) {
  .workbench .brand-link { font-size: 22px; }
  .workbench .header-actions { gap: 18px; }
  .workbench-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .message-main { padding-left: 32px; padding-right: 28px; }
  .feed-tools { justify-content: flex-start; margin-left: 0; }
}
@media (max-width: 960px) {
  .workbench-header { padding: 14px 22px; flex-wrap: wrap; gap: 12px; }
  .workbench .header-actions { margin-left: auto; }
  .workbench-layout { grid-template-columns: 228px minmax(0, 1fr); }
  .workbench-heading { column-gap: 12px; }
  .feed-tools { width: 100%; }
}
@media (max-width: 700px) {
  .workbench-header { padding: 14px 18px 10px; }
  .workbench .brand-link { font-size: 21px; gap: 10px; }
  .workbench .brand-link img { width: 36px; height: 36px; }
  .workbench .header-actions { width: 100%; justify-content: space-between; gap: 10px; font-size: 14px; }
  .header-actions .icon { width: 20px; height: 20px; }
  .account-name { padding-left: 12px; max-width: 110px; font-size: 12px; }
  .utility-link { gap: 5px; }
  .workbench-layout { display: block; }
  .channel-rail { display: none; position: relative; top: auto; height: auto; max-height: none; padding: 24px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .channel-rail.is-open { display: flex; }
  .channel-nav { max-height: 340px; }
  .channel-search input { font-size: 16px; }
  .channel-item { font-size: 15px; }
  .pin-button { flex-basis: 44px; }
  .original-apis { margin-top: 20px; }
  .raw-links { margin-bottom: 16px; }
  .message-main { padding: 12px 16px 20px; }
  .workbench-heading h1 { font-size: 20px; }
  .reading-heading { max-width: 100%; }
  .feed-tools { gap: 4px 8px; }
  .feed-status-slot { width: 100%; min-height: 44px; }
  .feed-actions { flex-wrap: wrap; }
  .channel-controls { width: 100%; }
  .workbench-heading .auto-update { font-size: 14px; }
  .mobile-channel-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; font-size: 14px; }
  .channel-selector { min-width: 120px; flex: 1; }
  .channel-selector select { width: 100%; font-size: 14px; padding-left: 12px; }
  .new-messages-button { width: min(100%, 260px); font-size: 14px; }
  .feed-footer { flex-direction: column; gap: 12px; }
}
@media (prefers-reduced-motion: no-preference) { button, a { transition: background-color .16s ease-out, border-color .16s ease-out; } }
@media (max-width: 850px) {
  .login-layout { width: min(500px, calc(100% - 32px)); display: block; padding: 90px 0 32px; }
  .brand-panel { padding: 0 4px 30px; text-align: center; }
  .brand-logo { width: 52px; height: 52px; margin: 0 auto 20px; }
  .brand-panel h1 { font-size: 38px; }
  .brand-panel h1 br { display: none; }
  .subtitle { margin: 12px 0; font-size: 18px; }
  .brand-note { max-width: 30em; margin: auto; font-size: 14px; }
  .login-card { padding: 32px 26px; border-radius: 20px; }
  .create-user-form { grid-template-columns: 1fr; }
  .create-user-form button { margin: 0; }
}
@media (max-width: 540px) {
  .theme-button { top: 14px; right: 14px; }
  .app-shell { width: calc(100% - 32px); }
  .app-header { gap: 18px; }
  .header-actions { gap: 14px; }
  .page-heading { margin-top: 32px; }
  .api-links, .channel-list { grid-template-columns: 1fr; }
  .api-links a + a { border-top: 1px solid var(--line); }
}
