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

:root {
  color-scheme: dark;
  --primary: #ffffff;
  --primary-pressed: #e8e8e8;
  --on-primary: #000000;
  --ink: #f4f4f6;
  --body: #cdcdcd;
  --mute: #9c9c9d;
  --ash: #6a6b6c;
  --stone: #434345;
  --canvas: #000000;
  --surface: #0d0d0d;
  --surface-elevated: #101111;
  --surface-card: #121212;
  --button-fg: #18191a;
  --hairline: #242728;
  --hairline-soft: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --accent-blue: #57c1ff;
  --accent-blue-soft: rgba(87, 193, 255, 0.15);
  --accent-red: #ff6161;
  --accent-red-soft: rgba(255, 97, 97, 0.15);
  --accent-green: #59d499;
  --accent-green-soft: rgba(89, 212, 153, 0.15);
  --accent-yellow: #ffc533;
  --accent-yellow-soft: rgba(255, 197, 51, 0.15);
  --glow-red: #b71f29;
  --glow-red-soft: rgba(255, 87, 87, 0.22);
  --reader-size: 18px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font);
  font-feature-settings: "calt", "kern", "liga", "ss03";
}

:root[data-theme="light"] {
  color-scheme: light;
  --primary: #111214;
  --primary-pressed: #2b2d30;
  --on-primary: #ffffff;
  --ink: #111214;
  --body: #383a3d;
  --mute: #6f7378;
  --ash: #8f9499;
  --stone: #c9ced3;
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-elevated: #f0f1ee;
  --surface-card: #e8e9e4;
  --button-fg: #e4e5e0;
  --hairline: #d9dcd7;
  --hairline-soft: rgba(17, 18, 20, 0.08);
  --hairline-strong: rgba(17, 18, 20, 0.16);
}

* {
  box-sizing: border-box;
}

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

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

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

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-message {
  min-height: 22px;
}

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

.sidebar {
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
  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;
}

.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;
}

.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-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
}

.reader-topbar {
  background: var(--canvas);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--hairline);
  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;
}

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

.reader-stage {
  overflow: auto;
  padding: 42px clamp(18px, 4vw, 56px);
}

.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 p:not(.eyebrow) {
  color: var(--body);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 0;
  max-width: 620px;
}

.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-filter-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

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

.filter-chip {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--body);
  display: inline-flex;
  font-size: 14px;
  font-weight: 600;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
}

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

.filter-chip span {
  color: var(--mute);
  font-size: 12px;
  font-weight: 700;
}

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

.library-card {
  --type-accent: var(--accent-blue);
  --type-accent-soft: var(--accent-blue-soft);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

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

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

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

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

.library-card-main {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

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

.library-card-open {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 12px;
  grid-template-columns: 48px minmax(0, 1fr);
  padding: 0;
  text-align: left;
  width: 100%;
}

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

.library-card.selection-mode .document-checkbox {
  display: block;
}

.library-card-type {
  align-items: center;
  background: var(--type-accent-soft);
  border: 1px solid color-mix(in srgb, var(--type-accent) 42%, transparent);
  border-radius: 8px;
  color: var(--type-accent);
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  height: 48px;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1;
  overflow: hidden;
  padding: 0 6px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 48px;
}

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

.library-card-copy strong {
  color: var(--ink);
  display: block;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-card-copy small {
  color: var(--mute);
  display: block;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-progress {
  background: var(--surface-elevated);
  border-radius: 999px;
  height: 3px;
  margin-left: 60px;
  overflow: hidden;
}

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

.library-progress-meta {
  align-items: center;
  color: var(--mute);
  display: flex;
  font-size: 12px;
  font-weight: 600;
  justify-content: space-between;
  line-height: 1.4;
  margin-left: 60px;
  max-width: 760px;
}

.library-card p {
  color: var(--body);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 0 60px;
  max-width: 760px;
}

.library-card.selection-mode p {
  margin-left: 84px;
}

.library-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-left: 60px;
}

.library-card.selection-mode .library-card-actions {
  margin-left: 84px;
}

.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;
  padding: clamp(24px, 6vw, 64px);
}

.article-reader h1 {
  color: var(--ink);
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 14px;
}

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

.article-body {
  color: var(--body);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: var(--reader-size);
  line-height: 1.72;
  outline: none;
}

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

.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);
  padding: 0 0.03em;
}

.highlight-popover {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  padding: 12px;
  position: fixed;
  width: 204px;
  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;
}

.epub-reader,
.pdf-reader {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  height: min(76vh, 860px);
  margin: 0 auto;
  max-width: 980px;
  overflow: hidden;
  position: relative;
}

.epub-toolbar {
  align-items: center;
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  bottom: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  display: flex;
  gap: 8px;
  left: 50%;
  padding: 8px;
  position: absolute;
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 420px);
  z-index: 4;
}

.epub-progress {
  color: var(--mute);
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 52px;
  text-align: center;
}

#epubFrame {
  height: 100%;
}

.epub-tap-zone {
  background: transparent;
  border: 0;
  bottom: 78px;
  display: block;
  position: absolute;
  top: 0;
  touch-action: manipulation;
  width: 18%;
  z-index: 3;
}

.epub-tap-zone-prev {
  left: 0;
}

.epub-tap-zone-next {
  right: 0;
}

.pdf-reader object,
.pdf-reader iframe {
  border: 0;
  height: 100%;
  width: 100%;
}

.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);
  max-height: 28vh;
  overflow: auto;
  padding: 14px 24px max(16px, env(safe-area-inset-bottom));
}

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

.highlight-card {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
  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;
}

.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;
}

.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(280px, 1fr));
}

.all-highlight-card,
.empty-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  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;
}

.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;
}

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

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

.mobile-only {
  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);
    height: 100vh;
    left: 0;
    max-width: min(88vw, 380px);
    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;
  }

  :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;
    padding-left: 12px;
    padding-right: 12px;
  }

  .reader-actions {
    gap: 6px;
  }

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

  .reader-stage {
    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-stage {
    background: var(--surface);
    padding: 0;
  }

  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 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .article-reader {
    border-left: 0;
    border-radius: 0;
    border-right: 0;
    min-height: 72vh;
    padding: 24px 18px;
  }

  .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: calc(100vh - 68px);
    height: calc(100dvh - 68px - env(safe-area-inset-top));
    max-width: none;
    width: 100%;
  }

  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-toolbar {
    bottom: max(14px, env(safe-area-inset-bottom));
    width: min(calc(100% - 24px), 430px);
  }

  body.reader-document[data-reader-format="epub"] .epub-toolbar .icon-button {
    display: inline-flex;
    flex: 0 0 44px;
    height: 44px;
    min-width: 44px;
  }

  body.reader-document[data-reader-format="epub"] .epub-tap-zone {
    width: 22%;
  }

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

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

  .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;
  }

  .library-card-copy strong,
  .library-card-copy small {
    white-space: normal;
  }

  .library-card p {
    margin-left: 0;
  }

  .library-card.selection-mode p,
  .library-card-actions,
  .library-card.selection-mode .library-card-actions {
    margin-left: 0;
  }

  .library-progress,
  .library-progress-meta {
    margin-left: 0;
  }
}
