*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #faf8f5;
  --white: #ffffff;
  --ink: #1a1814;
  --ink-light: #6b6560;
  --ink-faint: #b8b3ad;
  --rule: #e8e4de;
  --accent: #c85a2a;
  --accent-light: #f5ede7;
  --success: #2a7a4b;
  --error: #b83a2a;
  --sidebar-w: 260px;
  --header-h: 60px;
}

html, body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: 'Lora', serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.3px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.14s;
  outline: none;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background: var(--ink);
  color: var(--white);
  padding: 9px 20px;
}
.btn-primary:hover { background: #2e2b27; color: var(--white); }

.btn-ghost {
  background: none;
  color: var(--ink-light);
  border-color: var(--rule);
  font-size: 12.5px;
  padding: 6px 13px;
}
.btn-ghost:hover { background: var(--cream); color: var(--ink); }

/* ── Attribution ── */
.fixed-attribution {
  position: fixed;
  bottom: 14px;
  left: 16px;
  font-size: 11.5px;
  color: var(--ink-faint);
  z-index: 50;
}

.fixed-attribution a {
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.12s;
}

.fixed-attribution a:hover { color: var(--ink-light); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 10px; }

/* ════════════════════════════════════════════════════════════════════════════ */
/*  index.html — App layout */
/* ════════════════════════════════════════════════════════════════════════════ */

.index-layout { height: 100%; }
#app { display: flex; flex-direction: column; height: 100vh; }
.index-layout header { flex-shrink: 0; }

#auth-badge {
  font-size: 12px;
  color: var(--ink-light);
  font-family: 'DM Mono', monospace;
  display: none;
}

.body-wrap { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
aside {
  width: var(--sidebar-w);
  border-right: 1px solid var(--rule);
  background: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-section { padding: 20px 16px 12px; border-bottom: 1px solid var(--rule); }

.sidebar-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.collection-list { list-style: none; }

.collection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  gap: 8px;
}

.collection-item:hover { background: var(--cream); }
.collection-item.active { background: var(--accent-light); }
.collection-item.active .coll-name { color: var(--accent); font-weight: 500; }

.coll-name {
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.coll-count {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--ink-faint);
  background: var(--cream);
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.sidebar-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--ink-faint);
  font-style: italic;
}

.sidebar-attribution {
  padding: 14px 16px;
  margin-top: auto;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.sidebar-attribution a {
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.12s;
}

.sidebar-attribution a:hover { color: var(--ink-light); }

/* Main */
main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* Login */
#login-screen {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 40px 44px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 2px 24px rgba(0,0,0,0.04);
}

.login-card h2 {
  font-family: 'Lora', serif;
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 6px;
}

.login-card p {
  font-size: 13.5px;
  color: var(--ink-light);
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-card p a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.field { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-light);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--cream);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  background: var(--white);
}

input::placeholder { color: var(--ink-faint); }

.hint {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 5px;
}

.hint a {
  color: var(--accent);
  text-decoration: none;
}

/* App buttons (index-specific overrides) */
.index-layout .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 11px;
  font-size: 14px;
}
.index-layout .btn-primary:disabled { opacity: 0.45; cursor: default; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--white);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left { display: flex; flex-direction: column; gap: 2px; }

.toolbar-title {
  font-family: 'Lora', serif;
  font-size: 18px;
  font-weight: 500;
}

.toolbar-meta {
  font-size: 12px;
  color: var(--ink-faint);
  font-family: 'DM Mono', monospace;
}

.toolbar-right { display: flex; gap: 8px; align-items: center; }

/* Filter bar */
.filter-bar {
  padding: 12px 28px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.type-pill {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: none;
  color: var(--ink-light);
  font-family: 'DM Sans', sans-serif;
  transition: all 0.12s;
}

.type-pill:hover { border-color: var(--ink-faint); color: var(--ink); }
.type-pill.active { background: var(--ink); color: var(--white); border-color: var(--ink); }

/* Cards */
.annotations-wrap { padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }

.annotation-card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 24px;
  transition: box-shadow 0.15s, border-color 0.15s;
  animation: fadeUp 0.2s ease both;
}

.annotation-card:hover {
  box-shadow: 0 3px 16px rgba(0,0,0,0.06);
  border-color: #d8d4ce;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.card-url {
  font-size: 11.5px;
  color: var(--ink-faint);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
}

.card-url a { color: inherit; text-decoration: none; }
.card-url a:hover { color: var(--accent); }

.card-quote {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.65;
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  margin: 10px 0;
  opacity: 0.85;
}

.card-note {
  font-size: 14px;
  color: var(--ink-light);
  line-height: 1.6;
  margin: 8px 0;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.type-badge {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
}

.type-badge.annotation { background: #eaf0fb; color: #2a5ab8; }
.type-badge.highlight  { background: #fdf6e3; color: #8a6914; }
.type-badge.bookmark   { background: var(--accent-light); color: var(--accent); }
.type-badge.reply      { background: #edf7f0; color: var(--success); }

.card-date {
  font-size: 11.5px;
  color: var(--ink-faint);
  font-family: 'DM Mono', monospace;
  margin-left: auto;
}

.tags-wrap { display: flex; gap: 5px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  color: var(--ink-light);
  background: var(--cream);
  border: 1px solid var(--rule);
  padding: 1px 8px;
  border-radius: 10px;
}

/* States */
.state-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-faint);
  padding: 60px 20px;
  text-align: center;
}

.state-icon { font-size: 36px; line-height: 1; }
.state-title { font-size: 16px; color: var(--ink-light); font-weight: 500; }
.state-sub { font-size: 13px; max-width: 300px; line-height: 1.5; }
.state-error { color: var(--error); }

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: var(--white);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: all 0.2s;
  z-index: 999;
  max-width: 320px;
}

#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--error); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 32px 36px;
  width: 360px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  transform: translateY(8px);
  transition: transform 0.15s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal h3 {
  font-family: 'Lora', serif;
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 6px;
}

.modal p {
  font-size: 13px;
  color: var(--ink-light);
  margin-bottom: 22px;
}

.export-options { display: flex; flex-direction: column; gap: 10px; }

.export-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  background: none;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.12s;
  text-align: left;
  width: 100%;
}

.export-btn:hover { background: var(--cream); border-color: #d0cbc4; }

.export-btn-info .name { font-size: 14px; font-weight: 500; color: var(--ink); }
.export-btn-info .desc { font-size: 12px; color: var(--ink-faint); }

.export-ext {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--ink-faint);
}

.modal-footer { margin-top: 16px; display: flex; justify-content: flex-end; }

/* Selectable cards (Browse All) */
.annotation-card.selectable {
  cursor: pointer;
  position: relative;
  padding-left: 52px;
}

.annotation-card.selectable .card-checkbox {
  position: absolute;
  left: 18px;
  top: 22px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.annotation-card.selectable.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Tag filter modal */
.modal-wide { width: 480px; }

.tag-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.tag-filter-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--ink-light);
  font-family: 'DM Sans', sans-serif;
  transition: all 0.12s;
}

.tag-filter-chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.tag-filter-chip.active { background: var(--accent); color: var(--white); border-color: var(--accent); }
.tag-filter-chip.none-tag { font-style: italic; }

/* Date range filter (Browse All) */
.date-filter-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.date-filter-wrap label {
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-bottom: 0;
}

.date-filter-wrap input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--cream);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
  width: 130px;
}

.date-filter-wrap input[type="date"]:focus {
  border-color: var(--accent);
  background: var(--white);
}

/* Selection action bar */
.select-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 28px;
  background: var(--accent-light);
  border-bottom: 1px solid #e8cfc0;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.select-bar .select-bar-count { font-size: 13px; font-weight: 500; color: var(--accent); flex: 1; }
.select-bar .btn-ghost { font-size: 12px; padding: 5px 11px; }

/* ════════════════════════════════════════════════════════════════════════════ */
/*  about.html — Page layout */
/* ════════════════════════════════════════════════════════════════════════════ */

.about-layout header { position: sticky; top: 0; }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 28px 100px;
}

/* Hero */
.hero {
  margin-bottom: 56px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--rule);
}

.hero-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.hero h1 {
  font-family: 'Lora', serif;
  font-size: 38px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 18px;
  color: var(--ink);
}

.hero-lead {
  font-size: 16px;
  color: var(--ink-light);
  line-height: 1.7;
  max-width: 580px;
}

.hero-lead a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.hero-cta {
  margin-top: 28px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Sections */
section { margin-bottom: 52px; }

.section-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}

section h2 {
  font-family: 'Lora', serif;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 14px;
  color: var(--ink);
}

section p {
  color: var(--ink-light);
  line-height: 1.75;
  margin-bottom: 14px;
  font-size: 14.5px;
}

section p:last-child { margin-bottom: 0; }

section p a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* Steps */
.steps { display: flex; flex-direction: column; margin-top: 4px; }

.step {
  display: flex;
  gap: 20px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.step:last-child { border-bottom: none; }

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.step-body h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 5px;
}

.step-body p {
  font-size: 13.5px;
  color: var(--ink-light);
  line-height: 1.6;
  margin: 0;
}

.step-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

code {
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
  background: var(--cream);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--rule);
}

/* Features grid */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 4px;
}

.feature-card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 22px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.feature-card:hover {
  box-shadow: 0 3px 16px rgba(0,0,0,0.06);
  border-color: #d8d4ce;
}

.feature-icon { font-size: 22px; margin-bottom: 10px; line-height: 1; }

.feature-card h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 5px;
}

.feature-card p {
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.55;
  margin: 0;
}

/* Format list */
.format-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.format-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 8px;
  transition: border-color 0.12s;
}

.format-row:hover { border-color: #d0cbc4; }

.format-ext {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--ink-faint);
  background: var(--cream);
  border: 1px solid var(--rule);
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.format-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 3px;
}

.format-desc { font-size: 13px; color: var(--ink-faint); line-height: 1.5; }

/* Privacy box */
.privacy-box {
  background: var(--accent-light);
  border: 1px solid #e8c5b0;
  border-radius: 10px;
  padding: 20px 22px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 4px;
}

.privacy-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; line-height: 1; }
.privacy-box p { font-size: 13.5px; color: var(--ink-light); line-height: 1.65; margin: 0; }
.privacy-box strong { color: var(--ink); }

.about-layout .feature-card { transition: none; }
.about-layout .feature-card:hover {
  box-shadow: none;
  border-color: var(--rule);
}

.about-layout .format-row { transition: none; }
.about-layout .format-row:hover { border-color: var(--rule); }

/* ════════════════════════════════════════════════════════════════════════════ */
/*  Responsive */
/* ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  aside { width: 200px; }
  .toolbar, .filter-bar, .annotations-wrap { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 600px) {
  .page { padding: 36px 18px 80px; }
  .hero h1 { font-size: 28px; }
  .features { grid-template-columns: 1fr; }
  header { padding: 0 18px; }
}