@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: dark;

  --bg-base: #0D0D0F;
  --bg-surface: #17181C;
  --bg-surface-elevated: #1F2026;
  --bg-surface-soft: #272832;
  --bg-reader: #111114;

  --text-primary: #F4F4F6;
  --text-secondary: #A7A7AF;
  --text-muted: #8A8B95;
  --text-inverse: #111114;

  --accent-primary: #6D7EEC;
  --accent-primary-hover: #5A68D8;
  --accent-primary-active: #4A56C0;
  --accent-soft: rgba(109, 126, 236, 0.12);
  --accent-border: rgba(109, 126, 236, 0.32);

  --status-success: #54D18A;
  --status-warning: #F4B860;
  --status-error: #EF4056;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.22);

  --font-xs: 12px;
  --font-sm: 13px;
  --font-md: 15px;
  --font-lg: 17px;
  --font-xl: 22px;
  --font-2xl: 28px;
  --font-3xl: 36px;
  --reader-body: 19px;
  --reader-line-height: 1.65;
  --reader-title: 36px;
  --reader-subtitle: 18px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --motion-fast: 120ms;
  --motion-normal: 180ms;
  --motion-slow: 260ms;
  --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;

  /* Legacy aliases: delete only after every selector is migrated. */
  --primary: var(--accent-primary);
  --primary-pressed: var(--accent-primary-active);
  --on-primary: #ffffff;
  --ink: var(--text-primary);
  --body: var(--text-secondary);
  --mute: var(--text-secondary);
  --ash: var(--text-muted);
  --stone: var(--bg-surface-soft);
  --canvas: var(--bg-base);
  --surface: var(--bg-surface);
  --surface-elevated: var(--bg-surface-elevated);
  --surface-card: var(--bg-surface);
  --button-fg: var(--text-inverse);
  --hairline: var(--border-subtle);
  --hairline-soft: var(--border-subtle);
  --hairline-strong: var(--border-medium);
  --accent-blue: var(--accent-primary);
  --accent-blue-soft: var(--accent-soft);
  --accent-red: var(--status-error);
  --accent-red-soft: rgba(239, 64, 86, 0.15);
  --accent-green: var(--status-success);
  --accent-green-soft: rgba(84, 209, 138, 0.15);
  --accent-yellow: var(--status-warning);
  --accent-yellow-soft: rgba(244, 184, 96, 0.15);
  --glow-red: #b71f29;
  --glow-red-soft: rgba(239, 64, 86, 0.22);
  --reader-size: var(--reader-body);
  --text: var(--text-primary);
  --danger: var(--status-error);

  font-family: var(--font);
  font-feature-settings: "calt", "kern", "liga", "ss03";
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-base: #F7F7F4;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #ECEDE8;
  --bg-surface-soft: #E1E3DC;
  --bg-reader: #FAFAF7;
  --text-primary: #15161A;
  --text-secondary: #4A4D55;
  --text-muted: #666A73;
  --text-inverse: #FFFFFF;
  --accent-primary: #5866D8;
  --accent-primary-hover: #4B57C4;
  --accent-primary-active: #3F49AC;
  --accent-soft: rgba(88, 102, 216, 0.11);
  --accent-border: rgba(88, 102, 216, 0.3);
  --status-success: #248B56;
  --status-warning: #B97317;
  --status-error: #C72B40;
  --border-subtle: rgba(17, 18, 20, 0.08);
  --border-medium: rgba(17, 18, 20, 0.16);
  --border-strong: rgba(17, 18, 20, 0.24);
  --primary: var(--accent-primary);
  --primary-pressed: var(--accent-primary-active);
  --on-primary: #ffffff;
  --ink: var(--text-primary);
  --body: var(--text-secondary);
  --mute: var(--text-secondary);
  --ash: var(--text-muted);
  --stone: var(--bg-surface-soft);
  --canvas: var(--bg-base);
  --surface: var(--bg-surface);
  --surface-elevated: var(--bg-surface-elevated);
  --surface-card: var(--bg-surface);
  --button-fg: var(--text-inverse);
  --hairline: var(--border-subtle);
  --hairline-soft: var(--border-subtle);
  --hairline-strong: var(--border-medium);
  --accent-blue: var(--accent-primary);
  --accent-blue-soft: var(--accent-soft);
  --accent-red: var(--status-error);
  --accent-red-soft: rgba(199, 43, 64, 0.12);
  --accent-green: var(--status-success);
  --accent-green-soft: rgba(36, 139, 86, 0.12);
  --accent-yellow: var(--status-warning);
  --accent-yellow-soft: rgba(185, 115, 23, 0.12);
  --reader-size: var(--reader-body);
  --text: var(--text-primary);
  --danger: var(--status-error);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

body.auth-locked {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

body.auth-locked .app-shell,
body:not(.auth-locked) .auth-screen {
  display: none;
}

:root[data-theme="light"] body {
  background: var(--canvas);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
label:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.auth-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 430px;
  padding: 18px;
  width: 100%;
}

.auth-brand {
  align-items: center;
  display: flex;
  gap: 14px;
}

.auth-copy h2 {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.08;
  margin-bottom: 10px;
}

.auth-copy p,
.auth-message {
  color: var(--body);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 0;
}

.auth-tabs {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
}

.auth-tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--body);
  min-height: 36px;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--ink);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-submit {
  margin-top: 10px;
  min-height: 42px;
}

.auth-password-field {
  align-items: stretch;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 44px;
  overflow: hidden;
}

.auth-password-field:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(109, 126, 236, 0.16);
}

.auth-password-field .settings-input {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 42px;
}

.auth-password-field .settings-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.auth-password-toggle {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border-subtle);
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  min-width: 64px;
  padding: 0 12px;
  text-transform: uppercase;
}

.auth-password-toggle:hover,
.auth-password-toggle:focus-visible {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.auth-message {
  min-height: 22px;
}

.auth-message.error {
  color: var(--accent-red);
}

.sidebar {
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top)) 16px 16px;
}

.brand-row,
.reader-topbar,
.panel-header {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.brand-home {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: flex;
  gap: 11px;
  padding: 0;
  text-align: left;
}

.brand-mark {
  align-items: center;
  background: #07080a;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--hairline-soft);
  display: inline-flex;
  flex: 0 0 auto;
  height: 42px;
  justify-content: center;
  overflow: hidden;
  width: 42px;
}

:root[data-theme="light"] .brand-mark {
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(17, 18, 20, 0.04);
}

.brand-mark img {
  display: block;
  height: 34px;
  width: 34px;
}

.view-nav {
  display: grid;
  gap: 8px;
}

.sidebar-utility-nav {
  border-top: 1px solid var(--hairline);
  margin-top: auto;
  padding-top: 12px;
}

.view-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--body);
  display: grid;
  gap: 12px;
  grid-template-columns: 4px minmax(0, 1fr);
  min-height: 58px;
  padding: 8px 12px 8px 10px;
  position: relative;
  text-align: left;
  width: 100%;
}

.view-button.active,
.view-button:hover {
  background: var(--surface-card);
  border-color: var(--hairline-soft);
}

.nav-indicator {
  background: var(--view-accent, var(--accent-blue));
  border-radius: 999px;
  height: 24px;
  opacity: 0.46;
  width: 4px;
}

.view-button.active .nav-indicator,
.view-button:hover .nav-indicator {
  opacity: 1;
}

.view-home {
  --view-accent: var(--accent-blue);
}

.view-highlights {
  --view-accent: var(--accent-yellow);
}

.view-profile {
  --view-accent: var(--accent-green);
}

.view-button strong,
.highlight-source strong {
  color: var(--ink);
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1.4;
}

.view-button small,
.highlight-source small {
  color: var(--mute);
  display: block;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 2px;
}

.eyebrow,
.reader-title-block p {
  color: var(--mute);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  line-height: 1.5;
  margin: 0 0 4px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.1;
  margin-bottom: 0;
}

h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.15;
  margin-bottom: 0;
}

h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.4;
  margin-bottom: 0;
}

.upload-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.settings-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 16px;
}

.settings-card h3 {
  margin-bottom: 16px;
}

.field-label {
  color: var(--mute);
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1.5;
  margin: 12px 0 6px;
}

.settings-input {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

.settings-input:focus {
  border-color: var(--accent-blue);
  outline: 0;
}

.account-lock-row {
  align-items: center;
  border-top: 1px solid var(--hairline);
  color: var(--mute);
  display: flex;
  font-size: 13px;
  gap: 12px;
  justify-content: space-between;
  line-height: 1.5;
  margin-top: 16px;
  padding-top: 14px;
}

.segmented-control {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
}

.theme-option {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--body);
  min-height: 34px;
}

.theme-option.active {
  background: var(--surface);
  color: var(--ink);
}

.settings-note {
  color: var(--mute);
  font-size: 14px;
  line-height: 1.6;
  margin: 12px 0 0;
}

.setting-toggle {
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  padding: 12px;
}

.setting-toggle input {
  accent-color: var(--accent-blue);
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.setting-toggle strong,
.setting-toggle small {
  display: block;
}

.setting-toggle small {
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 2px;
}

.forwarding-card {
  grid-column: 1 / -1;
}

.email-display {
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 14px;
  padding: 10px;
}

.email-display span {
  color: var(--ink);
  font-size: clamp(18px, 4vw, 28px);
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.forwarding-fields {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr);
  margin-top: 4px;
}

.sample-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.url-import {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.url-import input {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  min-width: 0;
  padding: 8px 10px;
}

.url-import input:focus {
  border-color: var(--accent-blue);
  outline: 0;
}

.upload-drop {
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline-soft);
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  gap: 12px;
  min-height: 60px;
  padding: 10px;
}

.upload-drop strong,
.library-item strong,
.command-preview strong {
  color: var(--ink);
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1.4;
}

.upload-drop small,
.library-item small,
.command-preview small {
  color: var(--mute);
  display: block;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 2px;
}

.upload-icon,
.item-type,
.preview-icon,
.nav-icon {
  align-items: center;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--body);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  height: 36px;
  justify-content: center;
  letter-spacing: 0.2px;
  width: 36px;
}

.upload-icon {
  background: var(--accent-blue-soft);
  border-color: rgba(87, 193, 255, 0.28);
  color: var(--accent-blue);
  font-size: 20px;
  font-weight: 500;
}

#fileInput {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.tab {
  border: 0;
  border-radius: 8px;
  min-height: 36px;
}

.primary-button {
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 0 16px;
}

.primary-button:active {
  background: var(--primary-pressed);
}

.primary-button:disabled {
  background: var(--surface-elevated);
  color: var(--ash);
  cursor: default;
}

.secondary-button,
.icon-button {
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  color: var(--ink);
  display: inline-flex;
  font-size: 14px;
  font-weight: 500;
  justify-content: center;
  letter-spacing: 0.2px;
  padding: 0 14px;
}

.secondary-button.danger {
  border-color: color-mix(in srgb, var(--accent-red) 36%, transparent);
  color: var(--accent-red);
}

.secondary-button.danger:disabled {
  border-color: var(--hairline);
  color: var(--ash);
}

.text-button {
  background: transparent;
  color: var(--body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 0 6px;
}

.text-button.danger {
  color: var(--accent-red);
}

#deleteActiveDocumentButton {
  min-width: 58px;
}

.hidden {
  display: none !important;
}

.icon-button {
  min-width: 38px;
  padding: 0 10px;
}

.tabs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  background: transparent;
  color: var(--body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  min-height: 32px;
  padding: 4px 10px;
}

.tab.active {
  background: var(--surface-elevated);
  color: var(--ink);
}

.library-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-bottom: 20px;
}

.library-item {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--body);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 64px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.library-item-open {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 10px;
  grid-template-columns: 36px minmax(0, 1fr);
  min-width: 0;
  padding: 0;
  text-align: left;
}

.library-item-delete {
  opacity: 0.72;
}

.library-item:hover .library-item-delete,
.library-item:focus-within .library-item-delete {
  opacity: 1;
}

.library-item:hover,
.library-item.active {
  background: var(--surface-card);
  border-color: var(--hairline-soft);
}

.library-item .item-type {
  background: var(--type-accent-soft);
  border-color: color-mix(in srgb, var(--type-accent) 32%, transparent);
  color: var(--type-accent);
  font-size: 10px;
  letter-spacing: 0;
  overflow: hidden;
  padding: 0 4px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item.active .item-type {
  background: var(--type-accent-soft);
  border-color: color-mix(in srgb, var(--type-accent) 42%, transparent);
  color: var(--type-accent);
}

.library-item.type-article,
.library-item.type-newsletter,
.library-item.type-epub,
.library-item.type-pdf {
  --type-accent: var(--accent-blue);
  --type-accent-soft: var(--accent-blue-soft);
}

.library-item.type-article {
  --type-accent: var(--accent-green);
  --type-accent-soft: var(--accent-green-soft);
}

.library-item.type-newsletter {
  --type-accent: var(--accent-yellow);
  --type-accent-soft: var(--accent-yellow-soft);
}

.library-item.type-pdf {
  --type-accent: var(--accent-red);
  --type-accent-soft: var(--accent-red-soft);
}

.item-copy {
  min-width: 0;
}

.item-copy strong,
.item-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
  width: 100%;
}

.reader-topbar {
  background: var(--canvas);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--hairline);
  min-width: 0;
  overflow: hidden;
  padding: max(14px, env(safe-area-inset-top)) 24px 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.reader-title-block {
  flex: 1;
  min-width: 0;
}

.reader-title-block h2 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

body:not(.reader-document) .reader-actions:has(#copyButton:disabled):has(#refreshActiveDocumentButton:disabled):has(#archiveActiveDocumentButton:disabled):has(#deleteActiveDocumentButton:disabled) {
  display: none;
}

.reader-actions::-webkit-scrollbar {
  display: none;
}

.toast-region {
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  left: 50%;
  max-width: min(520px, calc(100vw - 28px));
  pointer-events: none;
  position: fixed;
  transform: translateX(-50%);
  width: max-content;
  z-index: 45;
}

.toast {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, black 8%);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.32);
  color: var(--text);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 12px 10px 18px;
  pointer-events: auto;
}

.toast span {
  font-size: 14px;
  line-height: 1.3;
  max-width: min(340px, 62vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-action {
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  color: var(--accent-ink);
  cursor: pointer;
  font: 700 13px/1 var(--font-ui);
  padding: 10px 14px;
}

.toast-action:active {
  transform: translateY(1px);
}

.panel-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.copy-fallback-backdrop {
  align-items: center;
  background: rgb(0 0 0 / 0.58);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.copy-fallback-panel {
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.32);
  display: grid;
  gap: 12px;
  max-height: min(680px, 88vh);
  max-width: min(720px, 100%);
  padding: 14px;
  width: 100%;
}

.copy-fallback-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.copy-fallback-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.copy-fallback-panel textarea {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font: 15px/1.55 var(--font-ui);
  min-height: min(520px, 70vh);
  padding: 12px;
  resize: vertical;
  width: 100%;
}

.reader-stage {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 42px clamp(18px, 4vw, 56px);
  width: 100%;
}

body.reader-document[data-reader-format="epub"] .reader-panel {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

body.reader-document[data-reader-format="epub"] .reader-stage {
  background: var(--canvas);
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

body.reader-document[data-reader-format="epub"] .epub-reader-document {
  display: block;
  height: 100%;
  min-height: 0;
}

body.reader-document[data-reader-format="epub"] .epub-reader {
  height: 100% !important;
  max-height: none;
  min-height: 0;
}

body.reader-document[data-reader-format="epub"] .highlights-panel,
body.reader-document[data-reader-format="epub"] #increaseTextButton,
body.reader-document[data-reader-format="epub"] #decreaseTextButton,
body.reader-document[data-reader-format="article"] #increaseTextButton,
body.reader-document[data-reader-format="article"] #decreaseTextButton,
body.reader-document[data-reader-format="newsletter"] #increaseTextButton,
body.reader-document[data-reader-format="newsletter"] #decreaseTextButton {
  display: none;
}

.home-library-view {
  margin: 0 auto;
  max-width: 1180px;
}

.library-heading {
  align-items: end;
  border-bottom: 1px solid var(--hairline);
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 18px;
  padding-bottom: 22px;
}

.library-heading h2 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 600;
  line-height: 1.06;
  margin-bottom: 10px;
}

.library-heading-count {
  color: var(--mute);
  font-size: 0.72em;
  font-weight: 500;
}

.library-heading p:not(.eyebrow) {
  color: var(--body);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 0;
  max-width: 620px;
}

.library-heading-action {
  margin-top: 16px;
}

.library-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  margin: 0;
}

.library-stats div {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  min-height: 72px;
  padding: 10px 12px;
}

.library-stats dt {
  color: var(--mute);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
}

.library-stats dd {
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  margin: 0;
}

.library-control-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.library-filter-control {
  position: relative;
  width: min(100%, 240px);
  z-index: 5;
}

.library-sort-control {
  width: min(100%, 280px);
}

.library-search-control {
  display: grid;
  gap: 4px;
  width: min(100%, 320px);
}

.library-search-input-wrap {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  min-height: 40px;
  padding: 0 8px 0 12px;
}

.library-search-input-wrap:focus-within {
  background: var(--surface-elevated);
  border-color: var(--hairline-strong);
}

.library-search-input-wrap input {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  flex: 1;
  font: inherit;
  min-width: 0;
  outline: 0;
}

.library-search-input-wrap input::placeholder {
  color: var(--mute);
}

.library-search-clear {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--mute);
  font-size: 12px;
  font-weight: 800;
  min-height: 30px;
  padding: 0 8px;
}

.library-search-clear:hover,
.library-search-clear:focus-visible {
  background: var(--surface-elevated);
  color: var(--ink);
}

.empty-search-panel {
  gap: 10px;
}

.empty-search-panel .secondary-button {
  align-self: start;
}

.type-filter-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  font-size: 14px;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  width: 100%;
}

.type-filter-button:hover,
.library-filter-control.open .type-filter-button {
  background: var(--surface-elevated);
  border-color: var(--hairline-strong);
}

.type-filter-label {
  color: var(--mute);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.type-filter-button strong {
  flex: 1;
  font-weight: 650;
  text-align: left;
}

.type-filter-count {
  color: var(--mute);
  font-size: 12px;
  font-weight: 800;
}

.type-filter-chevron {
  color: var(--mute);
  font-size: 16px;
  line-height: 1;
}

.type-filter-menu {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.16);
  display: none;
  left: 0;
  min-width: 230px;
  padding: 6px;
  position: absolute;
  top: calc(100% + 6px);
  width: 100%;
}

.library-filter-control.open .type-filter-menu {
  display: grid;
  gap: 2px;
}

.type-filter-option {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--body);
  display: flex;
  font-size: 14px;
  font-weight: 650;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
  width: 100%;
}

.type-filter-option:hover,
.type-filter-option.active {
  background: var(--surface);
  color: var(--ink);
}

.type-filter-option.active::after {
  color: var(--accent-blue);
  content: "✓";
  font-size: 13px;
  font-weight: 800;
  margin-left: 8px;
}

.type-filter-option-count {
  color: var(--mute);
  font-size: 12px;
  font-weight: 800;
  margin-left: auto;
}

.library-bulk-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.library-grid {
  display: grid;
  gap: 10px;
}

.library-row {
  --type-accent: var(--accent-blue);
  --type-accent-soft: var(--accent-blue-soft);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: visible;
  position: relative;
}

.library-row.type-article {
  --type-accent: var(--accent-green);
  --type-accent-soft: var(--accent-green-soft);
}

.library-row.type-newsletter {
  --type-accent: var(--accent-blue);
  --type-accent-soft: var(--accent-blue-soft);
}

.library-row.type-epub {
  --type-accent: var(--accent-blue);
  --type-accent-soft: var(--accent-blue-soft);
}

.library-row.type-pdf {
  --type-accent: var(--accent-red);
  --type-accent-soft: var(--accent-red-soft);
}

.library-row:hover {
  border-color: var(--hairline-strong);
}

.library-row-open {
  align-items: start;
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  grid-template-columns: 9px minmax(0, 1fr) 82px;
  min-width: 0;
  padding: 14px 46px 18px 14px;
  text-align: left;
  width: 100%;
}

.library-row.selection-mode {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.library-row.selection-mode .document-checkbox {
  align-self: center;
  display: block;
  grid-column: 1;
  grid-row: 1 / span 2;
  margin-left: 14px;
}

.library-row.selection-mode .library-row-menu-wrap {
  display: none;
}

.library-row.selection-mode .library-row-open {
  grid-column: 2 / -1;
  padding-left: 6px;
}

.document-checkbox {
  accent-color: var(--accent-red);
  display: none;
  margin: 0;
}

.library-row-unread {
  background: transparent;
  border-radius: 999px;
  display: block;
  height: 9px;
  margin-top: 31px;
  width: 9px;
}

.library-row-unread.visible {
  background: var(--accent-blue);
}

.library-row-copy {
  min-width: 0;
}

.library-row-kicker {
  align-items: center;
  color: var(--mute);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  gap: 6px;
  letter-spacing: 0.09em;
  line-height: 1.2;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.library-row-copy strong {
  color: var(--ink);
  display: -webkit-box;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-row-excerpt {
  color: var(--body);
  display: -webkit-box;
  font-size: 14px;
  line-height: 1.42;
  margin-top: 6px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-row-meta {
  color: var(--mute);
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-row-thumbnail {
  align-items: center;
  align-self: center;
  background: linear-gradient(135deg, var(--type-accent-soft), var(--surface-elevated));
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--type-accent);
  display: flex;
  font-size: 20px;
  font-weight: 800;
  height: 82px;
  justify-content: center;
  overflow: hidden;
  width: 82px;
}

.library-row-thumbnail img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.library-row-menu-wrap {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 3;
}

.library-row-menu-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--mute);
  display: inline-flex;
  font-size: 16px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  letter-spacing: 0.08em;
  line-height: 1;
  width: 34px;
}

.library-row-menu-button:hover,
.library-row-menu-wrap.open .library-row-menu-button {
  background: var(--surface-elevated);
  color: var(--ink);
}

.library-row-quick-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  position: absolute;
  right: 50px;
  top: 10px;
  z-index: 2;
}

.library-row-quick-actions .text-button {
  background: rgba(238, 243, 247, 0.06);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink);
  min-height: 30px;
  padding: 0 11px;
}

.library-row-quick-actions .text-button:hover {
  background: var(--surface-elevated);
  border-color: var(--hairline-strong);
}

.library-row-quick-actions .text-button.danger {
  color: var(--danger);
}

.library-row.selection-mode .library-row-quick-actions {
  display: none;
}

.library-row-menu {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.16);
  display: none;
  gap: 2px;
  min-width: 168px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
}

.library-row-menu-wrap.open .library-row-menu {
  display: grid;
}

.library-row-menu-item {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--body);
  font-size: 14px;
  font-weight: 650;
  min-height: 36px;
  padding: 0 10px;
  text-align: left;
  width: 100%;
}

.library-row-menu-item:hover {
  background: var(--surface);
  color: var(--ink);
}

.library-row-menu-item.danger {
  color: var(--danger);
}

.library-row-progress {
  background: var(--surface-elevated);
  border-radius: 999px;
  bottom: 0;
  grid-column: 1 / -1;
  height: 2px;
  left: 0;
  overflow: hidden;
  position: absolute;
  right: 0;
}

.library-row-progress span {
  background: var(--type-accent);
  border-radius: inherit;
  display: block;
  height: 100%;
}

.empty-state {
  align-items: center;
  display: grid;
  gap: clamp(24px, 5vw, 56px);
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1fr);
  margin: 0 auto;
  max-width: 1120px;
  min-height: 66vh;
  overflow: hidden;
  position: relative;
}

.empty-copy,
.command-preview {
  position: relative;
  z-index: 1;
}

.hero-logo {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 14px;
  margin-bottom: 28px;
}

.hero-logo strong {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

.hero-brand-mark {
  border-radius: 14px;
  height: 58px;
  width: 58px;
}

.hero-brand-mark img {
  height: 47px;
  width: 47px;
}

.empty-copy h2 {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.1;
  margin-bottom: 20px;
  max-width: 620px;
}

.empty-copy p:not(.eyebrow) {
  color: var(--body);
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 0;
  max-width: 560px;
}

.command-preview {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 12px;
}

.command-search {
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline-soft);
  border-radius: 10px;
  color: var(--body);
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
}

.command-search span {
  align-items: center;
  background: var(--surface-card);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  color: var(--body);
  display: inline-flex;
  font-size: 12px;
  font-weight: 500;
  height: 26px;
  justify-content: center;
  line-height: 1;
  width: 26px;
}

.preview-chip {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--mute);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
}

.preview-row {
  align-items: center;
  border-radius: 6px;
  display: grid;
  gap: 12px;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  margin-top: 8px;
  min-height: 64px;
  padding: 8px 10px;
}

.preview-row.active {
  background: var(--surface-card);
}

.accent-blue {
  background: var(--accent-blue-soft);
  border-color: rgba(87, 193, 255, 0.28);
  color: var(--accent-blue);
}

.accent-yellow {
  background: var(--accent-yellow-soft);
  border-color: rgba(255, 197, 51, 0.3);
  color: var(--accent-yellow);
}

.accent-green {
  background: var(--accent-green-soft);
  border-color: rgba(89, 212, 153, 0.3);
  color: var(--accent-green);
}

.article-reader {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  margin: 0 auto;
  max-width: 820px;
  min-height: 68vh;
  min-width: 0;
  overflow-x: hidden;
  padding: clamp(24px, 6vw, 64px) clamp(24px, 6vw, 64px) calc(clamp(24px, 6vw, 64px) + 92px);
  position: relative;
  width: 100%;
}

.article-reader.reader-measure-narrow {
  max-width: 680px;
}

.article-reader.reader-measure-standard {
  max-width: 800px;
}

.article-reader.reader-measure-wide {
  max-width: 920px;
}

.article-reader.reader-text-compact .article-body {
  font-size: 17px;
}

.article-reader.reader-text-comfortable .article-body {
  font-size: 19px;
}

.article-reader.reader-text-large .article-body {
  font-size: 21px;
}

.reader-progress-rail {
  background: color-mix(in srgb, var(--border-subtle) 72%, transparent);
  border-radius: var(--radius-pill);
  height: 3px;
  margin: -12px 0 22px;
  overflow: hidden;
  width: 100%;
}

.reader-progress-rail span {
  background: color-mix(in srgb, var(--accent-primary) 68%, var(--text-muted));
  display: block;
  height: 100%;
  transition: width var(--motion-normal) var(--motion-ease);
}

.article-meta {
  color: var(--mute);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 34px;
}

.reader-trust-details {
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--mute);
  margin: -18px 0 18px;
  padding: 9px 12px;
}

.reader-trust-details.has-warnings {
  border-color: rgba(255, 196, 87, 0.38);
}

.reader-trust-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.reader-trust-details dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.reader-trust-details dl div {
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.reader-trust-details dt {
  color: var(--mute);
}

.reader-trust-details dd {
  color: var(--text);
  margin: 0;
  text-align: right;
}

.reader-comfort-bar {
  background: color-mix(in srgb, var(--surface) 58%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  margin: 0 0 28px;
  padding: 9px 12px;
}

.reader-comfort-bar summary {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.reader-comfort-groups {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.reader-comfort-group {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 64px minmax(0, 1fr);
}

.reader-comfort-group > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.reader-segmented-control {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  display: flex;
  min-width: 0;
  overflow-x: auto;
  padding: 3px;
  scrollbar-width: none;
}

.reader-segmented-control::-webkit-scrollbar {
  display: none;
}

.reader-segmented-control button {
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  flex: 1 0 auto;
  font-size: 13px;
  font-weight: 700;
  min-height: 34px;
  min-width: 72px;
  padding: 0 12px;
}

.reader-segmented-control button.active {
  background: color-mix(in srgb, var(--accent-primary) 28%, var(--bg-surface-elevated));
  box-shadow: inset 0 0 0 1px var(--accent-border);
  color: var(--ink);
}

.reader-segmented-control button:focus-visible {
  outline-offset: 1px;
}

.reader-floating-controls {
  align-items: center;
  backdrop-filter: blur(22px);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: 26px 26px 0 0;
  bottom: 0;
  box-shadow: 0 -16px 48px rgb(0 0 0 / 0.28);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  left: 50%;
  margin: 0 auto;
  max-width: min(640px, 100vw);
  padding: 9px 14px max(10px, env(safe-area-inset-bottom));
  position: fixed;
  transform: translateX(-50%);
  width: 100%;
  z-index: 35;
}

.reader-floating-controls button,
.reader-sheet-primary button,
.reader-sheet-list button,
.reader-sheet-header button,
.reader-sheet-delete {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
}

.reader-floating-controls button {
  align-items: center;
  border-radius: 18px;
  display: grid;
  gap: 2px;
  justify-items: center;
  min-height: 48px;
  padding: 5px 4px;
}

.reader-floating-controls button:active,
.reader-floating-controls button:focus-visible,
.reader-sheet-primary button:active,
.reader-sheet-primary button:focus-visible,
.reader-sheet-list button:active,
.reader-sheet-list button:focus-visible {
  background: color-mix(in srgb, var(--accent-primary) 32%, var(--bg-surface-elevated));
  box-shadow: inset 0 0 0 1px var(--accent-border);
  color: var(--ink);
}

.reader-floating-controls span {
  font-size: 21px;
  line-height: 1;
}

.reader-floating-controls small {
  color: var(--text-muted);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.reader-actions-modal {
  inset: 0;
  position: fixed;
  z-index: 90;
}

.reader-actions-backdrop {
  background: rgb(0 0 0 / 0.34);
  inset: 0;
  position: absolute;
}

.reader-actions-sheet {
  background: color-mix(in srgb, var(--surface) 96%, black 4%);
  border: 1px solid var(--border-subtle);
  border-radius: 24px 24px 0 0;
  bottom: 0;
  box-shadow: 0 -24px 80px rgb(0 0 0 / 0.44);
  color: var(--text);
  display: grid;
  gap: 14px;
  left: 50%;
  max-height: min(70svh, 520px);
  max-width: min(640px, 100vw);
  overflow-y: auto;
  padding: 10px 22px max(22px, env(safe-area-inset-bottom));
  position: absolute;
  transform: translateX(-50%);
  width: 100%;
}

.reader-sheet-handle {
  background: var(--border-subtle);
  border-radius: 999px;
  height: 5px;
  justify-self: center;
  width: 44px;
}

.reader-sheet-header {
  align-items: center;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  text-align: center;
}

.reader-sheet-header button {
  color: var(--accent-blue);
  font-weight: 700;
  justify-self: end;
}

.reader-sheet-primary,
.reader-sheet-list {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  overflow: hidden;
}

.reader-sheet-primary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.reader-sheet-primary button {
  align-items: center;
  display: grid;
  gap: 7px;
  justify-items: center;
  min-height: 88px;
}

.reader-sheet-primary button + button,
.reader-sheet-list button + button {
  border-left: 1px solid var(--border-subtle);
}

.reader-sheet-primary span {
  font-size: 30px;
  line-height: 1;
}

.reader-sheet-primary small {
  color: var(--text-muted);
  font-size: 12px;
}

.reader-sheet-list button {
  align-items: center;
  border-left: 0 !important;
  display: flex;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 20px;
  width: 100%;
}

.reader-sheet-list button + button {
  border-top: 1px solid var(--border-subtle);
}

.reader-sheet-primary button:disabled,
.reader-sheet-list button:disabled {
  color: var(--text-muted);
  opacity: 0.72;
}

.reader-sheet-delete {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  color: var(--danger);
  min-height: 54px;
}

.reader-trust-warning,
.library-row-warning,
.library-row-sync-status.pending {
  color: #ffd27a;
}

.article-body {
  color: var(--body);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: var(--reader-size);
  line-height: 1.72;
  min-width: 0;
  outline: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-body * {
  box-sizing: border-box;
  max-width: 100% !important;
  min-width: 0 !important;
}

.article-body p {
  margin-bottom: 1.25em;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.35em 1.25em;
  padding-left: 1.1em;
}

.article-body li {
  margin: 0.42em 0;
}

.article-body .protonmail_quote,
.article-body .gmail_quote,
.article-body .yahoo_quoted {
  margin: 0 !important;
  padding: 0 !important;
}

.article-body .protonmail_quote blockquote,
.article-body .gmail_quote blockquote,
.article-body .yahoo_quoted blockquote {
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.article-body h1,
.article-body h2,
.article-body h3 {
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  line-height: 1.18;
  margin: 1.5em 0 0.55em;
}

.article-body h1 {
  font-size: clamp(30px, 5vw, 44px);
}

.article-body h2 {
  font-size: clamp(24px, 4vw, 34px);
}

.article-body h3 {
  font-size: clamp(20px, 3vw, 26px);
}

.article-body figure {
  margin: 1.8em auto;
  max-width: 100%;
}

.article-body img,
.article-body picture,
.article-body video,
.article-body canvas,
.article-body svg,
.article-body iframe {
  display: block;
  height: auto !important;
  margin: 1.4em auto;
  max-width: 100% !important;
  min-width: 0 !important;
  object-fit: contain;
  width: auto !important;
}

.article-body img[data-reader-chrome-image="true"] {
  background: none;
  border-radius: 0;
  box-shadow: none;
  cursor: default;
  display: inline-block;
  height: auto !important;
  margin: 0 0.25em;
  max-height: 64px;
  max-width: 96px !important;
  object-fit: contain;
  vertical-align: middle;
  width: auto !important;
}

.article-body img[data-reader-pending-image="true"] {
  height: auto !important;
  margin: 0.5em auto;
  max-height: 96px;
  max-width: 160px !important;
  object-fit: contain;
  width: auto !important;
}

.article-body [data-reader-image-container="true"] {
  box-sizing: border-box;
  max-width: 100% !important;
  min-width: 0 !important;
  text-align: center;
  width: 100% !important;
}

.article-body table[data-reader-image-container="true"],
.article-body tbody[data-reader-image-container="true"],
.article-body tr[data-reader-image-container="true"] {
  display: block;
}

.article-body td[data-reader-image-container="true"],
.article-body th[data-reader-image-container="true"] {
  display: block;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.article-body img[data-reader-content-image="true"] {
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--border-subtle);
  cursor: zoom-in;
  height: auto !important;
  margin: 1.4em auto;
  max-height: none;
  max-width: min(100%, 720px) !important;
  object-fit: contain;
  width: auto !important;
}

.article-body img[data-reader-enlargeable="true"] {
  cursor: zoom-in;
}

.article-body a:has(img[data-reader-enlargeable="true"]) {
  cursor: zoom-in;
  text-decoration: none;
}

.reader-image-lightbox {
  align-items: center;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  position: fixed;
  z-index: 80;
}

.reader-image-lightbox-panel {
  margin: 0;
  max-width: 96vw;
  position: relative;
}

.reader-image-lightbox img {
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  display: block;
  height: auto;
  max-height: 88dvh;
  max-width: 94vw;
  object-fit: contain;
  width: auto;
}

.reader-image-lightbox figcaption {
  color: rgba(255, 255, 255, 0.78);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  margin: 10px auto 0;
  max-width: min(720px, 94vw);
  text-align: center;
}

.reader-image-lightbox-close {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 1;
}

.article-body picture img {
  margin: 0 auto;
}

.article-body figcaption {
  color: var(--mute);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78em;
  line-height: 1.45;
  margin-top: 0.7em;
}

.article-body table {
  border-collapse: collapse;
  display: table;
  max-width: 100% !important;
  table-layout: fixed;
  width: 100% !important;
}

.article-body tbody,
.article-body thead,
.article-body tfoot,
.article-body tr,
.article-body td,
.article-body th {
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-wrap: anywhere;
  width: auto !important;
}

.article-body table[role="none"],
.article-body table[role="presentation"] {
  display: block !important;
  table-layout: auto;
}

.article-body table[role="none"] > tbody,
.article-body table[role="none"] > tbody > tr,
.article-body table[role="none"] > tbody > tr > td,
.article-body table[role="presentation"] > tbody,
.article-body table[role="presentation"] > tbody > tr,
.article-body table[role="presentation"] > tbody > tr > td {
  display: block !important;
  width: 100% !important;
}

.article-body pre {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.article-body mark {
  background: linear-gradient(transparent 52%, color-mix(in srgb, var(--highlight-color, var(--accent-yellow)) 72%, transparent) 52%);
  border-radius: 2px;
  color: var(--ink);
  cursor: pointer;
  padding: 0 0.03em;
}

.article-body mark:hover {
  outline: 1px solid color-mix(in srgb, var(--highlight-color, var(--accent-yellow)) 72%, transparent);
  outline-offset: 2px;
}

.highlight-popover {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  padding: 12px;
  position: fixed;
  width: 220px;
  z-index: 50;
}

.highlight-popover p {
  color: var(--mute);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 0;
  text-transform: uppercase;
}

.highlight-colors {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, 1fr);
}

.color-button {
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  height: 36px;
}

.color-yellow {
  background: #ffc533;
}

.color-blue {
  background: #57c1ff;
}

.color-green {
  background: #59d499;
}

.color-red {
  background: #ff6161;
}

.pdf-reader {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  display: grid;
  margin: 0 auto;
  max-width: 820px;
  min-height: min(60vh, 620px);
  padding: clamp(22px, 5vw, 48px);
  position: relative;
}

.pdf-open-card {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 560px;
  padding: clamp(20px, 4vw, 34px);
  text-align: left;
}

.pdf-open-card h2 {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.08;
  margin: 0;
}

.pdf-open-card p:not(.eyebrow) {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.pdf-open-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.epub-reader {
  --epub-shell: #050506;
  --epub-page: #0b0b0c;
  --epub-ink: #f5f3ee;
  --epub-body: #ddd9d1;
  --epub-muted: #9a958c;
  --epub-line: rgba(245, 243, 238, 0.12);
  --epub-control: rgba(255, 255, 255, 0.07);
  background: var(--epub-shell);
  color: var(--epub-ink);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(86vh, 980px);
  margin: 0 auto;
  max-width: 1280px;
  min-width: 0;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.epub-reader[data-epub-theme="light"] {
  --epub-shell: #eeeee9;
  --epub-page: #fbfbf8;
  --epub-ink: #17191c;
  --epub-body: #2e3033;
  --epub-muted: #6d7178;
  --epub-line: rgba(26, 28, 31, 0.12);
  --epub-control: rgba(26, 28, 31, 0.06);
}

.epub-reader[data-epub-theme="sepia"] {
  --epub-shell: #e3d5b8;
  --epub-page: #f3ecd9;
  --epub-ink: #241e17;
  --epub-body: #43382c;
  --epub-muted: #796b58;
  --epub-line: rgba(62, 48, 33, 0.16);
  --epub-control: rgba(73, 53, 30, 0.08);
}

.epub-reading-bar {
  align-items: center;
  border-bottom: 1px solid var(--epub-line);
  color: var(--epub-muted);
  display: grid;
  gap: 10px 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 13px 18px;
  position: relative;
  z-index: 8;
}

.epub-footer {
  align-items: center;
  color: var(--epub-muted);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 13px 18px;
  position: relative;
  z-index: 8;
}

.epub-current-location {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.epub-current-location span,
.epub-progress-meta,
.epub-notes-heading span,
.epub-note-card small,
.epub-notes-empty span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
}

.epub-reading-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: end;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.epub-reading-actions::-webkit-scrollbar {
  display: none;
}

.epub-pill-button,
.epub-footer-button,
.epub-appearance-popover button {
  align-items: center;
  background: var(--epub-control);
  border: 1px solid var(--epub-line);
  color: var(--epub-ink);
  display: inline-flex;
  font: inherit;
  justify-content: center;
}

.epub-pill-button {
  border-radius: 999px;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 650;
  min-height: 34px;
  padding: 0 12px;
}

.epub-pill-button.active,
.epub-appearance-popover button.active,
.epub-appearance-popover button[aria-pressed="true"] {
  background: var(--epub-ink);
  border-color: var(--epub-ink);
  color: var(--epub-page);
}

.epub-workspace {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  min-height: 0;
  min-width: 0;
  padding: 18px;
  position: relative;
}

.epub-page-surface {
  background: var(--epub-page);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#epubFrame {
  height: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  scrollbar-color: color-mix(in srgb, var(--epub-ink) 24%, transparent) transparent;
  scrollbar-width: thin;
  touch-action: none;
}

.epub-reader[data-reading-mode="paged-scroll"] #epubFrame,
.epub-reader[data-reading-mode="paginated"] #epubFrame {
  cursor: default;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}

.epub-reader[data-reading-mode="paginated"] #epubFrame,
.epub-reader[data-reading-mode="paginated"] .epub-container {
  overflow: hidden !important;
}

.epub-workspace-native {
  grid-template-columns: minmax(0, 1fr);
  padding: clamp(10px, 2.5vw, 22px);
}

.epub-paged-scroll-hint {
  animation: epub-hint-fade 5s ease 1.8s forwards;
  background: color-mix(in srgb, var(--epub-page) 82%, var(--epub-ink) 18%);
  border: 1px solid color-mix(in srgb, var(--epub-ink) 12%, transparent);
  border-radius: 999px;
  bottom: clamp(12px, 2.5vw, 20px);
  color: var(--epub-muted);
  font-size: 0.74rem;
  left: 50%;
  letter-spacing: 0.01em;
  margin: 0;
  opacity: 0.82;
  padding: 6px 11px;
  pointer-events: none;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  z-index: 3;
}

@keyframes epub-hint-fade {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.epub-scroll-document {
  box-sizing: border-box;
  color: var(--epub-body);
  font-family: var(--epub-content-font, Georgia, Cambria, "Times New Roman", serif);
  font-size: var(--reader-size);
  line-height: var(--epub-content-line-height, 1.74);
  margin: 0 auto;
  max-width: var(--epub-content-width, 760px);
  min-height: 100%;
  overflow-wrap: break-word;
  padding: clamp(34px, 7vw, 78px) clamp(22px, 6vw, 70px);
  text-rendering: optimizeLegibility;
  width: 100%;
}

.epub-scroll-document * {
  max-width: 100%;
}

.epub-scroll-document h1,
.epub-scroll-document h2,
.epub-scroll-document h3 {
  color: var(--epub-ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  line-height: 1.14;
}

.epub-scroll-document h1 {
  font-size: min(calc(var(--reader-size) + 14px), 38px);
}

.epub-scroll-document p {
  color: var(--epub-body);
  line-height: var(--epub-content-line-height, 1.74);
  margin-bottom: 1.05em;
}

.epub-scroll-document a {
  color: var(--epub-link, var(--accent-blue));
}

.epub-scroll-document img,
.epub-scroll-document svg {
  display: block;
  height: auto;
  margin: 1.5rem auto;
  max-width: 100%;
}

.epub-scroll-section + .epub-scroll-section {
  margin-top: 3rem;
}

.epub-pill-button:hover,
.epub-footer-button:hover,
.epub-appearance-popover button:hover {
  border-color: color-mix(in srgb, var(--epub-ink) 32%, transparent);
  color: var(--epub-ink);
}

.epub-pill-button.active:hover,
.epub-appearance-popover button.active:hover,
.epub-appearance-popover button[aria-pressed="true"]:hover {
  background: var(--epub-ink);
  border-color: var(--epub-ink);
  color: var(--epub-page);
}

.epub-margin-notes {
  border-left: 1px solid var(--epub-line);
  display: grid;
  gap: 18px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  padding-left: 14px;
}

.epub-side-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.epub-side-section + .epub-side-section {
  border-top: 1px solid var(--epub-line);
  padding-top: 16px;
}

.epub-notes-heading,
.epub-notes-empty {
  display: grid;
  gap: 4px;
}

.epub-notes-heading {
  margin-bottom: 10px;
}

.epub-notes-heading strong,
.epub-notes-empty strong {
  color: var(--epub-ink);
  font-size: 13px;
}

.epub-chapter-list {
  display: grid;
  gap: 7px;
}

.epub-chapter-card {
  background: transparent;
  border: 1px solid var(--epub-line);
  border-radius: 8px;
  color: var(--epub-body);
  display: block;
  min-width: 0;
  padding: 9px 10px;
  text-align: left;
}

.epub-chapter-card span {
  display: -webkit-box;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.epub-chapter-card:hover,
.epub-chapter-card.active,
.epub-note-card:hover {
  background: var(--epub-control);
  border-color: color-mix(in srgb, var(--epub-ink) 28%, transparent);
  color: var(--epub-ink);
}

.epub-note-list {
  display: grid;
  gap: 8px;
}

.epub-note-card {
  background: transparent;
  border: 1px solid var(--epub-line);
  border-radius: 8px;
  color: var(--epub-body);
  display: grid;
  gap: 7px;
  grid-template-columns: 4px minmax(0, 1fr);
  padding: 10px;
  text-align: left;
}

.epub-note-card span {
  background: var(--highlight-color, var(--accent-yellow));
  border-radius: 999px;
  grid-row: 1 / span 2;
  width: 4px;
}

.epub-note-card strong {
  display: -webkit-box;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.epub-note-card small {
  color: var(--epub-muted);
}

.epub-notes-empty {
  border: 1px dashed var(--epub-line);
  border-radius: 8px;
  color: var(--epub-muted);
  padding: 12px;
}

.epub-footer {
  border-top: 1px solid var(--epub-line);
}

.epub-footer-button {
  border-radius: 8px;
  flex: 0 0 42px;
  font-size: 14px;
  font-weight: 700;
  height: 38px;
}

.epub-progress-wrap {
  flex: 1;
  min-width: 0;
}

.epub-progress-meta {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.epub-progress-meta span:first-child {
  color: var(--epub-ink);
}

.epub-progress-track {
  background: var(--epub-control);
  border-radius: 999px;
  height: 4px;
  overflow: hidden;
}

.epub-progress-track span {
  background: var(--epub-ink);
  border-radius: inherit;
  display: block;
  height: 100%;
  width: 0%;
}

.epub-appearance-popover,
.epub-contents-popover {
  background: color-mix(in srgb, var(--epub-shell) 95%, transparent);
  border: 1px solid var(--epub-line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  color: var(--epub-ink);
  display: grid;
  gap: 13px;
  padding: 14px;
  position: absolute;
  right: 18px;
  top: 58px;
  width: min(330px, calc(100% - 36px));
  z-index: 20;
}

.epub-contents-popover {
  max-height: min(66vh, 560px);
  overflow: auto;
}

.epub-appearance-popover section {
  display: grid;
  gap: 8px;
}

.epub-appearance-popover h3 {
  color: var(--epub-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
}

.epub-segmented {
  background: var(--epub-control);
  border: 1px solid var(--epub-line);
  display: grid;
  gap: 4px;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding: 4px;
}

.epub-segmented button {
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  min-height: 32px;
  padding: 0 8px;
}

.reader-notice {
  background: var(--accent-blue-soft);
  border: 1px solid rgba(87, 193, 255, 0.28);
  border-radius: 8px;
  color: var(--accent-blue);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 auto 12px;
  max-width: 820px;
  padding: 10px 12px;
}

.highlights-panel {
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-top: 1px solid var(--hairline);
  display: none;
  max-height: 28vh;
  overflow: auto;
  padding: 14px 24px max(16px, env(safe-area-inset-bottom));
}

body.reader-document .highlights-panel {
  display: block;
}

.highlights-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  margin-top: 10px;
  min-width: 0;
}

.highlight-card {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  padding: 12px;
}

.highlight-card {
  border-left: 4px solid var(--highlight-color, var(--accent-yellow));
}

.highlight-card.selection-mode {
  grid-template-columns: auto minmax(0, 1fr);
}

.highlight-checkbox {
  accent-color: var(--accent-yellow);
  display: none;
  margin-top: 2px;
}

.selection-mode .highlight-checkbox {
  display: block;
}

.highlight-card p {
  color: var(--body);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.highlight-card footer {
  align-items: center;
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: space-between;
}

.highlight-card time {
  color: var(--mute);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  line-height: 1.5;
}

.all-highlights-view {
  margin: 0 auto;
  max-width: 1120px;
  min-width: 0;
  width: 100%;
}

.view-heading {
  margin-bottom: 24px;
  max-width: 720px;
}

.view-heading h2 {
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 12px;
}

.view-heading p:not(.eyebrow) {
  color: var(--body);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 0;
}

.all-highlights-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  min-width: 0;
}

.all-highlight-card,
.empty-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  min-width: 0;
  padding: 16px;
}

.highlight-swatch {
  background: color-mix(in srgb, var(--highlight-color) 24%, transparent);
  border-color: color-mix(in srgb, var(--highlight-color) 50%, transparent);
  color: var(--ink);
}

.highlight-source {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 36px minmax(0, 1fr);
  margin-bottom: 14px;
  min-width: 0;
}

.all-highlight-card.selection-mode .highlight-source {
  grid-template-columns: auto 36px minmax(0, 1fr);
}

.all-highlight-card p,
.empty-panel {
  color: var(--body);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.empty-panel strong {
  color: var(--ink);
  display: block;
  font-size: 17px;
  line-height: 1.35;
  margin-bottom: 4px;
}

.empty-reading-panel {
  display: grid;
  gap: 12px;
}

.empty-reading-panel span {
  display: block;
}

.empty-reading-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.empty-reading-actions .primary-button,
.empty-reading-actions .secondary-button {
  min-height: 40px;
}

@media (max-width: 640px) {
  .empty-reading-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

.open-highlight-source {
  margin-top: 10px;
}

.highlight-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 10px;
  min-width: 0;
}

/* Read-it-later design-system refinement layer. */
button:focus-visible,
label:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(109, 126, 236, 0.16);
}

button,
.primary-button,
.secondary-button,
.text-button,
.icon-button,
.tab,
.view-button,
.type-filter-button,
.type-filter-option,
.library-row,
.library-row-menu,
.highlight-card,
.all-highlight-card,
.settings-card,
.upload-panel,
.upload-drop {
  transition: background var(--motion-normal) var(--motion-ease), border-color var(--motion-normal) var(--motion-ease), color var(--motion-normal) var(--motion-ease), box-shadow var(--motion-normal) var(--motion-ease), transform var(--motion-normal) var(--motion-ease);
}

.app-shell {
  background: radial-gradient(circle at 18% 0%, rgba(109, 126, 236, 0.08), transparent 36%), var(--bg-base);
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-base) 94%, white 6%), var(--bg-base));
  border-right: 1px solid var(--border-subtle);
  gap: var(--space-4);
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-5) var(--space-5);
}

.reader-panel,
.reader-stage {
  background: var(--bg-reader);
}

.reader-topbar {
  background: color-mix(in srgb, var(--bg-reader) 82%, transparent);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.18);
}

.view-button {
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  min-height: 56px;
}

.view-button.active,
.view-button:hover {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
}

.primary-button {
  background: var(--accent-primary);
  border-radius: var(--radius-pill);
  color: var(--text-inverse);
  min-height: 44px;
}

.primary-button:hover {
  background: var(--accent-primary-hover);
  color: #fff;
}

.primary-button:active {
  background: var(--accent-primary-active);
  color: #fff;
}

.secondary-button,
.icon-button {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  min-height: 40px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.text-button {
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  min-height: 40px;
}

.text-button.danger,
.secondary-button.danger,
.library-row-menu-item.danger {
  color: var(--status-error);
}

.settings-input,
.url-import input,
.auth-form input,
.copy-fallback-panel textarea {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  min-height: 44px;
}

.upload-panel,
.settings-card,
.empty-panel,
.all-highlight-card,
.highlight-card,
.command-preview,
.auth-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.upload-drop,
.segmented-control,
.setting-toggle,
.email-display,
.type-filter-button,
.type-filter-menu,
.library-row-menu {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  border-radius: var(--radius-lg);
}

.theme-option,
.auth-tab,
.type-filter-option,
.library-row-menu-item {
  border-radius: var(--radius-md);
}

.theme-option.active,
.auth-tab.active,
.type-filter-option.active,
.type-filter-option:hover,
.library-row-menu-item:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.type-filter-option {
  min-height: 44px;
}

.type-filter-option.active::after {
  color: var(--accent-primary);
}

.library-heading {
  border-bottom-color: var(--border-subtle);
  margin-bottom: var(--space-5);
}

.library-heading h2,
.view-heading h2 {
  color: var(--text-primary);
  letter-spacing: -0.035em;
}

.library-grid {
  gap: var(--space-4);
}

.library-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
}

.library-row:hover {
  background: color-mix(in srgb, var(--bg-surface) 88%, white 12%);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.library-row-open {
  gap: var(--space-3);
  grid-template-columns: 9px minmax(0, 1fr) 92px;
  padding: var(--space-5) 54px var(--space-5) var(--space-5);
}

.library-row-copy strong {
  color: var(--text-primary);
  font-size: var(--font-xl);
  letter-spacing: -0.02em;
}

.library-row.unread .library-row-copy strong,
.library-row:has(.library-row-unread.visible) .library-row-copy strong {
  font-weight: 800;
}

.library-row-kicker,
.library-row-meta {
  color: var(--text-muted);
}

.library-row-excerpt {
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: var(--space-2);
}

.library-row-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.library-row-chip,
.preview-chip {
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  display: inline-flex;
  font-size: var(--font-xs);
  font-weight: 700;
  min-height: 28px;
  padding: 0 var(--space-3);
}

.library-row-thumbnail {
  border-radius: var(--radius-lg);
  height: 92px;
  width: 92px;
}

.library-row-menu {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.38);
}

.library-row-progress {
  background: color-mix(in srgb, var(--bg-surface-elevated) 70%, transparent);
  height: 3px;
}

.library-row-progress span {
  background: color-mix(in srgb, var(--type-accent) 66%, var(--text-muted));
}

.article-reader {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  max-width: 720px;
  padding: clamp(var(--space-6), 7vw, var(--space-8)) 0 calc(clamp(var(--space-6), 7vw, var(--space-8)) + 92px);
}

.article-meta {
  color: var(--text-muted);
  font-size: var(--font-sm);
  letter-spacing: 0.01em;
}

.article-body {
  color: var(--text-secondary);
  font-size: var(--reader-size);
  line-height: var(--reader-line-height);
}

.article-body h1,
.article-body h2,
.article-body h3 {
  color: var(--text-primary);
}

body.reader-document .reader-stage {
  background: var(--bg-reader);
}

.epub-reader {
  --epub-shell: var(--bg-reader);
  --epub-page: color-mix(in srgb, var(--bg-surface) 68%, var(--bg-reader));
  --epub-ink: var(--text-primary);
  --epub-body: var(--text-secondary);
  --epub-muted: var(--text-muted);
  --epub-line: var(--border-subtle);
  --epub-control: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.epub-page-surface {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.epub-reading-bar,
.epub-footer {
  background: color-mix(in srgb, var(--bg-reader) 88%, transparent);
}

.epub-appearance-popover,
.epub-contents-popover,
.highlight-popover,
.copy-fallback-panel {
  border-radius: var(--radius-xl);
}

.epub-segmented,
.epub-chapter-card,
.epub-note-card,
.epub-notes-empty,
.epub-footer-button {
  border-radius: var(--radius-md);
}

.highlights-panel {
  background: color-mix(in srgb, var(--bg-reader) 90%, transparent);
  border-top: 1px solid var(--border-subtle);
}

.highlight-card {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  border-left: 4px solid var(--highlight-color, var(--status-warning));
  border-radius: var(--radius-lg);
}

.highlight-card p,
.all-highlight-card p {
  color: color-mix(in srgb, var(--text-secondary) 82%, var(--status-warning) 18%);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: var(--font-md);
  line-height: 1.65;
}

.all-highlights-grid {
  gap: var(--space-4);
}

.all-highlight-card {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
}

.highlight-source {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-3);
}

.settings-view,
.all-highlights-view,
.home-library-view {
  width: 100%;
}

.settings-card {
  padding: var(--space-5);
}

.diagnostics-view {
  width: 100%;
}

.diagnostics-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: var(--space-5);
}

.diagnostics-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.diagnostics-card span,
.diagnostics-row small {
  color: var(--text-muted);
  display: block;
  font-size: var(--font-sm);
  text-transform: capitalize;
}

.diagnostics-card strong {
  color: var(--text-primary);
  display: block;
  font-size: 28px;
  margin-top: var(--space-2);
}

.diagnostics-section-heading,
.diagnostics-row {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
}

.diagnostics-list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.diagnostics-row {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.diagnostics-row code {
  color: #ffd27a;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

.mobile-only {
  display: none;
}

@media (max-width: 1180px) {
  .epub-reading-bar {
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
  }

  .epub-reading-actions {
    justify-content: start;
  }

  .epub-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .epub-margin-notes {
    display: none;
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    background: color-mix(in srgb, var(--canvas) 78%, transparent);
    backdrop-filter: blur(28px) saturate(1.35);
    border-right: 1px solid var(--hairline-strong);
    gap: clamp(10px, 1.7vh, 16px);
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    left: 0;
    max-height: 100vh;
    max-height: 100svh;
    max-height: 100dvh;
    max-width: min(88vw, 380px);
    overflow-y: auto;
    padding: max(18px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
    position: fixed;
    box-shadow: 24px 0 80px rgba(0, 0, 0, 0.18);
    top: 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    width: 100%;
    z-index: 1000;
  }

  .sidebar .brand-row {
    order: 1;
    flex: 0 0 auto;
  }

  .sidebar .view-nav {
    order: 2;
    flex: 0 0 auto;
  }

  .sidebar .upload-panel {
    order: 4;
    flex: 0 1 auto;
    max-height: max(132px, min(24svh, 210px));
    overflow-y: auto;
  }

  .sidebar-utility-nav {
    background: color-mix(in srgb, var(--canvas) 88%, transparent);
    border-bottom: 1px solid var(--hairline);
    border-top: 0;
    flex: 0 0 auto;
    margin-top: 0;
    order: 3;
    padding-bottom: clamp(10px, 1.4vh, 14px);
    padding-top: 0;
    position: static;
    z-index: 1;
  }

  .sidebar .view-button {
    min-height: clamp(46px, 7.4vh, 58px);
    padding: 7px 10px 7px 8px;
  }

  .sidebar .view-button small {
    font-size: 11px;
    line-height: 1.35;
    margin-top: 1px;
  }

  .sidebar .upload-panel .upload-drop {
    min-height: 48px;
  }

  .sidebar .sample-actions {
    grid-template-columns: 1fr 1fr;
  }

  :root[data-theme="light"] .sidebar {
    background: rgba(247, 247, 244, 0.76);
    box-shadow: 24px 0 80px rgba(30, 32, 36, 0.12);
  }

  body.panel-open .sidebar {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .reader-topbar {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: auto minmax(0, 1fr);
    padding-left: 12px;
    padding-right: 12px;
  }

  .reader-actions {
    gap: 6px;
    grid-column: 1 / -1;
    justify-content: start;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .reader-actions::-webkit-scrollbar {
    display: none;
  }

  .reader-actions .primary-button,
  .reader-actions .secondary-button {
    flex: 0 0 auto;
  }

  .reader-actions .icon-button {
    display: none;
  }

  .reader-stage {
    max-width: 100vw;
    overflow-x: hidden;
    padding: 24px 12px;
  }

  body.reader-document[data-reader-format="epub"] .reader-panel {
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.reader-document[data-reader-format="epub"] .reader-topbar {
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }

  body.reader-document[data-reader-format="epub"] .reader-title-block p {
    display: none;
  }

  body.reader-document[data-reader-format="epub"] .reader-title-block h2 {
    font-size: 15px;
    line-height: 1.2;
  }

  body.reader-document[data-reader-format="epub"] .reader-actions {
    display: none;
  }

  body.reader-document[data-reader-format="epub"] .reader-stage {
    background: var(--surface);
    padding: 0;
  }

  body.reader-document[data-reader-format="article"] .reader-topbar {
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }

  body.reader-document[data-reader-format="newsletter"] .reader-topbar {
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }

  body.reader-document[data-reader-format="article"] .reader-title-block p,
  body.reader-document[data-reader-format="newsletter"] .reader-title-block p {
    display: none;
  }

  body.reader-document[data-reader-format="article"] .reader-title-block h2,
  body.reader-document[data-reader-format="newsletter"] .reader-title-block h2 {
    font-size: 15px;
    line-height: 1.2;
  }

  body.reader-document[data-reader-format="article"] .reader-actions,
  body.reader-document[data-reader-format="newsletter"] .reader-actions {
    display: none;
  }

  body.reader-document[data-reader-format="article"] .reader-stage,
  body.reader-document[data-reader-format="newsletter"] .reader-stage {
    padding: 0 max(14px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-bottom));
  }

  body.reader-document[data-reader-format="epub"] .highlights-panel {
    display: none;
  }

  .empty-state {
    align-items: start;
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .library-heading {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .library-stats {
    display: none;
  }

  .library-filter-control {
    width: 100%;
  }

  .type-filter-menu {
    min-width: 100%;
  }

  .empty-copy h2 {
    font-size: clamp(38px, 12vw, 56px);
  }

  .command-preview {
    border-radius: 12px;
  }

    .article-reader {
      background: transparent;
      border: 0;
      border-left: 0;
      border-radius: 0;
      border-right: 0;
      box-shadow: none;
      min-height: 72vh;
      padding: 22px 4px max(32px, env(safe-area-inset-bottom));
    }

    .article-body {
      font-size: min(var(--reader-size), 20px);
      line-height: 1.68;
    }

    .article-reader.reader-text-large .article-body {
      font-size: 20px;
    }

    .reader-comfort-bar,
    .reader-trust-details {
      margin-left: 0;
      margin-right: 0;
    }

    .reader-comfort-group {
      grid-template-columns: 1fr;
    }

  .epub-reader,
  .pdf-reader {
    border-left: 0;
    border-radius: 0;
    border-right: 0;
    height: 72vh;
  }

  body.reader-document[data-reader-format="epub"] .epub-reader {
    border: 0;
    height: 100%;
    margin: 0;
    max-width: 100vw;
    min-height: 0;
    width: 100%;
  }

  body.reader-document[data-reader-format="epub"] .epub-workspace {
    gap: 0;
    grid-template-columns: minmax(0, 1fr);
    padding: 0;
  }

  body.reader-document[data-reader-format="epub"] .epub-page-surface {
    box-shadow: none;
  }

  body.reader-document[data-reader-format="epub"] .epub-margin-notes {
    display: none;
  }

  body.reader-document[data-reader-format="epub"] .reader-notice {
    border-radius: 0;
    margin: 0;
    max-width: none;
  }

  body.reader-document[data-reader-format="epub"] #epubFrame {
    height: 100%;
  }

  body.reader-document[data-reader-format="epub"] .epub-scroll-document {
    margin: 0 auto;
    max-width: var(--epub-content-width, 760px);
    padding: 28px clamp(18px, 5vw, 32px) 88px;
  }

  body.reader-document[data-reader-format="epub"] .epub-reading-bar {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 12px;
  }

  body.reader-document[data-reader-format="epub"] .epub-current-location span {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.reader-document[data-reader-format="epub"] .epub-reading-actions {
    justify-content: end;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  body.reader-document[data-reader-format="epub"] .epub-reading-actions::-webkit-scrollbar {
    display: none;
  }

  body.reader-document[data-reader-format="epub"] .epub-pill-button {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 10px;
  }

  body.reader-document[data-reader-format="epub"] .epub-footer {
    gap: 10px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  }

  body.reader-document[data-reader-format="epub"] .epub-footer-button {
    flex-basis: 34px;
    height: 34px;
  }

  body.reader-document[data-reader-format="epub"] .epub-progress-meta {
    margin-bottom: 3px;
  }

  body.reader-document[data-reader-format="epub"] .epub-progress-wrap {
    min-width: 0;
  }

  #epubProgressContext {
    display: none;
  }

  .highlights-panel {
    max-height: 30vh;
    overflow-x: hidden;
    padding-left: 12px;
    padding-right: 12px;
  }

  .highlight-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .highlight-actions .secondary-button,
  .highlight-actions .text-button {
    justify-content: center;
    width: 100%;
  }
}

@media (max-width: 430px) {
  .reader-title-block h2 {
    max-width: 100%;
  }

  .reader-stage {
    padding: 12px 8px;
  }

  .article-reader {
    padding: 18px 12px;
  }

  .home-library-view {
    max-width: 100%;
  }

  .library-grid {
    gap: 6px;
  }

  .library-heading h2 {
    font-size: clamp(30px, 10vw, 42px);
    margin-bottom: 6px;
  }

  .library-heading p:not(.eyebrow) {
    display: none;
  }

  .library-row {
    border-left: 0;
    border-radius: 0;
    border-right: 0;
  }

  .library-row-open {
    gap: 8px;
    grid-template-columns: 8px minmax(0, 1fr) 70px;
    padding: 12px 42px 16px 10px;
  }

  .library-row-unread {
    height: 8px;
    margin-top: 28px;
    width: 8px;
  }

  .library-row-kicker {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .library-row-copy strong {
    font-size: 16px;
    line-height: 1.22;
  }

  .library-row-excerpt {
    font-size: 13px;
    line-height: 1.36;
  }

  .library-row-meta {
    font-size: 12px;
    margin-top: 10px;
  }

  .library-row-thumbnail {
    border-radius: 7px;
    height: 70px;
    width: 70px;
  }

  .library-row-menu-wrap {
    right: 6px;
    top: 8px;
  }

  .library-row.selection-mode .library-row-open {
    grid-template-columns: 8px minmax(0, 1fr) 60px;
  }

  .primary-button {
    padding: 0 12px;
  }

  .preview-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .preview-row .preview-chip {
    display: none;
  }

  .forwarding-fields {
    grid-template-columns: 1fr;
  }

  .email-display {
    align-items: stretch;
    flex-direction: column;
  }

  .url-import,
  .sample-actions {
    grid-template-columns: 1fr;
  }

  .library-stats {
    grid-template-columns: 1fr;
  }

}
/* Mobile inbox density pass: treat the library as a reading queue, not a feed. */
@media (max-width: 600px) {
  body:not(.reader-document) .reader-actions {
    display: none;
  }

  body:not(.reader-document) .reader-topbar {
    grid-template-columns: auto minmax(0, 1fr);
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  body:not(.reader-document) .reader-title-block h2 {
    font-size: 16px;
    font-weight: 600;
  }

  body:not(.reader-document) .reader-stage {
    padding: 12px 10px 18px;
  }

  .library-heading {
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .library-heading h2 {
    font-size: clamp(26px, 7vw, 32px);
    letter-spacing: -0.03em;
    margin-bottom: 4px;
  }

  .library-heading p:not(.eyebrow) {
    color: var(--text-muted);
    display: block;
    font-size: 13px;
    line-height: 1.38;
    max-width: 34ch;
  }

  .library-control-row {
    margin-bottom: 10px;
  }

  .type-filter-button {
    min-height: 42px;
    padding: 0 12px;
  }

  .library-bulk-actions {
    margin-bottom: 10px;
  }

  .library-bulk-actions .secondary-button {
    min-height: 36px;
    padding: 0 14px;
  }

  .library-grid {
    gap: 7px;
  }

  .library-row {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: none;
  }

  .library-row:hover {
    transform: none;
  }

  .library-row-open {
    gap: 8px;
    grid-template-columns: 7px minmax(0, 1fr);
    min-height: 64px;
    padding: 10px 38px 10px 10px;
  }

  .library-row-unread {
    height: 7px;
    margin-top: 23px;
    width: 7px;
  }

  .library-row-kicker {
    font-size: 9px;
    gap: 4px;
    letter-spacing: 0.08em;
    margin-bottom: 3px;
  }

  .library-row-copy strong {
    font-size: 15px;
    line-height: 1.24;
    -webkit-line-clamp: 2;
  }

  .library-row-excerpt,
  .library-row-chip-row,
  .library-row-thumbnail {
    display: none;
  }

  .library-row-meta {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 550;
    line-height: 1.3;
    margin-top: 5px;
  }

  .library-row-menu-wrap {
    right: 4px;
    top: 7px;
  }

  .library-row-menu-button {
    color: var(--text-muted);
    height: 40px;
    width: 40px;
  }

  .library-row-progress {
    height: 2px;
  }

  .library-row.selection-mode .document-checkbox {
    margin-left: 10px;
  }

  .library-row.selection-mode .library-row-open {
    grid-template-columns: 7px minmax(0, 1fr);
    padding-left: 4px;
  }
}


/* Imperatr suite Vesta redesign pass */
:root {
  --imperatr-bg: #03060b;
  --imperatr-panel: #071018;
  --imperatr-panel-2: #0b141d;
  --imperatr-line: #1a2632;
  --imperatr-ink: #eef3f7;
  --imperatr-muted: #8d98a5;
  --imperatr-faint: #5f6974;
  --vesta-accent: #d07a2e;
  --vesta-accent-bright: #f0b276;
  --vesta-accent-soft: rgba(208, 122, 46, 0.15);
  --vesta-bookplate-line: rgba(240, 178, 118, 0.20);
  --vesta-serif: Georgia, "Times New Roman", serif;
}

body:not(.reader-document) {
  background:
    radial-gradient(900px 460px at 8% 94%, rgba(55, 86, 128, 0.26), transparent 58%),
    radial-gradient(650px 380px at 52% 0%, rgba(208, 122, 46, 0.13), transparent 58%),
    linear-gradient(180deg, #02050a, #050912 55%, #020409);
}

body:not(.reader-document) .app-shell {
  background: transparent;
}

body:not(.reader-document) .sidebar {
  background: linear-gradient(180deg, rgba(7, 16, 24, 0.96), rgba(3, 6, 11, 0.98));
  border-right: 1px solid var(--imperatr-line);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.025), 18px 0 50px rgba(0, 0, 0, 0.18);
}

body:not(.reader-document) .brand-row {
  border-bottom: 1px solid var(--imperatr-line);
  padding-bottom: 14px;
}

body:not(.reader-document) .brand-home h1 {
  color: #f3e1ca;
  font-family: var(--vesta-serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

body:not(.reader-document) .brand-row .eyebrow,
body:not(.reader-document) .reader-title-block p,
body:not(.reader-document) .library-heading .eyebrow {
  color: var(--vesta-accent-bright);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

body:not(.reader-document) .brand-mark {
  background: linear-gradient(145deg, #111923, #05080e 45%, #020408);
  border-color: rgba(240, 178, 118, 0.26);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 12px 28px rgba(0, 0, 0, 0.24);
}

body:not(.reader-document) .view-button {
  border-radius: 14px;
  color: var(--imperatr-muted);
  min-height: 54px;
}

body:not(.reader-document) .view-button.active,
body:not(.reader-document) .view-button:hover {
  background: rgba(11, 20, 29, 0.86);
  border-color: rgba(255, 255, 255, 0.06);
}

body:not(.reader-document) .view-button.active {
  box-shadow: inset 0 0 0 1px rgba(240, 178, 118, 0.08);
}

body:not(.reader-document) .view-home,
body:not(.reader-document) .view-archive {
  --view-accent: var(--vesta-accent);
}

body:not(.reader-document) .view-button strong {
  color: var(--imperatr-ink);
  font-weight: 650;
}

body:not(.reader-document) .view-button small {
  color: var(--imperatr-muted);
}

body:not(.reader-document) .upload-panel,
body:not(.reader-document) .reader-topbar,
body:not(.reader-document) .library-heading,
body:not(.reader-document) .type-filter-button,
body:not(.reader-document) .type-filter-menu,
body:not(.reader-document) .library-search-input-wrap,
body:not(.reader-document) .library-bulk-actions .secondary-button,
body:not(.reader-document) .library-bulk-actions .text-button {
  background: rgba(7, 16, 24, 0.94);
  border-color: rgba(243, 225, 202, 0.18);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

body:not(.reader-document) .reader-panel {
  background: transparent;
}

body:not(.reader-document) .reader-stage {
  background:
    radial-gradient(480px 260px at 18% 0%, rgba(208, 122, 46, 0.09), transparent 70%),
    linear-gradient(180deg, rgba(5, 10, 17, 0.94), rgba(3, 6, 11, 0.98));
}

body:not(.reader-document) .home-library-view {
  max-width: 980px;
}

body:not(.reader-document) .library-heading {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
  margin-bottom: 14px;
  padding: 16px;
}

body:not(.reader-document) .library-heading h2 {
  color: #f3e1ca;
  font-family: var(--vesta-serif);
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 400;
  letter-spacing: -0.035em;
}

body:not(.reader-document) .library-heading p:not(.eyebrow) {
  color: var(--imperatr-muted);
}

body:not(.reader-document) .library-heading-count {
  color: var(--vesta-accent-bright);
  font-family: var(--font);
  font-size: 0.5em;
  letter-spacing: 0;
}

body:not(.reader-document) .type-filter-button,
body:not(.reader-document) .library-search-input-wrap,
body:not(.reader-document) .secondary-button,
body:not(.reader-document) .icon-button,
body:not(.reader-document) .settings-input {
  border-radius: 12px;
}

body:not(.reader-document) .type-filter-label,
body:not(.reader-document) .type-filter-count,
body:not(.reader-document) .type-filter-chevron,
body:not(.reader-document) .library-search-clear {
  color: var(--vesta-accent-bright);
}

body:not(.reader-document) .type-filter-menu {
  backdrop-filter: blur(22px) saturate(1.25);
}

body:not(.reader-document) .type-filter-option:hover,
body:not(.reader-document) .type-filter-option.active {
  background: rgba(240, 178, 118, 0.16);
  color: #fff6e8;
}

body:not(.reader-document) .type-filter-option.active::after,
body:not(.reader-document) .primary-button {
  color: #111114;
}

body:not(.reader-document) .primary-button {
  background: linear-gradient(180deg, #f0b276, #d07a2e);
  border-color: rgba(240, 178, 118, 0.42);
}

body:not(.reader-document) .auth-tab.active {
  background: linear-gradient(180deg, rgba(240, 178, 118, 0.18), rgba(208, 122, 46, 0.10));
  box-shadow: inset 0 0 0 1px rgba(240, 178, 118, 0.24), 0 8px 18px rgba(0, 0, 0, 0.18);
  color: #f3e1ca;
}

body:not(.reader-document) .auth-form .settings-input:-webkit-autofill,
body:not(.reader-document) .auth-form .settings-input:-webkit-autofill:hover,
body:not(.reader-document) .auth-form .settings-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--imperatr-ink);
  caret-color: var(--imperatr-ink);
  box-shadow: 0 0 0 1000px var(--imperatr-panel-2) inset;
  transition: background-color 9999s ease-out;
}

body:not(.reader-document) .auth-password-field:has(.settings-input:-webkit-autofill) {
  background: var(--imperatr-panel-2);
  border-color: rgba(240, 178, 118, 0.22);
}

body:not(.reader-document) .library-grid {
  gap: 8px;
}

body:not(.reader-document) .library-row {
  background: rgba(11, 20, 29, 0.82);
  border-color: rgba(255, 255, 255, 0.055);
  border-radius: 17px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

body:not(.reader-document) .library-row:hover {
  border-color: rgba(240, 178, 118, 0.32);
  transform: translateY(-1px);
}

body:not(.reader-document) .library-row.type-epub,
body:not(.reader-document) .library-row.type-newsletter {
  --type-accent: var(--vesta-accent-bright);
  --type-accent-soft: var(--vesta-accent-soft);
}

body:not(.reader-document) .library-row-open {
  grid-template-columns: 8px minmax(0, 1fr) 68px;
  min-height: 76px;
  padding: 12px 44px 15px 12px;
}

body:not(.reader-document) .library-row-unread.visible {
  background: var(--vesta-accent-bright);
  box-shadow: 0 0 0 5px rgba(240, 178, 118, 0.10);
}

body:not(.reader-document) .library-row-kicker {
  color: var(--vesta-accent-bright);
  font-size: 10px;
}

body:not(.reader-document) .library-row-copy strong {
  color: var(--imperatr-ink);
  font-size: 16px;
  line-height: 1.22;
}

body:not(.reader-document) .library-row-excerpt {
  color: var(--imperatr-muted);
  font-size: 13px;
}

body:not(.reader-document) .library-row-meta,
body:not(.reader-document) .library-row-chip {
  color: var(--imperatr-muted);
}

body:not(.reader-document) .library-row-chip {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.055);
}

body:not(.reader-document) .library-row-thumbnail {
  border-color: rgba(240, 178, 118, 0.22);
  border-radius: 13px;
  color: var(--vesta-accent-bright);
  height: 68px;
  width: 68px;
}

body:not(.reader-document) .library-row-progress span {
  background: linear-gradient(90deg, var(--vesta-accent), var(--vesta-accent-bright));
}

body:not(.reader-document) .reader-topbar {
  border-bottom: 1px solid var(--imperatr-line);
}

@media (max-width: 600px) {
  body:not(.reader-document) .library-heading {
    border-radius: 18px;
    padding: 12px;
  }

  body:not(.reader-document) .library-heading h2 {
    font-size: clamp(27px, 7vw, 34px);
  }

  body:not(.reader-document) .library-row-open {
    grid-template-columns: 7px minmax(0, 1fr);
    min-height: 64px;
    padding: 10px 38px 10px 10px;
  }

  body:not(.reader-document) .library-row-quick-actions {
    display: none;
  }
}


/* Vesta auth first-impression polish: premium private-reader entry. */
body.auth-locked {
  background:
    radial-gradient(540px 320px at 50% 38%, rgba(240, 178, 118, 0.13), transparent 64%),
    radial-gradient(780px 420px at 8% 92%, rgba(44, 68, 99, 0.32), transparent 62%),
    linear-gradient(180deg, #020409, #050912 58%, #020307);
}

body.auth-locked::before {
  background-image:
    radial-gradient(circle at center, rgba(240, 178, 118, 0.14) 0 1px, transparent 1.5px),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-position: center, 0 0, 0 0;
  background-size: 132px 132px, 44px 44px, 44px 44px;
  content: "";
  inset: 0;
  mask-image: radial-gradient(circle at 50% 42%, black, transparent 70%);
  opacity: 0.42;
  pointer-events: none;
  position: fixed;
}

.auth-screen {
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.auth-panel {
  background:
    linear-gradient(180deg, rgba(11, 20, 29, 0.96), rgba(3, 6, 11, 0.98)),
    radial-gradient(380px 160px at 50% 0%, rgba(240, 178, 118, 0.12), transparent 70%);
  border: 1px solid rgba(240, 178, 118, 0.16);
  border-radius: 24px;
  gap: 22px;
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  max-width: 440px;
  padding: 24px 26px;
  position: relative;
}

.auth-panel::before {
  background:
    linear-gradient(90deg, transparent, rgba(240, 178, 118, 0.48), transparent),
    linear-gradient(90deg, var(--vesta-bookplate-line), transparent 18%, transparent 82%, var(--vesta-bookplate-line)),
    linear-gradient(180deg, var(--vesta-bookplate-line), transparent 16%, transparent 84%, var(--vesta-bookplate-line));
  border-radius: 18px;
  content: "";
  inset: 10px;
  opacity: 0.62;
  pointer-events: none;
  position: absolute;
}

.auth-panel::after {
  color: rgba(240, 178, 118, 0.34);
  content: "PRIVATE LIBRARY";
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.24em;
  line-height: 1;
  pointer-events: none;
  position: absolute;
  right: 25px;
  top: 19px;
}

.auth-brand {
  gap: 12px;
  position: relative;
  z-index: 1;
}

.auth-brand h1,
.auth-copy h2 {
  color: #f3e1ca;
  font-family: var(--vesta-serif, Georgia, "Times New Roman", serif);
  font-weight: 400;
}

.auth-brand h1 {
  font-size: 30px;
  letter-spacing: 0.015em;
}

.auth-brand .eyebrow {
  color: var(--vesta-accent-bright, #f0b276);
  font-size: 10.5px;
  letter-spacing: 0.12em;
}

.auth-copy h2 {
  font-size: clamp(34px, 6vw, 44px);
  letter-spacing: -0.045em;
  line-height: 1.04;
  margin-bottom: 12px;
}

.auth-copy p {
  color: rgba(238, 243, 247, 0.84);
  font-size: 15px;
  line-height: 1.55;
}

.auth-copy,
.auth-tabs,
.auth-form,
.auth-message,
.auth-footnote {
  position: relative;
  z-index: 1;
}

.auth-trust {
  border-left: 2px solid rgba(240, 178, 118, 0.45);
  color: rgba(247, 199, 151, 0.94) !important;
  font-size: 12px !important;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 12px;
  padding-left: 10px;
}

.auth-tabs {
  background: rgba(3, 6, 11, 0.38);
  border-color: rgba(240, 178, 118, 0.09);
  border-radius: 14px;
  padding: 3px;
}

.auth-tab {
  border-radius: 11px;
  box-shadow: inset 0 0 0 1px rgba(238, 243, 247, 0.035);
  color: rgba(238, 243, 247, 0.86);
  font-weight: 750;
  min-height: 44px;
}

.auth-tab:not(.active):hover,
.auth-tab:not(.active):focus-visible {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(240, 178, 118, 0.16);
  color: rgba(255, 247, 238, 0.96);
}

.auth-tab.active {
  background: rgba(240, 178, 118, 0.12);
  box-shadow: inset 0 0 0 1px rgba(240, 178, 118, 0.16);
  color: #f3e1ca;
}

.auth-form .field-label {
  color: rgba(238, 243, 247, 0.84);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.auth-form .settings-input {
  background: rgba(3, 6, 11, 0.42);
  border-color: rgba(240, 178, 118, 0.12);
  border-radius: 13px;
  color: #eef3f7;
}

.auth-form .settings-input::placeholder {
  color: rgba(195, 203, 212, 0.82);
}

.auth-form .auth-password-field {
  background: rgba(3, 6, 11, 0.42);
  border-color: rgba(240, 178, 118, 0.12);
  border-radius: 13px;
}

.auth-form .auth-password-field .settings-input {
  background: transparent;
  border: 0;
  border-radius: 0;
}

.auth-form .auth-password-field .settings-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.auth-form .auth-password-field:focus-within {
  border-color: rgba(240, 178, 118, 0.50);
  box-shadow: 0 0 0 3px rgba(240, 178, 118, 0.11);
}

.auth-form .auth-password-toggle {
  border-left-color: rgba(240, 178, 118, 0.09);
  color: #f0b276;
  min-height: 44px;
  min-width: 76px;
}

.auth-form .auth-password-toggle:hover,
.auth-form .auth-password-toggle:focus-visible {
  background: rgba(240, 178, 118, 0.12);
  color: #fff7ee;
}

/* Auth entry spacing polish: keep account setup connected, legible, and reader-quiet. */
/* Imperatr auth bookplate pass: private-library ritual without touching reader documents. */
.auth-panel .auth-form {
  gap: 10px;
}

.auth-panel > .auth-message {
  margin-top: 2px;
  min-height: 18px;
}

.auth-panel > .auth-message.error {
  background: rgba(239, 64, 86, 0.10);
  border: 1px solid rgba(239, 64, 86, 0.34);
  border-radius: 12px;
  color: #ffd6dc;
  padding: 9px 11px;
}

.auth-panel .auth-password-hint {
  color: rgba(238, 243, 247, 0.76);
  font-size: 12px;
  line-height: 1.35;
  margin: -2px 2px 2px;
}

.auth-panel > .auth-footnote {
  background:
    linear-gradient(135deg, rgba(240, 178, 118, 0.07), rgba(3, 6, 11, 0.32));
  border: 1px solid rgba(240, 178, 118, 0.16);
  border-radius: 15px;
  color: rgba(238, 243, 247, 0.90);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
  padding: 12px 13px 12px 40px;
  position: relative;
}

.auth-panel > .auth-footnote::before {
  color: var(--vesta-accent-bright, #f0b276);
  content: "Private sync";
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.auth-panel > .auth-footnote::after {
  align-items: center;
  background: rgba(240, 178, 118, 0.10);
  border: 1px solid rgba(240, 178, 118, 0.16);
  border-radius: 999px;
  color: #f0b276;
  content: "V";
  display: flex;
  font-family: var(--vesta-serif, Georgia, "Times New Roman", serif);
  font-size: 13px;
  height: 20px;
  justify-content: center;
  left: 12px;
  position: absolute;
  top: 13px;
  width: 20px;
}

body:not(.reader-document) .auth-tab.active {
  background: linear-gradient(180deg, rgba(240, 178, 118, 0.24), rgba(208, 122, 46, 0.14));
  box-shadow:
    inset 0 0 0 1px rgba(240, 178, 118, 0.34),
    0 10px 22px rgba(0, 0, 0, 0.22);
  color: #fff1df;
}

.auth-form .settings-input:focus {
  border-color: rgba(240, 178, 118, 0.50);
  box-shadow: 0 0 0 3px rgba(240, 178, 118, 0.11);
}

.auth-form .settings-input[aria-invalid="true"] {
  border-color: rgba(239, 64, 86, 0.72);
  box-shadow: 0 0 0 3px rgba(239, 64, 86, 0.14);
}

.auth-form .auth-password-field:has(.settings-input[aria-invalid="true"]) {
  border-color: rgba(239, 64, 86, 0.72);
  box-shadow: 0 0 0 3px rgba(239, 64, 86, 0.14);
}

.auth-form .settings-input[aria-invalid="true"]::placeholder {
  color: rgba(255, 188, 197, 0.82);
}

.auth-submit.primary-button {
  background: linear-gradient(180deg, #f0b276, #c56f28);
  border-color: rgba(240, 178, 118, 0.38);
  border-radius: 13px;
  box-shadow: 0 16px 38px rgba(208, 122, 46, 0.18);
  color: #14100b;
  font-weight: 850;
}

@media (max-width: 480px) {
  .auth-panel {
    border-radius: 22px;
    padding: 21px;
  }

  .auth-copy h2 {
    font-size: clamp(31px, 10vw, 39px);
    line-height: 1.08;
  }
}

@media (max-width: 600px), (max-height: 720px) {
  .auth-screen {
    align-items: start;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    overflow-y: auto;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .auth-panel {
    gap: 12px;
    margin-bottom: max(28px, env(safe-area-inset-bottom));
    margin-top: 0;
    padding: 16px;
  }

  .auth-copy h2 {
    font-size: clamp(27px, 8vw, 33px);
    line-height: 1.03;
    margin-bottom: 6px;
  }

  .auth-copy p {
    font-size: 13px;
    line-height: 1.38;
  }

  .auth-trust {
    display: none;
  }

  .auth-panel .auth-form {
    gap: 7px;
  }

  .auth-panel > .auth-message {
    margin-top: 0;
    min-height: 0;
  }

  .auth-panel > .auth-footnote {
    font-size: 11.75px;
    line-height: 1.36;
    margin-top: 0;
    padding: 8px 10px 8px 34px;
  }

  .auth-panel::after {
    display: none;
  }

  .auth-panel > .auth-footnote::after {
    left: 9px;
    top: 10px;
  }

  .auth-submit {
    margin-top: 6px;
    min-height: 48px;
    touch-action: manipulation;
  }
}
