:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #18202a;
  --muted: #66717f;
  --line: #dce1e8;
  --accent: #1f6feb;
  --accent-strong: #1456b8;
  --success: #198754;
  --danger: #b42318;
  --shadow: 0 16px 45px rgba(24, 32, 42, .08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --surface: #20252c; --text: #edf1f5; --muted: #a6b0bd; --line: #37404b; --accent: #79b4ff; --accent-strong: #a7ccff; --success: #62d39a; --danger: #ff9b8f; --shadow: 0 16px 45px rgba(0, 0, 0, .2); }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
.shell { width: min(100% - 32px, 960px); margin: 0 auto; padding: 42px 0 26px; }
.topbar, .section-heading, .token-controls, .upload-actions, footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 34px; }
.eyebrow, .section-kicker { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .14em; margin: 0 0 8px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(30px, 5vw, 48px); letter-spacing: 0; margin-bottom: 0; line-height: 1.1; }
h2 { font-size: 22px; margin-bottom: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 28px; }
.token-panel { display: grid; grid-template-columns: 1fr minmax(300px, 400px); gap: 24px; align-items: end; margin-bottom: 50px; }
.token-form { display: grid; gap: 8px; }
.token-form label, .dropzone { display: block; font-size: 13px; font-weight: 650; }
.token-controls { align-items: stretch; margin-top: 8px; }
.legacy-token-panel, #login-error, #token-error { grid-column: 2; }
.legacy-token-panel { border-top: 1px solid var(--line); padding-top: 14px; }
.legacy-token-panel summary { color: var(--muted); cursor: pointer; font-size: 13px; }
.legacy-token-panel .muted { font-size: 12px; margin-top: 10px; }
.invite-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 18px; }
.invite-panel h3 { margin: 0 0 6px; font-size: 18px; }
input { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); padding: 11px 12px; font: inherit; min-width: 0; }
input:focus, button:focus-visible, .dropzone:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 2px; }
.button { border: 0; border-radius: 6px; font: inherit; font-weight: 650; padding: 11px 16px; cursor: pointer; white-space: nowrap; }
.button:disabled { cursor: wait; opacity: .55; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-strong); }
.button-quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.button-quiet:hover { color: var(--text); border-color: var(--muted); }
.muted, .status-line, footer { color: var(--muted); font-size: 14px; line-height: 1.65; margin-bottom: 0; }
.connection { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.connected .status-dot { background: var(--success); }
.section-heading { align-items: flex-start; margin-bottom: 12px; }
.library-actions, .settings-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.library-search { margin: 18px 0 8px; }
.library-search label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 7px; }
.search-controls { display: flex; gap: 8px; max-width: 560px; }
.search-controls input { background: var(--surface); }
.status-line { min-height: 25px; margin-bottom: 16px; }
.book-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.book-card { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-height: 190px; }
.book-card-info { min-width: 0; }
.book-cover { position: relative; isolation: isolate; aspect-ratio: 2 / 3; overflow: hidden; border: 1px solid rgba(24, 32, 42, .18); border-radius: 4px; padding: 12px 10px 10px 15px; display: flex; flex-direction: column; justify-content: space-between; color: var(--cover-ink); background: var(--cover-paper); box-shadow: 4px 4px 0 rgba(24, 32, 42, .1); }
.book-cover::after { content: ""; position: absolute; inset: 9px 9px auto 15px; height: 1px; background: currentColor; opacity: .3; }
.book-spine { position: absolute; z-index: 0; inset: 0 auto 0 0; width: 7px; background: rgba(24, 32, 42, .22); }
.book-mark { position: relative; z-index: 1; font-size: 25px; font-weight: 750; line-height: 1; }
.book-cover-title { position: relative; z-index: 1; font-size: 12px; font-weight: 750; line-height: 1.3; overflow-wrap: anywhere; }
.book-cover-author { position: relative; z-index: 1; font-size: 10px; line-height: 1.25; overflow-wrap: anywhere; opacity: .78; }
.book-cover.theme-0 { --cover-paper: #d9e9f2; --cover-ink: #17324a; }
.book-cover.theme-1 { --cover-paper: #dce8d7; --cover-ink: #23422e; }
.book-cover.theme-2 { --cover-paper: #f1dfc8; --cover-ink: #63391f; }
.book-cover.theme-3 { --cover-paper: #ead8d9; --cover-ink: #5c2f38; }
.book-cover.theme-4 { --cover-paper: #e5e0cd; --cover-ink: #4b4425; }
.book-cover.theme-5 { --cover-paper: #d9e2ed; --cover-ink: #243c5a; }
.book-cover.theme-6 { --cover-paper: #e6dcd0; --cover-ink: #4e3526; }
.book-cover.theme-7 { --cover-paper: #d9e5e2; --cover-ink: #214947; }
.book-card h3 { margin: 0 0 8px; font-size: 19px; }
.book-author { color: var(--muted); margin-bottom: 18px; }
.book-meta { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 12px; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.book-link { color: var(--accent); display: inline-block; font-size: 14px; font-weight: 700; margin-top: 22px; text-decoration: none; }
.book-link:hover { color: var(--accent-strong); text-decoration: underline; }
.book-progress { color: var(--muted); display: block; font-size: 13px; margin-top: 14px; }
.book-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.book-actions .book-link { margin-top: 0; }
.book-download { font-size: 13px; padding: 7px 10px; }
.empty-state { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 8px; text-align: center; padding: 46px 20px; color: var(--muted); }
.stream-panel { margin-top: 34px; }
.stream-list { display: grid; gap: 12px; }
.stream-card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--surface); }
.stream-card-heading, .stream-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.stream-source { color: var(--accent); font-weight: 700; }
.stream-card h3 { margin: 9px 0 7px; font-size: 17px; line-height: 1.35; }
.stream-card p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.stream-link { color: var(--accent); font-weight: 650; text-decoration: none; }
.stream-link:hover { text-decoration: underline; }
.stream-card-actions { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stream-card-actions .button { padding: 6px 9px; font-size: 12px; }
.stream-original { color: var(--muted); font-size: 12px; font-weight: 500; }
.daily-brief-panel { margin-top: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 22px; background: var(--surface); box-shadow: var(--shadow); }
.daily-brief-opening { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border-radius: 4px; padding: 12px 14px; margin: 8px 0 16px; line-height: 1.6; }
.daily-brief-list { display: grid; gap: 12px; }
.daily-brief-card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.daily-brief-card h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.4; }
.daily-brief-card p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 8px; }
.daily-brief-why { font-size: 12px !important; }
.daily-brief-sources { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.daily-brief-sources a { color: var(--accent); text-decoration: none; }
.daily-brief-sources a:hover { text-decoration: underline; }
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { width: auto; }
.upload-panel { margin-top: 34px; }
.dropzone { border: 1px dashed #9aa7b6; border-radius: 8px; padding: 34px 20px; text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.dropzone.is-busy { cursor: wait; opacity: .58; border-style: solid; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-icon { display: block; color: var(--accent); font-size: 28px; line-height: 1; margin-bottom: 8px; }
.drop-title, .drop-detail { display: block; }
.drop-title { font-weight: 700; }
.drop-detail { color: var(--muted); font-size: 13px; margin-top: 6px; overflow-wrap: anywhere; }
.upload-actions { justify-content: flex-end; margin-top: 16px; }
.message { border-radius: 6px; padding: 11px 13px; margin-top: 14px; font-size: 14px; line-height: 1.5; }
.message-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.message-info { color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.message-success { color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
footer { border-top: 1px solid var(--line); margin-top: 52px; padding-top: 18px; justify-content: space-between; }
.settings-dialog { width: min(100% - 28px, 520px); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); padding: 24px; box-shadow: var(--shadow); }
.daily-brief-dialog { width: min(100% - 28px, 800px); max-height: 88vh; overflow-y: auto; }
.daily-brief-dialog .brief-dialog-section + .brief-dialog-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.daily-brief-dialog .brief-dialog-subtitle { margin: 0 0 8px; font-size: 15px; }
.daily-brief-dialog .brief-dialog-actions { justify-content: flex-start; margin: 4px 0 14px; }
.daily-brief-dialog .daily-brief-list { margin-bottom: 6px; }
@media (max-width: 680px) {
  .daily-brief-dialog { width: calc(100% - 20px); max-height: 92vh; padding: 18px; }
}
.upload-dialog { width: min(100% - 28px, 620px); }
.upload-dialog .upload-panel { margin: 0; }
.settings-dialog::backdrop { background: rgba(24, 32, 42, .38); }
.settings-dialog form { display: grid; gap: 8px; }
.settings-dialog label { font-size: 13px; font-weight: 650; margin-top: 8px; }
.settings-dialog .dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.settings-dialog .status-line { margin-bottom: 12px; }
.settings-dialog .settings-actions { justify-content: flex-end; margin-top: 12px; }
.settings-dialog .settings-test-status { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; overflow-wrap: anywhere; }
.admin-dialog { width: min(100% - 28px, 720px); }
.admin-section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.admin-section h3 { font-size: 16px; margin: 0; }
.admin-section-heading, .admin-member-row, .admin-invitation-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-section-heading { margin-bottom: 10px; }
.admin-member-list, .admin-invitation-list { display: grid; gap: 8px; }
.admin-member-row, .admin-invitation-row { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.admin-member-meta, .admin-invitation-meta { min-width: 0; display: grid; gap: 2px; }
.admin-member-meta strong { overflow-wrap: anywhere; }
.admin-member-meta span, .admin-invitation-meta span { color: var(--muted); font-size: 12px; }
.admin-member-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-member-actions .button, .admin-invitation-row .button { padding: 7px 10px; font-size: 12px; }
.admin-invitation-row { align-items: flex-start; }
@media (max-width: 680px) { .shell { width: min(100% - 22px, 960px); padding-top: 25px; } .topbar { align-items: flex-start; } .token-panel { display: block; padding: 22px; } .token-form { margin-top: 24px; } .legacy-token-panel, #login-error, #token-error { margin-top: 20px; } .token-controls { display: block; } .token-controls .button { width: 100%; margin-top: 10px; } .panel { padding: 22px; } .section-heading { display: block; } .section-heading .button { margin-top: 12px; } .library-actions { margin-top: 12px; } .search-controls { max-width: none; } .book-card { grid-template-columns: 92px minmax(0, 1fr); gap: 13px; padding: 13px; } .book-cover { padding-left: 12px; } .settings-dialog { padding: 20px; } .settings-dialog .settings-actions { align-items: stretch; flex-direction: column; } .settings-dialog .settings-actions .button { width: 100%; } .admin-member-row, .admin-invitation-row { align-items: flex-start; flex-direction: column; } .admin-member-actions { width: 100%; } }

/* Notification-stack grouping for the stream (same-source collapse) — Reader style v2. */
.stream-stack { position: relative; }
.stream-stack.is-collapsed { padding-bottom: 9px; }
.stream-stack-header { display: flex; align-items: center; gap: 8px; padding: 2px 2px 8px; cursor: pointer; user-select: none; border-radius: 8px; }
.stream-stack-header:hover { background: rgba(31, 111, 235, .06); }
.stream-stack-header:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stream-stack-avatar { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.stream-stack-title { font-weight: 700; color: var(--accent); font-size: 14px; }
.stream-stack-pill { flex: none; background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); font-size: 11px; font-weight: 700; line-height: 16px; padding: 1px 8px; border-radius: 999px; }
.stream-stack-header time { margin-left: auto; color: var(--muted); font-size: 12px; }
.stream-stack-top { position: relative; z-index: 3; }
.stream-stack.is-collapsed .stream-stack-top .stream-card { box-shadow: var(--shadow); }
.stream-stack-top .stream-card h3 { margin-top: 0; }
/* Back layers peek ONLY below the main card bottom (~4px / ~8px); they are
   confined to the bottom strip so the header and headline are never covered. */
.stream-stack.is-collapsed .stream-stack-layers::before, .stream-stack.is-collapsed .stream-stack-layers::after { content: ""; position: absolute; height: 8px; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 7px 7px; }
.stream-stack.is-collapsed .stream-stack-layers::before { left: 10px; right: 10px; bottom: 4px; height: 6px; z-index: 1; }
.stream-stack.is-collapsed .stream-stack-layers::after { left: 20px; right: 20px; bottom: 0; height: 9px; z-index: 0; opacity: .8; }
/* Expanded: layers fully removed; compact divider list instead of per-row cards. */
.stream-stack.is-expanded { padding-bottom: 0; }
.stream-stack-rows { list-style: none; margin: 0; padding: 0; }
.stream-stack-row { border-bottom: 1px solid var(--line); }
.stream-stack-row:last-child { border-bottom: 0; }
.stream-stack-row-button { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 2px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.stream-stack-row-button:hover { background: rgba(31, 111, 235, .06); }
.stream-stack-row-button time { flex: none; color: var(--muted); font-size: 12px; }
.stream-stack-row-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-stack-row-detail[hidden] { display: none; }
.stream-stack-row-detail .stream-card { margin: 2px 0 12px; }

/* Stream navigation v1: Reeder-style source sidebar / responsive drawer. */
.stream-panel .section-heading { flex-wrap: wrap; gap: 10px; }
.stream-workspace { display: block; }
.stream-timeline-heading { margin-bottom: 12px; }
.stream-timeline-heading h3 { margin: 0 0 4px; font-size: 18px; overflow-wrap: anywhere; }
.stream-timeline-heading .status-line { margin: 0; }
.stream-source-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.stream-source-close { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; }
.stream-source-close:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); color: var(--text); }
.stream-source-search { display: block; width: 100%; margin: 0 0 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.stream-source-search::placeholder { color: var(--muted); }
.stream-source-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.stream-source-all { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 4px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 650; text-align: left; cursor: pointer; }
.stream-source-all:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.stream-source-all.is-selected { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.stream-source-all-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.stream-source-all.is-selected .stream-source-all-dot { background: var(--accent); }
.stream-source-section { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.stream-source-list { display: grid; gap: 2px; }
.stream-source-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 3px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.stream-source-row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.stream-source-row.is-selected { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.stream-source-avatar { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); font-size: 11px; font-weight: 700; }
.stream-source-row.is-selected .stream-source-avatar { background: var(--accent); color: #fff; }
.stream-source-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-source-empty { margin: 0; padding: 10px 8px; color: var(--muted); font-size: 12px; }
.stream-source-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); z-index: 40; }

@media (max-width: 1099.98px) {
  .stream-source-drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 41; width: min(280px, 86vw); display: flex; flex-direction: column; padding: 14px 12px; background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow); }
  .stream-source-scroll { flex: 1; min-height: 0; overflow-y: auto; }
  .stream-source-drawer.is-open { animation: stream-drawer-in 160ms ease-out; }
  .stream-source-backdrop.is-open { animation: stream-backdrop-in 160ms ease-out; }
}
@keyframes stream-drawer-in { from { transform: translateX(-16px); opacity: 0; } }
@keyframes stream-backdrop-in { from { opacity: 0; } }

@media (max-width: 759.98px) {
  .stream-panel { padding: 20px; }
}

@media (min-width: 1100px) {
  .stream-source-trigger { display: none; }
  /* Stream workspace may exceed the reading width on desktop only;
     the library and Daily Brief keep the global 960px shell width. */
  .stream-panel { --stream-overflow: min(130px, max(0px, calc((100vw - 32px - 960px) / 2))); width: calc(100% + var(--stream-overflow) * 2); margin-left: calc(var(--stream-overflow) * -1); }
  .stream-workspace { display: grid; grid-template-columns: 228px minmax(0, 760px); gap: 24px; align-items: start; justify-content: center; }
  .stream-source-drawer { position: sticky; top: 24px; height: calc(100vh - 48px); max-height: none; display: flex; flex-direction: column; padding: 4px 12px 4px 4px; border-right: 1px solid var(--line); }
  .stream-source-drawer-header { display: none; }
  .stream-source-nav { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  .stream-source-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; padding-right: 4px; }
  .stream-source-backdrop { display: none; }
}
