@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&family=Fraunces:wght@500;600&family=Source+Serif+4:wght@400;600&display=swap");

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

:root {
  color-scheme: light;
  --bg: #f7f1e8;
  --bg-strong: #f0e7dd;
  --bg-muted: #f4ece3;
  --card: #fffaf5;
  --card-muted: #f3e8de;
  --card-ghost: #eee2d8;
  --panel: #2b1f1a;
  --panel-border: #3b2c24;
  --panel-text: #f7ede5;
  --panel-muted: #d8c9bb;
  --muted: #7d6657;
  --text: #2f241e;
  --accent: #b66a5b;
  --accent-2: #8ba177;
  --accent-soft: rgba(182, 106, 91, 0.12);
  --accent-strong: rgba(182, 106, 91, 0.2);
  --border: #e4d6c8;
  --shadow: 0 18px 52px rgba(66, 44, 32, 0.14);
  --shadow-strong: 0 24px 60px rgba(66, 44, 32, 0.2);
  --ghost: #f0e5da;
  --tag-bg: #e9ddd1;
  --tag-text: #3a2c23;
  --pill-bg: #efe5db;
  --pill-active-bg: #b66a5b;
  --pill-active-text: #fff7f1;
  --danger: #a33f3f;
  --danger-bg: #fceeee;
  --danger-border: #f2c4c4;
  --success: #4f8b62;
  --success-bg: #e7f4ea;
  --success-border: #b8dfc5;
  --highlight-bg: #fdf2dc;
  --highlight-text: #3a2c23;
  --highlight-border: rgba(57, 43, 35, 0.12);
  --page-shell-bg: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 92%, #ffffff 8%),
    color-mix(in srgb, var(--bg-muted) 92%, #ffffff 8%)
  );
  --hero-bg: color-mix(in srgb, var(--card) 92%, var(--card-muted) 8%);
  --dropzone-bg: linear-gradient(
    180deg,
    color-mix(in srgb, var(--card) 94%, var(--card-muted) 6%),
    color-mix(in srgb, var(--card-muted) 88%, var(--bg) 12%)
  );
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16100d;
  --bg-strong: #1b1410;
  --bg-muted: #1f1712;
  --card: #1f1813;
  --card-muted: #241c17;
  --card-ghost: #2a201a;
  --panel: #231a15;
  --panel-border: #3b2b23;
  --panel-text: #f3e6d8;
  --panel-muted: #cbb7a7;
  --muted: #bda995;
  --text: #f7ede2;
  --accent: #d08b76;
  --accent-2: #a6b88f;
  --accent-soft: rgba(208, 139, 118, 0.16);
  --accent-strong: rgba(208, 139, 118, 0.26);
  --border: #372920;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 22px 60px rgba(0, 0, 0, 0.55);
  --ghost: #2d231d;
  --tag-bg: #33271f;
  --tag-text: #f1e6d7;
  --pill-bg: #2d241e;
  --pill-active-bg: #d08b76;
  --pill-active-text: #211611;
  --danger: #f3b5b5;
  --danger-bg: #381b1b;
  --danger-border: #7a3b3b;
  --success: #9fd2a7;
  --success-bg: #163025;
  --success-border: #2f6b4a;
  --highlight-bg: rgba(255, 209, 160, 0.22);
  --highlight-text: #ffe7c4;
  --highlight-border: rgba(255, 209, 160, 0.38);
  --page-shell-bg: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 88%, #000000 12%),
    color-mix(in srgb, var(--bg-muted) 90%, #000000 10%)
  );
  --hero-bg: color-mix(in srgb, var(--card) 88%, var(--card-muted) 12%);
  --dropzone-bg: linear-gradient(
    180deg,
    color-mix(in srgb, var(--card) 90%, var(--card-muted) 10%),
    color-mix(in srgb, var(--card-muted) 85%, var(--bg) 15%)
  );
}

:root[data-theme="dark"] .home-shell {
  --home-ink: color-mix(in srgb, #f7ede2 88%, #e5d1c2 12%);
  --home-rose: color-mix(in srgb, #f3c8b6 52%, #5b3b32 48%);
  --home-honey: color-mix(in srgb, #d9c19b 46%, #3b2b1f 54%);
  --home-fog: color-mix(in srgb, #2f2620 65%, #1c1410 35%);
  --home-veil: color-mix(in srgb, #241a15 82%, #3a2c24 18%);
  --home-shadow: 0 26px 110px rgba(0, 0, 0, 0.32);
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: "Fraunces", "Playfair Display", "Source Serif 4", serif;
  letter-spacing: -0.015em;
  margin-top: 0;
  color: var(--text);
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.16em;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--accent) 30%);
  background: linear-gradient(135deg, var(--card), var(--card-muted));
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  color: var(--text);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    border-color 120ms ease;
}

.theme-switcher {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.theme-switcher__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.theme-switcher__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  padding: 6px;
  min-width: 180px;
  display: grid;
  gap: 6px;
}

.theme-switcher__item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.theme-switcher__item:hover {
  color: var(--text);
  background: var(--card-muted);
}

.theme-switcher__item.is-active {
  color: var(--text);
  background: var(--accent-soft);
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 14px 32px rgba(59, 42, 32, 0.18);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

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

.page-shell {
  min-height: 100vh;
  background: var(--page-shell-bg);
  padding: 64px 24px 80px;
  position: relative;
  overflow: hidden;
}

.home-shell {
  --home-ink: color-mix(in srgb, var(--text) 82%, #1a0f0b 18%);
  --home-rose: color-mix(in srgb, var(--accent) 55%, #ffdeda 45%);
  --home-honey: color-mix(in srgb, var(--accent-2) 58%, #ffeac6 42%);
  --home-fog: color-mix(in srgb, var(--card) 90%, #ffffff 10%);
  --home-veil: color-mix(in srgb, var(--bg) 86%, #fff5e9 14%);
  --home-shadow: 0 24px 90px rgba(35, 16, 10, 0.16);
  min-height: 100vh;
  padding: 36px 16px 52px;
  display: grid;
  align-items: start;
  justify-items: center;
  background:
    radial-gradient(1100px circle at 16% 4%, color-mix(in srgb, var(--home-rose) 32%, transparent), transparent 60%),
    radial-gradient(900px circle at 80% 12%, color-mix(in srgb, var(--home-honey) 26%, transparent), transparent 60%),
    linear-gradient(155deg, color-mix(in srgb, var(--home-veil) 86%, #fff7ef 14%), color-mix(in srgb, var(--bg-muted) 70%, #f1e5d8 30%));
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.home-shell::before,
.home-shell::after {
  content: "";
  position: absolute;
  inset: 8% 14%;
  border-radius: 40px;
  filter: blur(90px);
  opacity: 0.22;
  z-index: 0;
  pointer-events: none;
}

.home-shell::before {
  background: radial-gradient(circle at 30% 40%, var(--home-rose), transparent 50%);
}

.home-shell::after {
  background: radial-gradient(circle at 70% 60%, var(--home-honey), transparent 55%);
}

.home-minimal {
  display: flex;
  justify-content: center;
  width: 100%;
  position: relative;
  z-index: 1;
}

.home-minimal__content {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 14px 22px;
  border-radius: 28px;
  box-shadow: none;
  color: var(--home-ink);
}

.hero {
  max-width: 1080px;
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
}

.hero--welcome {
  background: var(--hero-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 32px;
  box-shadow: var(--shadow);
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
}

.hero__content h1 {
  font-size: clamp(2.2rem, 3vw, 3rem);
  margin: 8px 0;
  letter-spacing: -0.5px;
}

.hero__content .lede {
  color: var(--muted);
  max-width: 640px;
  margin-top: 8px;
}

.hero__logo {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 14px 30px rgba(59, 42, 32, 0.16));
}

.hero__visual {
  display: grid;
  gap: 12px;
  justify-items: start;
  align-content: start;
}

.hero__highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.highlight {
  background: var(--panel);
  color: var(--panel-text);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.highlight__title {
  margin: 0 0 4px;
  font-weight: 700;
}

.highlight__text {
  margin: 0;
  color: var(--panel-muted);
  font-size: 0.95rem;
}

.hero__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.hero__meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.stat {
  background: var(--panel);
  color: var(--panel-text);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  width: 100%;
}

.stat__label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--panel-muted);
}

.stat__value {
  margin: 6px 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
}

.stat__hint {
  margin: 0;
  color: var(--panel-muted);
  font-size: 0.92rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--border) 60%, var(--accent) 40%);
  background: linear-gradient(135deg, var(--card), color-mix(in srgb, var(--card-muted) 70%, #fff2e6 30%));
  color: var(--text);
  box-shadow: 0 12px 28px rgba(59, 42, 32, 0.16);
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 16px 34px rgba(59, 42, 32, 0.22);
}

.btn--primary {
  background: linear-gradient(120deg, var(--accent), color-mix(in srgb, var(--accent-2) 60%, var(--accent) 40%));
  color: #ffffff;
  border-color: transparent;
}

.btn--primary:hover {
  color: #ffffff;
  box-shadow: 0 18px 36px rgba(182, 106, 91, 0.3);
}

.btn--ghost {
  background: var(--card-ghost);
  color: var(--text);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 700;
  margin: 0;
}

.layout {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
  grid-template-columns: 2fr 1fr;
}

.home-grid {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.card--primary {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 90%, var(--bg) 10%);
}

.card--muted {
  background: var(--card-muted);
}

.feature-panel {
  display: grid;
  gap: 14px;
}

.feature-panel__header h2 {
  margin: 0;
}

.feature-list {
  display: grid;
  gap: 12px;
}

.feature {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card);
}

.feature__title {
  margin: 0 0 4px;
  font-weight: 700;
}

.feature__text {
  margin: 0;
  color: var(--muted);
}

.steps {
  padding-left: 18px;
  color: var(--text);
  margin: 8px 0 12px;
  display: grid;
  gap: 6px;
}

.note {
  margin: 0;
  color: var(--muted);
}

.library {
  display: grid;
  gap: 32px;
  width: 100%;
  align-items: start;
}

.upload {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 6px 4px 0;
  border-radius: 24px;
  background: transparent;
  box-shadow: none;
}

.upload__header {
  position: relative;
  z-index: 1;
  padding: 0 8px 12px;
}

.upload__header h2 {
  margin: 2px 0 6px;
  font-size: clamp(1.6rem, 3vw, 2rem);
}

.upload__header p {
  margin: 6px 0 12px;
  color: var(--muted);
}

.dropzone {
  width: 100%;
  display: block;
  position: relative;
  border: none;
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  background: var(--dropzone-bg);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
  box-shadow: 0 18px 46px rgba(59, 42, 32, 0.12);
}

.dropzone:hover {
  box-shadow: 0 22px 52px rgba(59, 42, 32, 0.2);
  transform: translateY(-2px);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone__title {
  margin: 0;
  font-weight: 600;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}

.dropzone__hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.dropzone--busy {
  opacity: 0.7;
  cursor: progress;
  box-shadow: none;
  transform: none;
}

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  padding: 8px 10px;
  border-radius: 8px;
  margin-top: 10px;
}

.home-shell .upload {
  max-width: 960px;
  padding: 0;
}

.home-shell .upload__header {
  text-align: center;
  padding: 0 0 6px;
}

.home-shell .upload__header h2 {
  margin: 0 0 10px;
  font-size: clamp(2.8rem, 6vw, 3.8rem);
  letter-spacing: -0.04em;
  color: var(--home-ink);
}

.home-shell .dropzone {
  border: 1px solid color-mix(in srgb, var(--home-rose) 28%, rgba(255, 255, 255, 0.7));
  background: linear-gradient(145deg, color-mix(in srgb, #ffffff 78%, var(--home-fog) 22%), color-mix(in srgb, var(--home-rose) 12%, #fff8f3 88%));
  box-shadow:
    0 18px 42px rgba(35, 16, 10, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  padding: 24px 22px 28px;
  border-radius: 20px;
}

.home-shell .dropzone:hover {
  box-shadow:
    0 20px 54px rgba(35, 16, 10, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.home-shell .dropzone__title {
  font-family: "Fraunces", "Playfair Display", serif;
  font-size: clamp(1.4rem, 3.4vw, 2.1rem);
  letter-spacing: -0.02em;
  color: var(--home-ink);
  margin-bottom: 6px;
}

:root[data-theme="dark"] .home-shell .dropzone {
  border: 1px solid color-mix(in srgb, var(--home-rose) 42%, rgba(255, 255, 255, 0.16));
  background: linear-gradient(
      150deg,
      color-mix(in srgb, var(--home-fog) 82%, rgba(255, 255, 255, 0.08) 18%),
      color-mix(in srgb, var(--home-veil) 70%, rgba(255, 255, 255, 0.06) 30%)
    ),
    radial-gradient(160% 140% at 14% 20%, color-mix(in srgb, var(--home-rose) 18%, transparent), transparent 52%),
    radial-gradient(130% 120% at 82% 80%, color-mix(in srgb, var(--home-honey) 12%, transparent), transparent 60%);
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .home-shell .dropzone:hover {
  box-shadow:
    0 26px 84px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .home-shell .dropzone__title {
  color: color-mix(in srgb, var(--home-ink) 92%, #ffffff 8%);
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.35);
}

.home-shell .error {
  background: color-mix(in srgb, var(--home-rose) 16%, rgba(255, 255, 255, 0.3));
  border-color: color-mix(in srgb, var(--danger) 70%, transparent);
  box-shadow: none;
}

.recent__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recent__hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.recent__list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 14px;
}

.drop-area {
  border: none;
  border-radius: 16px;
  padding: 10px;
  transition:
    background 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
  background: color-mix(in srgb, var(--card) 90%, transparent);
}

.drop-area.is-over {
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--card) 40%);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.recent__item[draggable="true"] {
  cursor: grab;
}

.recent__item[draggable="true"]:active {
  cursor: grabbing;
}

.recent__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: none;
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 94%, var(--card-muted) 6%);
  box-shadow: 0 14px 34px rgba(59, 42, 32, 0.12);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  cursor: pointer;
  overflow: visible;
}

.recent__item--active {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--card) 30%);
  box-shadow: 0 18px 40px rgba(182, 106, 91, 0.18);
}

.recent__item--empty {
  justify-content: center;
  text-align: center;
  background: var(--card);
}

.recent__item:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(59, 42, 32, 0.16);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border) 50%);
}

.recent__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.recent__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ellipsis-btn {
  width: 34px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: box-shadow 120ms ease, color 120ms ease, background 120ms ease;
}

.ellipsis-btn:hover:not(:disabled) {
  color: var(--text);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  box-shadow: 0 12px 24px rgba(182, 106, 91, 0.14);
}

.ellipsis-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropdown__menu {
  position: absolute;
  left: auto;
  right: 0;
  top: calc(100% + 8px);
  margin-top: 0;
  transform: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-strong);
  min-width: 140px;
  padding: 6px;
  z-index: 60;
}

.dropdown__item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.dropdown__icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.85rem;
  margin-top: 4px;
}

.dropdown__item:hover {
  background: var(--card-muted);
}

.library-collapse {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 12px;
  background: var(--card);
}

.library-collapse summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.library-collapse[open] {
  box-shadow: var(--shadow);
}

.library-collapse[open] summary {
  margin-bottom: 8px;
}

.recent__title {
  margin: 0;
  font-weight: 600;
}

.recent__meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.home-shell .recent {
  margin-top: 28px;
  display: grid;
  gap: 18px;
}

.home-shell .drop-area {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 6px 0;
}

.home-shell .drop-area.is-over {
  background: color-mix(in srgb, var(--home-rose) 16%, transparent);
  box-shadow: none;
}

.home-shell .drop-area,
.home-shell .drop-area * {
  position: relative;
  z-index: 1;
}

.home-shell .recent__list {
  gap: 4px;
}

.home-shell .recent__item {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 24px 18px 22px;
  border-radius: 6px;
  overflow: visible;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.home-shell .recent__item--active {
  background: color-mix(in srgb, var(--home-rose) 10%, transparent);
  box-shadow: 0 6px 18px rgba(35, 16, 10, 0.08);
}

.home-shell .recent__title {
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.home-shell .recent__meta {
  font-size: 0.98rem;
}

.home-shell .recent__item:hover {
  border-color: color-mix(in srgb, var(--home-rose) 30%, var(--border) 70%);
  box-shadow: 0 10px 22px rgba(35, 16, 10, 0.1);
}

.home-shell .library-collapse {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 4px 0 0;
}

.home-shell .library-collapse summary {
  letter-spacing: 0.01em;
  padding: 6px 0 10px;
}

.home-shell details[open] > summary {
  border-bottom-color: color-mix(in srgb, var(--home-ink) 14%, var(--border) 86%);
}

.home-shell .ellipsis-btn {
  border-color: color-mix(in srgb, var(--border) 60%, rgba(255, 255, 255, 0.35));
  color: color-mix(in srgb, var(--home-ink) 68%, var(--muted) 32%);
  box-shadow: 0 8px 16px rgba(35, 16, 10, 0.08);
  width: 30px;
  height: 30px;
}

.home-shell .ellipsis-btn:hover:not(:disabled) {
  box-shadow: 0 12px 30px rgba(35, 16, 10, 0.12);
}

@media (max-width: 720px) {
  .home-shell {
    padding: 30px 12px 44px;
  }

  .home-minimal__content {
    padding: 16px 14px 22px;
  }

  .home-shell .upload__header h2 {
    font-size: clamp(2.4rem, 8vw, 3.2rem);
  }

  .home-shell .dropzone {
    padding: 22px 18px 24px;
  }
}

.muted {
  color: var(--muted);
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--accent) 20%);
  background: color-mix(in srgb, var(--pill-bg) 80%, var(--accent-soft) 20%);
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 8px 20px rgba(59, 42, 32, 0.08);
}

.pill--active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  border-color: var(--pill-active-bg);
}

.pill--soft {
  background: color-mix(in srgb, var(--card) 85%, var(--accent-soft) 15%);
  border-style: solid;
  color: var(--muted);
  box-shadow: none;
}

.reader-page {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: linear-gradient(145deg, var(--bg), var(--bg-muted));
}

.reader {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.reader.is-sidebar-collapsed {
  grid-template-columns: 1fr;
}

.reader.is-sidebar-collapsed .reader__sidebar {
  display: none;
}

.reader__sidebar {
  --sidebar-bg: var(--card);
  --sidebar-border: var(--border);
  --sidebar-text: var(--text);
  --sidebar-muted: var(--muted);
  --sidebar-ghost: var(--card-muted);
  background: linear-gradient(170deg, var(--sidebar-bg), color-mix(in srgb, var(--sidebar-ghost) 80%, var(--sidebar-bg) 20%));
  color: var(--sidebar-text);
  border: 1px solid var(--sidebar-border);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.reader__sidebar .muted {
  color: var(--sidebar-muted);
}

.reader__sidebar h2 {
  margin: 4px 0 0;
}

.reader__sidebar-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--sidebar-border);
}

.reader--dark .reader__sidebar {
  --sidebar-bg: var(--panel);
  --sidebar-border: var(--panel-border);
  --sidebar-text: var(--panel-text);
  --sidebar-muted: var(--panel-muted);
  --sidebar-ghost: var(--ghost);
  background: linear-gradient(168deg, #241a15, #18100c);
  box-shadow: var(--shadow-strong);
}

.reader--sepia .reader__sidebar {
  --sidebar-bg: #f7eedc;
  --sidebar-border: rgba(91, 70, 54, 0.25);
  --sidebar-text: #5b4636;
  --sidebar-muted: #8b715c;
  --sidebar-ghost: #f1e2cd;
  background: linear-gradient(172deg, #fdf6e9, #f7e9d5);
  box-shadow: 0 14px 32px rgba(91, 70, 54, 0.12);
}

.reader__toc {
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 6px;
}

.reader__toc .toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}

.toc__list:not(.toc__list--depth-0) {
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  margin-left: 4px;
}

.toc__row {
  display: grid;
  gap: 6px;
}

.toc__title {
  margin: 0 0 6px;
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  color: var(--sidebar-muted);
}

.toc__section {
  font-weight: 700;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--sidebar-ghost);
  border: 1px solid var(--sidebar-border);
}

.toc__item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
}

.toc__item:hover {
  background: var(--sidebar-ghost);
  border-color: var(--sidebar-border);
}

.toc__item.is-active {
  background: color-mix(in srgb, var(--accent-soft) 75%, var(--sidebar-ghost) 25%);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--sidebar-border) 68%);
  color: var(--sidebar-text);
  box-shadow: none;
}

.reader--dark .toc__item.is-active {
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--sidebar-border) 60%);
  color: var(--panel-text);
}

.reader--sepia .toc__item.is-active {
  background: rgba(91, 70, 54, 0.12);
  border-color: rgba(91, 70, 54, 0.24);
  box-shadow: none;
}

.toc__highlights {
  list-style: none;
  padding: 6px 0 0 10px;
  margin: 0;
  display: grid;
  gap: 6px;
}

.toc-highlight {
  display: grid;
  gap: 8px;
  align-items: start;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 28px rgba(59, 42, 32, 0.14);
  position: relative;
  cursor: pointer;
}

.toc-highlight__top {
  position: absolute;
  top: 8px;
  right: 8px;
}

.toc-highlight__text {
  color: var(--sidebar-text);
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
  line-height: 1.5;
  padding-right: 34px;
  border-radius: 0;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
}

.toc-highlight__text:hover,
.toc-highlight__text:focus-visible {
  border: none;
  background: transparent;
  box-shadow: none;
  transform: none;
  color: var(--sidebar-text);
}

.toc-highlight__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.toc-highlight__menu {
  position: relative;
}

.toc-highlight__menu-trigger {
  width: 34px;
  height: 34px;
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--sidebar-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  cursor: pointer;
}

.toc-highlight__menu-trigger:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-ghost);
}

.toc-highlight__menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 4px;
  min-width: 160px;
  z-index: 12;
}

.toc-highlight__menu-dropdown button {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toc-highlight__menu-dropdown button:hover {
  background: var(--sidebar-ghost);
}

.toc-highlight__delete {
  color: var(--danger);
}

.toc-highlight__note {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  padding-left: 10px;
  border-left: 3px solid var(--sidebar-border);
}

.toc-highlight__note-editor {
  display: grid;
  gap: 6px;
}

.toc-highlight__note-editor textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--sidebar-border);
  background: var(--sidebar-ghost);
  color: var(--sidebar-text);
  padding: 8px 10px;
  font: inherit;
}

.toc-highlight__note-actions {
  display: inline-flex;
  gap: 8px;
  justify-content: flex-end;
}

.toc-highlight__cancel-btn {
  color: var(--sidebar-muted);
  background: transparent;
  border: none;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.reader__highlights {
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}

.highlights__list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}

.highlight__item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
}

.highlight__text {
  margin: 0 0 4px;
  color: var(--panel-text);
  font-size: 0.95rem;
}

.highlight__meta {
  margin: 0;
  color: var(--panel-muted);
  font-size: 0.82rem;
}

.highlight__actions {
  margin-top: 4px;
}

.link-btn {
  background: transparent;
  color: var(--panel-muted);
  border: none;
  padding: 4px 0;
  cursor: pointer;
}

.link-btn:hover {
  color: #ffffff;
}

.reader__content {
  background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card-muted) 80%, #fff7ed 20%));
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--accent) 15%);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(59, 42, 32, 0.16);
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  height: 100%;
  max-width: 80ch;
}

.reader__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, var(--accent) 20%);
  gap: 10px;
}

.reader.is-fullscreen {
  min-height: 100vh;
  height: auto;
  justify-items: center;
  align-content: start;
  overflow-y: auto;
  grid-template-rows: auto;
}

.reader.is-fullscreen .reader__toolbar {
  display: none;
}

.reader.is-fullscreen .reader__content {
  width: min(60em, 100%);
  justify-self: center;
  height: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.reader.is-fullscreen .chapter {
  overflow: visible;
  height: auto;
}

.reader.is-cursor-hidden,
.reader.is-cursor-hidden * {
  cursor: none !important;
}

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

.toolbar__group--themes {
  color: var(--muted);
}

.toolbar__group--settings {
  position: relative;
  justify-content: flex-end;
}

.nav-btn {
  width: 42px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}

.icon-btn {
  width: 40px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-muted);
  color: var(--muted);
  box-shadow: none;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(182, 106, 91, 0.16);
}

.icon-btn--active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
}

.icon-btn--success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.icon-btn--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.settings-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  padding: 12px;
  display: grid;
  gap: 10px;
  min-width: 240px;
  z-index: 5;
}

.settings-menu__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.text-scale {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.font-select {
  min-width: 220px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: none;
}

mark.highlight {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  padding: 0 2px;
  border-radius: 3px;
  border: none;
  box-shadow: inset 0 0 0 1px var(--highlight-border);
}

.selection-menu {
  position: fixed;
  transform: translate(-50%, -100%);
  background: var(--panel);
  color: var(--panel-text);
  border-radius: 10px;
  padding: 8px;
  width: 240px;
  display: grid;
  gap: 6px;
  box-shadow: 0 14px 34px rgba(59, 42, 32, 0.24);
  border: 1px solid var(--panel-border);
  z-index: 20;
}

.selection-menu__note {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--panel-text);
  padding: 8px 10px;
  font: inherit;
}

.selection-menu__actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.selection-menu button {
  background: transparent;
  color: inherit;
  border: none;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.selection-menu__cancel {
  color: var(--panel-muted);
}

.selection-menu button:hover {
  background: var(--accent-soft);
}

.chapter {
  padding: 18px 48px 28px;
  overflow-y: auto;
  line-height: 1.72;
  min-height: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  font-kerning: normal;
  font-feature-settings: "liga" 1, "clig" 1, "calt" 1, "kern" 1;
  font-variant-numeric: proportional-nums oldstyle-nums;
  font-variant-ligatures: common-ligatures;
  hanging-punctuation: first;
  hyphens: auto;
}

.chapter :is(p, ul, ol, blockquote, pre, figure, table, hr) {
  margin-left: auto;
  margin-right: auto;
}

.chapter p {
  margin: 0 0 1.1em;
}

.chapter .dropcaps2line {
  text-indent: 0;
}

.chapter .dropcaps2line::first-letter {
  initial-letter: 2;
  float: left;
  margin-right: 0.18em;
  margin-top: 0.08em;
  font-family: "Fraunces", "Source Serif 4", serif;
  font-size: clamp(2.6rem, 7vw, 3.3rem);
  line-height: 0.9;
  font-weight: 700;
  color: color-mix(in srgb, var(--text) 82%, var(--accent) 18%);
}

.chapter h1, .chapter h2, .chapter h3, .chapter h4 {
  margin-top: 1.4em;
  margin-bottom: 0.4em;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin-left: auto;
  margin-right: auto;
}

.chapter img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(59, 42, 32, 0.2);
}

.chapter a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.18em;
}

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

.chapter li + li {
  margin-top: 0.35em;
}

.chapter blockquote {
  border-left: 3px solid color-mix(in srgb, var(--border) 70%, var(--accent) 30%);
  padding: 1.05em 1.4em;
  margin: 1.4em auto;
  color: var(--muted);
  font-style: italic;
  line-height: 1.82;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent);
  border-radius: 14px;
}

.chapter blockquote > :first-child {
  margin-top: 0;
}

.chapter blockquote > :last-child {
  margin-bottom: 0;
}

.reader--dark .chapter blockquote {
  background: linear-gradient(90deg, rgba(208, 139, 118, 0.16), transparent);
  border-color: color-mix(in srgb, var(--panel-border) 70%, var(--accent) 30%);
}

.reader--sepia .chapter blockquote {
  border-color: rgba(91, 70, 54, 0.28);
  background: linear-gradient(90deg, rgba(91, 70, 54, 0.12), transparent);
  color: #6a5346;
}

.chapter hr {
  height: 1px;
  border: none;
  background: var(--border);
  margin: 2em auto;
}

.chapter figure {
  margin: 1.4em auto;
  text-align: center;
}

.chapter figcaption {
  margin-top: 0.6em;
  color: var(--muted);
  font-size: 0.94em;
}

.chapter pre {
  background: var(--card-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 1.2em auto;
}

.reader--dark .chapter pre {
  background: #241a15;
  border-color: var(--panel-border);
}

.reader--sepia .chapter pre {
  background: #f1e2cd;
  border-color: rgba(91, 70, 54, 0.26);
}

.chapter code {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 0.95em;
  background: var(--card-muted);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.reader--dark .chapter code {
  background: rgba(255, 255, 255, 0.06);
}

.reader--sepia .chapter code {
  background: rgba(91, 70, 54, 0.14);
}

.chapter sup, .chapter sub {
  font-size: 0.8em;
}

.chapter table {
  border-collapse: collapse;
  margin: 1.4em auto;
}

.chapter th, .chapter td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.chapter th {
  background: var(--card-muted);
}

.reader--sepia .chapter th {
  background: #f1e2cd;
}

.reader--sepia .reader__content {
  background: #fbf0dc;
}

.reader--sepia .chapter {
  color: #5b4636;
}

.reader--dark {
  color-scheme: dark;
}

.reader--dark .reader__content {
  background: #1a120d;
  color: var(--panel-text);
  border-color: var(--panel-border);
}

.reader--dark .chapter {
  color: var(--panel-text);
}

@media (max-width: 900px) {
  .page-shell {
    padding: 28px 16px 40px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero--welcome {
    padding: 22px;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .reader {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100vh;
  }

  .reader__sidebar {
    order: 2;
  }

  .chapter {
    padding: 18px 24px 28px;
  }
}

@media (max-width: 600px) {
  .theme-switcher__trigger {
    padding: 8px;
  }
}
