:root {
  --background: 32 65% 97%;
  --foreground: 222 22% 12%;
  --surface: 0 0% 100%;
  --surface-2: 220 25% 96%;
  --surface-3: 220 20% 92%;
  --muted: 220 10% 46%;
  --accent: 20 90% 55%;
  --primary: 217 76% 45%;
  --shadow: 220 40% 12%;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --font-sans: "Space Grotesk", system-ui, sans-serif;
  --font-serif: "Literata", "Times New Roman", serif;
  --font-display: "Fraunces", serif;
  --font-clarity: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-sans-alt: "IBM Plex Sans", system-ui, sans-serif;
  --font-serif-alt: "Merriweather", "Times New Roman", serif;
  --font-classic: "Playfair Display", "Times New Roman", serif;
  --reader-font: var(--font-display);
  --reader-scale: 1;
}

body[data-theme="dark"] {
  --background: 224 36% 8%;
  --foreground: 0 0% 95%;
  --surface: 224 30% 14%;
  --surface-2: 223 30% 18%;
  --surface-3: 223 28% 22%;
  --muted: 220 10% 70%;
  --accent: 22 90% 60%;
  --primary: 200 80% 55%;
  --shadow: 220 60% 4%;
}

body[data-reader-font="display"] {
  --reader-font: var(--font-display);
}

body[data-reader-font="serif"] {
  --reader-font: var(--font-serif);
}

body[data-reader-font="clarity"] {
  --reader-font: var(--font-clarity);
}

body[data-reader-font="sans-alt"] {
  --reader-font: var(--font-sans-alt);
}

body[data-reader-font="serif-alt"] {
  --reader-font: var(--font-serif-alt);
}

body[data-reader-font="classic"] {
  --reader-font: var(--font-classic);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: #f6f7fb;
  color: hsl(var(--foreground));
  transition: background 0.3s ease, color 0.3s ease;
}

body[data-theme="dark"] {
  background: #0c111a;
}

.page-shell {
  min-height: 100vh;
  padding: 24px 5vw 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.site-footer {
  text-align: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: hsl(var(--muted));
  margin-top: 12px;
}

.footer-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}

.footer-link:hover {
  opacity: 0.8;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 12px 18px;
  border-radius: 18px;
  background: hsl(var(--surface));
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

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

.brand-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #38bdf8 100%);
  color: white;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: 0 10px 18px rgba(30, 58, 138, 0.25);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: hsl(var(--muted));
  font-size: 14px;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  background: hsl(var(--surface-2));
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
}

.nav-link.active {
  background: hsl(var(--surface-3));
}

.page-content {
  display: grid;
  gap: 24px;
}

.panel {
  background: hsl(var(--surface));
  border-radius: var(--radius-xl);
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

.reader-links {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 960px;
  align-items: center;
}

.underline-link {
  position: relative;
  font-weight: 600;
  color: hsl(var(--foreground));
  text-decoration: none;
  padding-bottom: 4px;
  letter-spacing: 0.02em;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}

.underline-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #0f766e, #2563eb, #38bdf8);
  transform-origin: left center;
  transform: scaleX(0.6);
  transition: transform 0.2s ease;
}

.notes-accordion {
  position: relative;
}

.notes-accordion summary {
  list-style: none;
  cursor: pointer;
}

.notes-accordion summary::-webkit-details-marker {
  display: none;
}

.notes-accordion[open] .notes-accordion-body {
  max-height: 360px;
  opacity: 1;
  margin-top: 12px;
}

.notes-accordion-body {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 80vw);
  background: hsl(var(--surface));
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.14);
  padding: 16px;
  display: grid;
  gap: 12px;
  max-height: min(360px, calc(100vh - 120px));
  opacity: 0;
  overflow: auto;
  transition: max-height 0.2s ease, opacity 0.2s ease;
  z-index: 3;
}

.underline-link:hover::after {
  transform: scaleX(1);
}

.panel-soft {
  background: hsl(var(--surface-2));
  border-radius: var(--radius-lg);
  padding: 20px;
}

.upload-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 28px;
  align-items: stretch;
}

.upload-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
}

.upload-hero p {
  color: hsl(var(--muted));
}

.upload-drop {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 2px dashed rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.05);
}

.upload-drop label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: hsl(var(--muted));
}

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

.recent-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: hsl(var(--surface-2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.reader-shell {
  display: flex;
  justify-content: center;
}

.reader-focus {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.reader-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
  text-transform: lowercase;
  flex-wrap: wrap;
}

.reader-title .underline-link {
  padding-bottom: 2px;
}

.reader-subtitle {
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted));
  margin-top: 4px;
}

.focus-card {
  position: relative;
  width: 100%;
  max-width: 960px;
  padding: 24px;
  border-radius: 28px;
  background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.04) 0%,
      rgba(14, 116, 144, 0.08) 45%,
      rgba(37, 99, 235, 0.12) 100%
    ),
    hsl(var(--surface));
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

body[data-theme="dark"] .focus-card {
  background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.6) 0%,
      rgba(12, 74, 110, 0.5) 45%,
      rgba(14, 116, 144, 0.4) 100%
    ),
    hsl(var(--surface));
}

.focus-card::before {
  content: "";
  position: absolute;
  inset: -40% 20% auto auto;
  width: 420px;
  height: 420px;
  background: radial-gradient(
    circle,
    rgba(56, 189, 248, 0.22) 0%,
    rgba(56, 189, 248, 0) 65%
  );
  pointer-events: none;
}

.focus-reader {
  display: grid;
  gap: 16px;
  align-items: center;
  justify-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
}

.focus-reader.is-flipping {
  animation: diceFlip 0.55s ease;
  transform-style: preserve-3d;
}

.focus-word {
  min-height: 160px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(clamp(44px, 7vw, 92px) * var(--reader-scale));
  font-family: var(--reader-font);
  letter-spacing: 0.02em;
  color: #0f172a;
  background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 40%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.focus-word.dice-card {
  font-size: calc(18px * var(--reader-scale));
  line-height: 1.7;
  letter-spacing: 0.01em;
  color: hsl(var(--foreground));
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  text-align: left;
  justify-content: flex-start;
  align-items: flex-start;
  white-space: normal;
  padding: 0 8px;
}

.dice-meta {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: hsl(var(--muted));
}

body[data-theme="dark"] .focus-word {
  background: linear-gradient(135deg, #f8fafc 0%, #7dd3fc 45%, #22d3ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

body[data-theme="dark"] .focus-word.dice-card {
  color: hsl(var(--foreground));
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}

.focus-status {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: hsl(var(--muted));
}

.progress-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.progress-slider {
  width: min(520px, 80%);
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #2563eb, #38bdf8);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

.progress-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #fff;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.2);
}

.progress-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #fff;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.2);
}

.focus-controls {
  margin-top: 16px;
  display: grid;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.focus-divider {
  height: 1px;
  width: 100%;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0) 0%,
    rgba(148, 163, 184, 0.4) 50%,
    rgba(148, 163, 184, 0) 100%
  );
}

.pill-group {
  display: grid;
  gap: 10px;
}

.pill-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: hsl(var(--muted));
  margin: 0;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: hsl(var(--surface-2));
  color: hsl(var(--foreground));
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

.pill.active {
  background: linear-gradient(135deg, #0f766e 0%, #2563eb 100%);
  color: #fff;
  border-color: transparent;
}

.focus-action {
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: #0f172a;
  color: #fff;
  cursor: pointer;
  justify-self: start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.focus-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.2);
}

.focus-action.secondary {
  background: #2563eb;
}

.focus-action.secondary:hover {
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.3);
}

.upload-inline {
  margin: 0;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  border: 0;
  opacity: 0;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.24);
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.note-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 14, 22, 0.62);
  z-index: 2;
}

.note-card {
  width: 100%;
  max-width: 560px;
  background: hsl(var(--surface));
  border-radius: 20px;
  padding: 24px;
  display: grid;
  gap: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.note-title {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: hsl(var(--muted));
}

.note-form {
  display: grid;
  gap: 14px;
}

.note-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  min-height: 140px;
  resize: vertical;
}

.note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.focus-card.is-muted .focus-reader,
.focus-card.is-muted .focus-controls {
  opacity: 0.3;
  filter: grayscale(1);
  pointer-events: none;
}

.header-doc.compact .header-doc-title {
  max-width: 240px;
}

.hidden {
  display: none !important;
}

.library-shell,
.settings-shell,
.notes-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.library-card,
.settings-card,
.notes-card {
  width: 100%;
  max-width: 980px;
  border-radius: 26px;
  padding: 28px;
  background: hsl(var(--surface));
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.1);
}

.library-header,
.notes-header,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.library-title,
.settings-title,
.notes-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 38px);
  margin: 6px 0 0;
}

.library-section {
  display: grid;
  gap: 14px;
  margin-bottom: 28px;
}

.library-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-section-title {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: hsl(var(--muted));
}

.library-count {
  font-size: 12px;
  color: hsl(var(--muted));
}

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

.library-item {
  border-radius: 20px;
  padding: 20px;
  background: hsl(var(--surface-2));
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: grid;
  gap: 16px;
}

.library-item-main {
  display: grid;
  gap: 12px;
}

.library-item-title {
  font-size: 20px;
  margin: 6px 0 0;
  font-weight: 600;
}

.library-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.library-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.status-select {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: hsl(var(--surface));
  font-weight: 600;
}

.pill.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-control .range {
  width: min(260px, 70vw);
}

.settings-label {
  font-weight: 600;
  margin: 0;
}

.toggle {
  position: relative;
  width: 54px;
  height: 30px;
  display: inline-block;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: hsl(var(--surface-3));
  border-radius: 999px;
  transition: background 0.2s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 4px;
  left: 4px;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.15);
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-track {
  background: linear-gradient(135deg, #0f766e, #2563eb);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(24px);
}

.reader-frame {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.left-nav {
  display: grid;
  gap: 12px;
  height: fit-content;
}

.search-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: hsl(var(--surface));
  font-weight: 600;
}

.nav-footer {
  position: sticky;
  bottom: 0;
  background: hsl(var(--surface));
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.reader-row {
  display: grid;
  gap: 22px;
}

.reader-stage {
  display: grid;
  gap: 18px;
}

.reader-meta {
  display: grid;
  gap: 6px;
}

.reader-viewport {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(clamp(36px, 6vw, 74px) * var(--reader-scale));
  font-family: var(--reader-font);
  text-align: center;
  padding: 24px;
  border-radius: 22px;
  background: linear-gradient(135deg, #1b2a78 0%, #2d4cc6 50%, #4aa3ff 100%);
  color: white;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

body[data-theme="dark"] .reader-viewport {
  background: linear-gradient(135deg, #111827 0%, #0f766e 55%, #14b8a6 100%);
}

.pivot-letter {
  color: #f97316;
  text-shadow: 0 6px 14px rgba(15, 23, 42, 0.4);
}

.clock-panel,
.notes-panel {
  display: grid;
  gap: 16px;
}

.control-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: hsl(var(--muted));
}

.segmented {
  display: inline-flex;
  background: hsl(var(--surface-2));
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.segment {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  color: inherit;
}

.segment.active {
  background: hsl(var(--surface));
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.1);
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: hsl(var(--muted));
  margin: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.text-link {
  color: hsl(var(--primary));
  font-weight: 600;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.recent-panel {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.recent-docs {
  display: grid;
  gap: 8px;
}

.recent-doc {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: hsl(var(--surface-2));
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}

.recent-doc:hover {
  background: hsl(var(--surface-3));
}
.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  height: 38px;
}

.icon-label {
  font-size: 13px;
  font-weight: 600;
}

.icon-moon,
.icon-trash,
.icon-upload,
.icon-file,
.icon-dice,
.icon-library {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: currentColor;
  mask-size: cover;
  mask-repeat: no-repeat;
  mask-position: center;
}

.icon-moon {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5Z'/%3E%3C/svg%3E");
}

.icon-trash {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 3h6l1 2h4v2H4V5h4l1-2Zm1 6h2v8h-2V9Zm4 0h2v8h-2V9Z'/%3E%3C/svg%3E");
}

.icon-upload {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3 7 8h3v6h4V8h3l-5-5Zm-7 14h14v2H5v-2Z'/%3E%3C/svg%3E");
}

.icon-file {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 2h7l5 5v15a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2Zm7 1.5V8h4.5L13 3.5Z'/%3E%3C/svg%3E");
}

.icon-dice {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7.5 7.5 3h9L21 7.5v9L16.5 21h-9L3 16.5v-9Zm5 1.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm8 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm-8 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm8-8a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z'/%3E%3C/svg%3E");
}

.icon-library {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 5h3v14H4V5Zm6 0h3v14h-3V5Zm6 0h4v14h-4V5Z'/%3E%3C/svg%3E");
}

.list-scroll {
  max-height: 360px;
  overflow-y: auto;
  display: grid;
  gap: 12px;
}

.passage-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: hsl(var(--surface-2));
  display: grid;
  gap: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.passage-item:hover,
.passage-item.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: hsl(var(--surface-3));
}

.dice-card {
  font-family: var(--reader-font);
  font-size: calc(18px * var(--reader-scale));
  line-height: 1.7;
}

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

.note-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: hsl(var(--surface-2));
  display: grid;
  gap: 6px;
}

.font-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: hsl(var(--surface));
  font-weight: 600;
}

textarea.font-select {
  font-weight: 500;
  resize: vertical;
  min-height: 140px;
}

.library-grid {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.library-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: hsl(var(--surface-2));
  display: grid;
  gap: 12px;
}

.header-doc {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.header-doc-title {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fade-in {
  animation: fadeInUp 0.8s ease;
}

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

@keyframes diceFlip {
  0% {
    transform: rotateY(0deg);
  }
  45% {
    transform: rotateY(85deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

@media (max-width: 1100px) {
  .upload-hero {
    grid-template-columns: 1fr;
  }

  .reader-frame {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .site-header {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 12px;
  }

  .header-center {
    justify-content: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .reader-viewport {
    min-height: 200px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .focus-card {
    padding: 22px;
  }

  .focus-word {
    min-height: 180px;
  }

  .focus-status {
    flex-direction: column;
    gap: 6px;
  }

  .focus-action {
    justify-self: stretch;
    text-align: center;
  }

  .library-card,
  .settings-card,
  .notes-card {
    padding: 22px;
  }

  .library-item-footer {
    align-items: flex-start;
  }
}
