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

/* =========================
   Lexikon — WORKING styles.css
   (matches your HTML exactly)
   Fixes:
   - translation disappearing
   - text not wrapping
   - keeps glass UI + highlights + POS colors
   ========================= */

:root{
  --font-ui: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-text: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;

  --bg0:#05070c;
  --bg1:#0b1020;

  --panel: #0f1420;
  --panel2: #121826;
  --ink: #e7e9f3;
  --muted: rgba(255,255,255,.58);
  --muted2: rgba(255,255,255,.40);
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.14);

  /* Shared tokens for modals/buttons */
  --bg: #0f1420;
  --bg-soft: rgba(255,255,255,0.03);
  --fg: var(--ink);
  --text: var(--ink);
  --border: rgba(255,255,255,0.12);
  --accent: #8a93a3;
  --accent-2: #8a93a3;
  --accent-glow: rgba(138,147,163,0.12);
  --card: var(--panel2);

  --hiA: rgba(181,255,207,.22);
  --hiB: rgba(181,255,207,.06);

  --shadow: 0 6px 16px rgba(0,0,0,.28);
  --inner: none;
}

body[data-theme="light"]{
  --bg0: #f6f6f3;
  --bg1: #fbfbf8;
  --panel: #ffffff;
  --panel2: #ffffff;
  --ink: #1f2430;
  --muted: rgba(20,24,32,.62);
  --muted2: rgba(20,24,32,.42);
  --line: rgba(20,24,32,.10);
  --line-strong: rgba(20,24,32,.16);
  --bg: #ffffff;
  --bg-soft: rgba(0,0,0,0.05);
  --border: rgba(20,24,32,.12);
  --accent: #6c7a92;
  --accent-2: #6c7a92;
  --accent-glow: rgba(108,122,146,.18);
  --hiA: rgba(138,147,163,.10);
  --hiB: rgba(138,147,163,.04);
  --shadow: 0 4px 12px rgba(26,34,52,.10);
  --inner: none;
}

*{ box-sizing:border-box; }
html,body{
  margin: 0;
  min-height: 100%;
  height: auto;
}
html{
  overscroll-behavior-y: auto;
  scroll-behavior: auto;
}

body{
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg0);
  overscroll-behavior-y: auto;
  overflow-anchor: none;
  overflow-y: auto;
}

body:not(.reader-page){
  background:
    radial-gradient(circle at top left, rgba(126,143,122,0.16), transparent 26%),
    radial-gradient(circle at 85% 8%, rgba(108,122,146,0.14), transparent 22%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
  font-family: "Inter", "Segoe UI", sans-serif;
}

body:not(.reader-page) h1,
body:not(.reader-page) h2,
body:not(.reader-page) h3,
body:not(.reader-page) .brand-title{
  font-family: "Libre Baskerville", Georgia, serif;
}

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

/* =========================
   Topbar
   ========================= */

.topbar{
  position: sticky;
  top: 0;
  z-index: 70;
  display:flex;
  align-items:flex-start;
  justify-content:flex-start;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel2);
  backdrop-filter: none;
  flex-wrap: wrap;
}

.menu-btn{
  display: inline-flex;
}

.menu-panel{
  position: fixed;
  top: 0;
  left: 0;
  height: 100dvh;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px 26px;
  background: var(--panel2);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 16px rgba(0,0,0,.25);
  transform: translateX(-100%);
  transition: transform 220ms ease;
  z-index: 80;
  pointer-events: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: auto;
}

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

body[data-theme="light"] .menu-panel{
  background: var(--panel2);
  border-right: 1px solid rgba(0,0,0,0.08);
  box-shadow: 8px 0 16px rgba(26,34,52,.12);
}

.menu-panel .nav-btn,
.menu-panel .nav-link{
  width: 100%;
  justify-content: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  min-height: 44px;
  font-size: 0.95rem;
}

.menu-panel .switch{
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  min-height: 44px;
  width: 100%;
}

body[data-theme="light"] .menu-panel .switch{
  background: rgba(0,0,0,0.03);
}

.menu-typography{
  gap: 10px;
}

.menu-typo-control select{
  min-width: 100%;
}

.menu-range{
  width: 100%;
  accent-color: rgba(139,208,255,.9);
}

.menu-typography.is-locked .menu-typo-control{
  opacity: 0.55;
}

.menu-typography.is-locked .menu-range{
  cursor: not-allowed;
}

.menu-section{
  display: grid;
  gap: 8px;
  padding: 10px 6px 2px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

body[data-theme="light"] .menu-section{
  border-top: 1px solid rgba(0,0,0,0.08);
}

.menu-title{
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted2);
  margin: 4px 6px 2px;
}

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

.menu-recent-item{
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.menu-recent-item:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.08);
}

body[data-theme="light"] .menu-recent-item{
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.08);
}

.menu-recent-item .menu-recent-title{
  font-weight: 600;
  font-size: 0.92rem;
}

.menu-recent-item .menu-recent-meta{
  font-size: 0.78rem;
  color: var(--muted2);
}

.menu-brand{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 6px;
}

.menu-brand .logo{
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.menu-brand .brand-title{
  font-weight: 700;
}

.menu-close{
  width: 38px;
  height: 38px;
  border-radius: 12px;
  align-self: flex-end;
}

.menu-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 60;
}

body.menu-open{
  overflow: hidden;
}

.menu-backdrop.open{
  opacity: 1;
  pointer-events: auto;
}

.mobile-dock{
  display: none;
}

body[data-theme="light"] .topbar{
  background: var(--panel2);
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: 250px;
}

.logo{
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  font-weight: 750;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
}

.brand-title{ font-weight: 680; letter-spacing:.01em; }
.brand-sub{ font-size:.82rem; color: var(--muted2); margin-top:2px; }

.topbar-group{
  display:flex;
  align-items:flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.controls-group{
  display:flex;
  align-items:flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.toggles-group{
  display:flex;
  align-items:center;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.email-export-cta{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(120,255,170,0.2);
  background: rgba(120,255,170,0.08);
  color: var(--ink);
}

.email-export-text{
  font-size: 0.85rem;
  color: var(--muted);
}

.links-group{
  display:flex;
  gap: 10px;
  align-items:center;
}

/* Match index.html topbar styling on non-reader pages. */
body:not(.reader-page) .topbar{
  position: sticky;
  top: 14px;
  z-index: 70;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(calc(100% - 36px), 1180px);
  margin: 18px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,0.32);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.14);
}

body:not(.reader-page) .topbar .brand{
  align-items: baseline;
  gap: 10px;
}

body:not(.reader-page) .topbar .logo{
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #5f715c;
}

body:not(.reader-page) .topbar .brand-title{
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

body:not(.reader-page) .topbar .brand-sub{
  display: block;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted2);
}

body:not(.reader-page) .links-group{
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body:not(.reader-page) .links-group > .nav-link{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--muted2);
  text-decoration: none;
  transition:
    color 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease,
    transform 140ms ease;
}

body:not(.reader-page) .links-group > .nav-link:hover{
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.16);
  opacity: 1;
  color: var(--ink);
  transform: translateY(-1px);
}

body[data-theme="light"]:not(.reader-page) .links-group > .nav-link{
  border-color: rgba(20,28,40,0.08);
  background: rgba(255,255,255,0.78);
  color: #425167;
}

body[data-theme="light"]:not(.reader-page) .links-group > .nav-link:hover{
  border-color: rgba(20,28,40,0.14);
  background: rgba(255,255,255,0.96);
  color: #182235;
}

.library-page .site-header{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: min(calc(100% - 36px), 1180px);
  margin: 0 auto;
  padding: 14px 0 28px;
}

.library-page .brand{
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.library-page .logo-mark{
  font-size: 1.2rem;
  color: var(--sage-deep);
}

.library-page .logo-word{
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.library-page .topnav{
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.library-page .topnav a{
  color: var(--muted-strong);
  text-decoration: none;
  transition: color 160ms ease;
}

.library-page .topnav a:hover{
  color: var(--text);
}

.library-page .theme-toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.32);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.library-page .theme-toggle input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.library-page .theme-toggle-track{
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--line-strong);
  position: relative;
}

.library-page .theme-toggle-track::before{
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  transition: transform 180ms ease;
}

.library-page .theme-toggle input:checked + .theme-toggle-track::before{
  transform: translateX(16px);
}

.library-page .theme-toggle-label{
  font-size: 0.92rem;
  color: var(--muted-strong);
}

@media (max-width: 759px){
  .library-page .site-header{
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
    width: min(calc(100% - 24px), 1180px);
    padding: 10px 0 18px;
  }

  .library-page .topnav{
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  .library-page .theme-toggle{
    margin-top: 4px;
  }

  .library-page .topnav a{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,0.28);
  }
}

.select-wrap{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.label{
  font-size:.78rem;
  color: var(--muted2);
}

select{
  min-width: 190px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.06);
  color: var(--ink);
  outline: none;
}

select:focus{
  border-color: rgba(139,208,255,.38);
  box-shadow: 0 0 0 3px rgba(139,208,255,.12);
}

.toggle{
  display:flex;
  align-items:center;
  gap: 8px;
  font-size:.86rem;
  color: var(--muted);
  user-select:none;
}

.toggle input{
  width: 16px;
  height: 16px;
  accent-color: rgba(139,208,255,.90);
}

/* =========================
   Layout
   ========================= */

.layout{
  max-width: 980px;
  margin: 22px auto 0;
  padding: 0 18px 32px;
  display:block;
  overflow-anchor: none;
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  select{ min-width: 160px; }
}

@media (max-width: 720px){
  .reader-page{
    -webkit-text-size-adjust: 100%;
  }

  body.reader-page .topbar{
    align-items: stretch;
    gap: 8px;
    padding: 12px 12px 10px;
    transition: transform 180ms ease;
    will-change: transform;
  }

  body.reader-page.topbar-hidden .topbar{
    transform: translateY(calc(-100% - 8px));
    pointer-events: none;
  }

  body.reader-page .topbar-group{
    width: 100%;
    justify-content: space-between;
  }

  body.reader-page .controls-group{
    width: 100%;
    gap: 10px;
  }

  body.reader-page .controls-group .select-wrap{
    flex: 1 1 100%;
    min-width: 0;
  }

  body.reader-page .controls-group select{
    width: 100%;
  }

  body.reader-page .toggles-group{
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  body.reader-page #annotationSearch{
    width: 100%;
  }

  .layout{
    margin-top: 12px;
    padding: 0 12px calc(96px + env(safe-area-inset-bottom));
  }

  .columns{
    padding: 10px 12px 8px;
    gap: 12px;
  }

  .card-head{
    padding: 12px;
  }

  .ai-btn{
    flex: 1 1 140px;
  }

  .reader.card{
    resize: none;
  }

  select,
  #annotationSearch{
    min-height: 44px;
    font-size: 16px;
  }

  .nav-btn,
  .nav-link,
  .ai-btn{
    min-height: 44px;
  }

  .reader-toolbar{
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================
   Cards
   ========================= */

.card{
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow), var(--inner);
  backdrop-filter: none;
  overflow: hidden;
}

body[data-theme="light"] .card{
  background: var(--panel2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), var(--inner);
}

.reader {
  resize: vertical;
  min-height: 320px;
}

.reader{
  position: relative;
  overflow: visible;
  z-index: 30;
  overflow-anchor: none;
}

.reader.card{
  overflow: visible;
}

.card-head{
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: transparent;
}

body[data-theme="light"] .card-head{
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: transparent;
}

.card-body{
  padding: 14px 16px 16px;
}

#title{
  margin:0;
  font-size: 1.18rem;
  letter-spacing: .01em;
}

.meta{
  margin-top: 6px;
  font-size: .86rem;
  color: var(--muted2);
}

.reading-progress {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.reading-progress-bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}

.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 180ms ease;
}

.reading-progress-text {
  font-size: .82rem;
  color: var(--muted2);
  white-space: nowrap;
}

.learned-words {
  margin-top: 8px;
  font-size: .85rem;
}

/* =========================
   Reader columns
   ========================= */

.columns{
  display:grid;
  grid-template-columns: 1.1fr 0.9fr; /* Greek slightly wider */
  gap: 16px;
  padding: 0;
}

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

/* IMPORTANT: wrapping lives on containers */
.text{
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;

  white-space: normal;        /* ✅ wrap */
  overflow-wrap: anywhere;    /* ✅ never overflow off-screen */
  word-break: normal;
}

/* Phrase annotations */
.original-wrap{
  position: relative;
  overflow: visible;
}

#original{
  position: relative;
  padding-right: 14px;
}

#original.has-range-cards{
  padding-right: 14px;
}

.range-annotation-lines{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
  overflow: visible;
}

.range-annotations{
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  overflow: visible;
}

.range-annotation-card{
  position: absolute;
  right: 10px;
  width: 260px;
  max-width: calc(100% - 32px);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(18, 20, 28, 0.92);
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.5;
  box-shadow: 0 10px 20px rgba(0,0,0,0.35);
  pointer-events: auto;
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: 50;
}

body[data-theme="light"] .range-annotation-card{
  background: rgba(255,255,255,0.98);
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 10px 20px rgba(0,0,0,0.12);
}

.range-annotation-card.dragging{
  cursor: grabbing;
  box-shadow: 0 14px 26px rgba(0,0,0,0.45);
}

.range-annotation-text{
  color: var(--muted2);
  font-style: italic;
  margin-bottom: 6px;
}

.range-annotation-note{
  color: var(--ink);
}

.range-annotation-card.note-hidden .range-annotation-note{
  display: none;
}

.range-annotation-actions{
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.range-annotation-actions .nav-btn{
  min-height: 32px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.selection-bar{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,0.03);
  font-size: 0.85rem;
  color: var(--muted2);
}

.selection-bar.hidden{
  display: none;
}

.selection-text{
  color: var(--ink);
  font-weight: 600;
}

.phrase-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.phrase-actions .meta{
  font-size: 0.82rem;
}

.range-select-mode #original .word{
  cursor: crosshair;
}

.word.range-selected{
  background: rgba(139, 208, 255, 0.22);
  box-shadow: 0 0 0 1px rgba(139, 208, 255, 0.35);
}

.word.has-range-annotation{
  text-decoration: underline solid rgba(139, 208, 255, 0.6);
}

@media (max-width: 980px){
  #original{
    padding-right: 14px;
  }
  #original.has-range-cards{
    padding-right: 14px !important;
  }
  .range-annotation-lines{
    display: none;
  }
  .range-annotations{
    position: static;
    margin-top: 8px;
  }
  .range-annotation-card{
    position: static;
    max-width: 100%;
    margin-bottom: 8px;
  }
}

.verse-num{
  font-size: 0.78em;
  vertical-align: super;
  letter-spacing: 0.02em;
  color: var(--muted2);
  font-weight: 600;
}

body[data-theme="light"] .text{
  border: 1px solid rgba(0,0,0,.08);
  background: var(--panel);
}

/* Greek typography */
#original{
  font-family: var(--reader-font-family, var(--font-text));
  font-size: calc(1.05rem * var(--reader-font-size-multiplier, 1));
  line-height: 1.75;
  letter-spacing: .01em;
}

/* Translation MUST be visible */
#translation{
  font-family: var(--reader-font-family, var(--font-text));
  display:block;
  opacity: 1 !important;
  visibility: visible !important;
  font-size: calc(.96rem * var(--reader-font-size-multiplier, 1));
  line-height: 1.7;
  color: rgba(235,238,248,.95);
}

body[data-theme="light"] #translation{
  color: rgba(20,24,32,.88);
}

/* Hint */
.hint{
  padding: 10px 16px 14px;
  color: var(--muted2);
  font-size: .84rem;
}

/* =========================
   Tokens + Sentences
   ========================= */

/* Do NOT set nowrap here — it kills wrapping */
.word{
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 5px;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
  color: var(--ink);
}

.word.word-punct{
  padding-left: 0;
  padding-right: 0;
}

.word:hover{
  background: rgba(255,255,255,.14);
  box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}

.word:focus-visible{
  background: rgba(255,255,255,.18);
  box-shadow: 0 0 0 2px rgba(255,255,255,.45);
  outline: none;
}

.word.active{
  background: rgba(255,255,255,.28);
  color: #fff !important;
}

body[data-theme="light"] .word:hover{
  background: rgba(0,0,0,.06);
  box-shadow: 0 0 0 1px rgba(0,0,0,.04);
}

body[data-theme="light"] .word:focus-visible{
  background: rgba(0,0,0,.08);
  box-shadow: 0 0 0 2px rgba(0,0,0,.24);
}

body[data-theme="light"] .word.active{
  background: rgba(0,0,0,.14);
  color: #111 !important;
}

/* Sentence wrapper must remain inline so text flows naturally */
.sentence{
  display: inline;
  border-radius: 8px;
}

/* Highlight — subtle, directional */
#original .sentence.active-sentence{
  background: linear-gradient(to right, var(--hiA), var(--hiB));
  box-shadow: inset 3px 0 0 rgba(181,255,207,.65);
}

#translation .sentence.active-sentence{
  background: rgba(181,255,207,.14);
  border-radius: 6px;
  padding: 1px 2px;
}

/* =========================
   POS colors (Greek only)
   ========================= */

#original .word.pos-noun{ color: #8bd0ff; }
#original .word.pos-verb{ color: #ff8b8b; }
#original .word.pos-adj{ color: #9cffc7; }
#original .word.pos-particle{ color: #a6e6ff; }
#original .word.pos-pron{ color: #ffcc80; }

body[data-theme="light"] #original .word.pos-noun{ color: #1f5fa5; }
body[data-theme="light"] #original .word.pos-verb{ color: #b63b3b; }
body[data-theme="light"] #original .word.pos-adj{ color: #1c7a56; }
body[data-theme="light"] #original .word.pos-particle{ color: #2a6f92; }
body[data-theme="light"] #original .word.pos-pron{ color: #a55e18; }

/* =========================
   Case colors
   ========================= */

:root{
  --case-nom: #4f8fca;
  --case-gen: #d29a49;
  --case-dat: #56a684;
  --case-acc: #d86a5c;
  --case-voc: #a67bd8;
  --case-abl: #4ea8b8;
  --case-loc: #a2ad4f;
  --gender-masc: #4f8fca;
  --gender-fem: #cf6f9f;
  --gender-neut: #56a684;
  --gender-com: #d29a49;
}

body[data-theme="light"]{
  --case-nom: #1f6aa8;
  --case-gen: #9a651e;
  --case-dat: #1f7f61;
  --case-acc: #b64b3f;
  --case-voc: #8254b5;
  --case-abl: #1f7f92;
  --case-loc: #76811f;
  --gender-masc: #1f6aa8;
  --gender-fem: #b24d81;
  --gender-neut: #1f7f61;
  --gender-com: #9a651e;
}

#original .word.case-nom{ color: var(--case-nom); }
#original .word.case-gen{ color: var(--case-gen); }
#original .word.case-dat{ color: var(--case-dat); }
#original .word.case-acc{ color: var(--case-acc); }
#original .word.case-voc{ color: var(--case-voc); }
#original .word.case-abl{ color: var(--case-abl); }
#original .word.case-loc{ color: var(--case-loc); }

/* =========================
   Gender colors (Spanish)
   ========================= */

#original .word.gender-masc{ color: var(--gender-masc); }
#original .word.gender-fem{ color: var(--gender-fem); }
#original .word.gender-neut{ color: var(--gender-neut); }
#original .word.gender-com{ color: var(--gender-com); }

/* keep active readable over POS */
#original .word.active{
  color: var(--ink) !important;
}

/* =========================
   Inspector
   ========================= */

.inspector-body{
  padding: 16px;
  font-size: .95rem;
  line-height: 1.65;
}

.inspector-body strong{
  font-size: 1.18rem;
  letter-spacing: .01em;
}
.inspector-body em{ color: var(--muted); font-style: normal; }

.nav-buttons{
  display:flex;
  gap: 10px;
}

.inspector-toggles{
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.inspector-typography{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.morph-legend {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.morph-legend-title {
  margin-bottom: 6px;
}

.morph-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.morph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.morph-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.14);
}

.morph-swatch.case-nom { background: var(--case-nom); }
.morph-swatch.case-gen { background: var(--case-gen); }
.morph-swatch.case-dat { background: var(--case-dat); }
.morph-swatch.case-acc { background: var(--case-acc); }
.morph-swatch.case-voc { background: var(--case-voc); }
.morph-swatch.case-abl { background: var(--case-abl); }
.morph-swatch.case-loc { background: var(--case-loc); }
.morph-swatch.gender-masc { background: var(--gender-masc); }
.morph-swatch.gender-fem { background: var(--gender-fem); }
.morph-swatch.gender-neut { background: var(--gender-neut); }
.morph-swatch.gender-com { background: var(--gender-com); }

.nav-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--ink);
  cursor:pointer;
  min-height: 40px;
  text-decoration: none;
  transition: background .12s ease, transform .06s ease, box-shadow .12s ease;
  box-shadow: none;
}

body[data-theme="light"] .nav-btn{
  background: var(--bg-soft);
  box-shadow: none;
}

.nav-btn:hover{
  background: rgba(255,255,255,.08);
  box-shadow: none;
}

body[data-theme="light"] .nav-btn:hover{
  background: rgba(0,0,0,.06);
}

.nav-btn:active{ transform: translateY(1px); }

.nav-btn:disabled{
  opacity: .45;
  cursor:not-allowed;
}

.nav-btn.subtle{
  background: var(--bg-soft);
}

.icon-btn{
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.icon-btn.active{
  border-color: var(--line-strong);
  box-shadow: none;
}

.nav-link{
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.05);
  color: var(--ink);
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}

body[data-theme="light"] .nav-link{
  background: rgba(0,0,0,.02);
}

.nav-link.subtle-link{
  background: transparent;
}

.nav-link:hover{
  background: rgba(139,208,255,.14);
  border-color: rgba(139,208,255,.38);
}

.nav-link:active{
  transform: translateY(1px);
}

/* =========================
   Footer
   ========================= */

.footer{
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 18px 28px;
  text-align:center;
  color: rgba(255,255,255,.35);
  font-size: .78rem;
}

.footer-links{
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
}

.footer-links a{
  color: rgba(255,255,255,.55);
  text-decoration: none;
  cursor: pointer;
}

.footer-links a:hover{
  color: rgba(255,255,255,.85);
}

.speaker-Socrates { border-left: 4px solid #8bd0ff; }
.speaker-Diotima { border-left: 4px solid #ffb4e6; }
.speaker-Alcibiades { border-left: 4px solid #ff8b8b; }


/* ------------------------------
   AI PANEL (Inspector)
-------------------------------- */

.ai-panel {
  grid-column: 1 / -1;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;

  /* glass look */
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow-anchor: none;
}

body[data-theme="light"] .ai-panel{
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(0,0,0,.08);
  box-shadow:
    0 10px 30px rgba(26,34,52,0.12),
    inset 0 1px 0 rgba(255,255,255,.65);
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ai-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
  user-select: none;
}

.ai-credits {
  margin: 2px 0 10px;
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-credits-ring {
  --pct: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background:
    conic-gradient(
      rgba(255, 255, 255, 0.9) var(--pct),
      rgba(255, 255, 255, 0.18) 0
    );
  position: relative;
  opacity: 0.9;
}

.ai-credits-ring::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
}

body[data-theme="light"] .ai-credits-ring {
  background:
    conic-gradient(
      rgba(0, 0, 0, 0.85) var(--pct),
      rgba(0, 0, 0, 0.16) 0
    );
}

body[data-theme="light"] .ai-credits-ring::after {
  background: rgba(255, 255, 255, 0.9);
}

.ai-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
  white-space: nowrap;
}

.ai-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

body[data-theme="light"] .ai-btn{
  border: 1px solid rgba(20,24,32,0.18);
  background: #ffffff;
  color: #1f2430;
}

body[data-theme="light"] .ai-btn:hover{
  background: rgba(0,0,0,0.04);
  border-color: rgba(20,24,32,0.28);
}

.ai-btn:active {
  transform: translateY(0px);
  opacity: 0.9;
}

.ai-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.ai-output {
  font-size: 14px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
  white-space: pre-wrap;      /* preserve line breaks from AI */
  word-break: break-word;
}

body[data-theme="light"] .ai-output{
  color: rgba(20,24,32,0.88);
}

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

.reader-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.reading-progress.compact{
  margin-top: 0;
  flex: 1 1 auto;
}

.reader-toolbar-controls{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.reader-morph-toggle{
  min-height: 38px;
}

.translation-toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.translation-toggle input{
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.translation-col{
  display: block;
}

.reader.hide-translation .translation-col{
  display: none;
}

.reader.card{
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)),
    var(--panel2);
}

body[data-theme="light"] .reader.card{
  background:
    linear-gradient(180deg, rgba(250,248,242,0.95), rgba(255,255,255,0.98)),
    var(--panel2);
}

#original,
#translation{
  max-width: 36rem;
  margin: 0 auto;
}

#original{
  font-size: calc(1.12rem * var(--reader-font-size-multiplier, 1));
  line-height: 1.95;
}

#translation{
  margin-top: 4px;
  font-size: calc(1rem * var(--reader-font-size-multiplier, 1));
  line-height: 1.85;
  color: rgba(235,238,248,.82);
}

.reader-ghost-controls{
  display: none;
}

.study-tools-fab{
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 72;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 180px;
  padding: 18px 10px 18px 14px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: 18px 0 0 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
    rgba(18,24,38,0.94);
  color: var(--ink);
  box-shadow: -12px 14px 28px rgba(0,0,0,0.24);
  cursor: pointer;
  transform: translateY(-50%);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.study-tools-fab.open{
  transform: translateY(-50%) translateX(-392px);
  box-shadow: none;
}

.study-tools-fab-label{
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.study-tools-backdrop{
  display: none !important;
}

body[data-theme="light"] .study-tools-fab{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(245,242,235,0.94)),
    rgba(255,255,255,0.94);
  box-shadow: -10px 14px 30px rgba(26,34,52,0.12);
}

.study-tools-panel{
  position: fixed;
  top: 0;
  right: 0;
  z-index: 85;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(380px, calc(100vw - 28px));
  height: 100dvh;
  margin-top: 0;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  border-left: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)),
    rgba(15,20,32,0.98);
  box-shadow: -18px 0 44px rgba(0,0,0,0.34);
  transform: translateX(100%);
  transition: transform 220ms ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.study-tools-panel.open{
  transform: translateX(0);
}

body[data-theme="light"] .study-tools-panel{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,245,238,0.98)),
    rgba(255,255,255,0.98);
}

.exam-workspace-backdrop{
  display: none;
}

.exam-workspace{
  position: relative;
  width: 100%;
  margin-top: 18px;
  display: grid;
  grid-template-rows: auto auto;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)),
    rgba(11, 16, 27, 0.98);
  box-shadow: 0 28px 56px rgba(0,0,0,0.42);
}

body[data-theme="light"] .exam-workspace{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,245,238,0.98)),
    rgba(255,255,255,0.98);
}

.exam-workspace-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.exam-workspace-header h2{
  margin: 2px 0 0;
  font-size: 1.2rem;
}

.exam-workspace-body{
  min-height: 0;
  padding-right: 4px;
}

.exam-question-block{
  display: grid;
  gap: 10px;
}

.study-tools-groups{
  display: grid;
  gap: 14px;
}

.study-tools-group h3{
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted2);
}

.study-tools-buttons{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-card-layer{
  position: fixed;
  inset: 0;
  z-index: 110;
}

.word-card-backdrop{
  position: absolute;
  inset: 0;
}

.word-card{
  position: absolute;
  width: min(380px, calc(100vw - 24px));
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(15,20,32,0.98);
  box-shadow: 0 24px 48px rgba(0,0,0,0.32);
}

body[data-theme="light"] .word-card{
  background: rgba(255,255,255,0.99);
}

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

.word-card-token{
  font-size: 1.15rem;
  font-weight: 700;
}

.word-card-close{
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.4rem;
  cursor: pointer;
}

.word-card-section,
.word-card-style-point,
.word-card-shared-note,
.word-card-expand{
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.word-card-label{
  margin-bottom: 4px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
}

.word-card-style-point{
  color: #c8f0da;
}

body[data-theme="light"] .word-card-style-point{
  color: #1b6b46;
}

.word-card-actions,
.word-card-note-actions,
.word-card-tool-links{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.word-card-action-link,
.word-card-tool-link{
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.word-card-note-input{
  width: 100%;
  min-height: 108px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  font: inherit;
}

.reader-welcome{
  position: fixed;
  left: 50%;
  top: calc(78px + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(15,20,32,0.96);
  color: var(--ink);
  box-shadow: 0 14px 28px rgba(0,0,0,0.24);
  z-index: 100;
}

body[data-theme="light"] .reader-welcome{
  background: rgba(255,255,255,0.98);
}

.poetry-summary{
  max-width: 36rem;
  margin: 24px auto 0;
  display: grid;
  gap: 10px;
}

.poetry-detail{
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
}

.poetry-detail summary{
  cursor: pointer;
  font-weight: 600;
}

.audio-shell,
.settings-shell{
  max-width: 1180px;
  margin: 24px auto 0;
  padding: 0 18px 32px;
}

.audio-hero,
.settings-hero{
  padding: 28px;
  margin-bottom: 18px;
}

.audio-layout,
.settings-grid{
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.settings-grid{
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 980px){
  .audio-layout,
  .settings-grid{
    grid-template-columns: 1fr;
  }

  .study-tools-fab{
    top: auto;
    bottom: calc(18px + env(safe-area-inset-bottom));
    right: 14px;
    min-width: auto;
    min-height: auto;
    padding: 10px 14px;
    border-right: 1px solid var(--line-strong);
    border-radius: 999px;
    transform: none;
  }

  .study-tools-fab.open{
    transform: none;
  }

  .study-tools-fab-label{
    writing-mode: horizontal-tb;
    transform: none;
    letter-spacing: 0.08em;
  }

  .study-tools-panel{
    width: min(100vw, 420px);
  }
}

.audio-config-body,
.settings-card-body{
  display: grid;
  gap: 16px;
}

.audio-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.audio-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.audio-player-card .card-body{
  display: grid;
  gap: 14px;
}

.settings-field{
  display: grid;
  gap: 6px;
}

.settings-input{
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  font: inherit;
}

body[data-theme="light"] .settings-input{
  background: rgba(0,0,0,0.02);
}

@media (max-width: 720px){
  .reader-shell{
    padding: 14px 14px 18px;
  }

  .study-tools-panel{
    width: min(100vw, 380px);
    padding-top: calc(18px + env(safe-area-inset-top));
  }

  .exam-workspace{
    margin-top: 14px;
    padding: 16px;
    border-radius: 22px;
  }

  .word-card{
    left: 12px !important;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    top: auto !important;
    width: auto;
    border-radius: 24px 24px 18px 18px;
  }

  .reader-welcome{
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
    transform: none;
    border-radius: 18px;
    align-items: flex-start;
  }

  .reader-toolbar-controls{
    width: 100%;
    justify-content: space-between;
  }

  .audio-shell,
  .settings-shell{
    padding: 0 12px 24px;
  }

  .audio-hero,
  .settings-hero{
    padding: 20px;
  }

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

/* optional: nicer paragraphs if you later render markdown-ish text */
.ai-output p {
  margin: 0 0 10px 0;
}

.ai-output ul {
  margin: 0 0 10px 0;
  padding-left: 18px;
}

.ai-output li {
  margin: 0 0 6px 0;
}

/* inline code-ish styling */
.ai-output code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  padding: 0.15em 0.35em;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

/* blockquote styling (if AI outputs quoted Greek/English) */
.ai-output blockquote {
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 12px;
}

/* loading shimmer (apply class ai-loading on ai-output) */
.ai-output.ai-loading {
  position: relative;
  min-height: 46px;
  color: rgba(255, 255, 255, 0.55);
}

.ai-output.ai-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.00) 0%,
    rgba(255,255,255,0.06) 40%,
    rgba(255,255,255,0.00) 80%
  );
  animation: aiShimmer 1.2s infinite;
  pointer-events: none;
}

@keyframes aiShimmer {
  0% { transform: translateX(-40%); }
  100% { transform: translateX(40%); }
}

/* error styling (apply class ai-error on ai-output) */
.ai-output.ai-error {
  color: rgba(255, 190, 190, 0.92);
  border: 1px solid rgba(255, 120, 120, 0.20);
  background: rgba(255, 80, 80, 0.08);
  padding: 10px 12px;
  border-radius: 12px;
}

/* ------------------------------
   Podcast Panel
-------------------------------- */

.podcast-panel{
  grid-column: 1 / -1;
  overflow-anchor: none;
}

.section-video-panel{
  grid-column: 1 / -1;
}

.section-video-frame-wrap{
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,0.2);
}

body[data-theme="light"] .section-video-frame-wrap{
  background: rgba(0,0,0,0.02);
  border: 1px solid rgba(0,0,0,0.1);
}

.section-video-frame{
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}

.section-video-actions{
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.podcast-controls{
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.podcast-prefs{
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.podcast-prefs select{
  width: 100%;
  min-width: 0;
}

.podcast-audio{
  width: 100%;
  margin-top: 12px;
  accent-color: var(--accent);
}

.podcast-audio::-webkit-media-controls-panel{
  background: rgba(255,255,255,0.08);
}

.podcast-audio::-webkit-media-controls-play-button{
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

body[data-theme="light"] .podcast-audio::-webkit-media-controls-panel{
  background: rgba(0,0,0,0.04);
}

.podcast-player{
  margin-top: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

body[data-theme="light"] .podcast-player{
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.podcast-play-cluster{
  display: flex;
  align-items: center;
  gap: 8px;
}

.podcast-play{
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.podcast-skip{
  min-width: 44px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  cursor: pointer;
}

body[data-theme="light"] .podcast-skip{
  background: rgba(0,0,0,0.04);
}

.podcast-play:hover{
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(139,208,255,0.12);
}

.podcast-track{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.podcast-time{
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 44px;
  text-align: center;
}

.podcast-seek{
  width: 100%;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  outline: none;
}

body[data-theme="light"] .podcast-seek{
  background: rgba(0,0,0,0.1);
}

.podcast-seek::-webkit-slider-thumb{
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,208,255,0.18);
}

.podcast-seek::-moz-range-thumb{
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 0 3px rgba(139,208,255,0.18);
}

.podcast-volume{
  display: grid;
  grid-template-columns: auto 90px;
  align-items: center;
  gap: 8px;
}

.podcast-volume-icon{
  font-size: 0.9rem;
  opacity: 0.7;
}

.podcast-volume-slider{
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  outline: none;
}

body[data-theme="light"] .podcast-volume-slider{
  background: rgba(0,0,0,0.1);
}

.podcast-volume-slider::-webkit-slider-thumb{
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.podcast-volume-slider::-moz-range-thumb{
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.podcast-chapters{
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.podcast-chapter{
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  font-size: 0.8rem;
  cursor: pointer;
}

body[data-theme="light"] .podcast-chapter{
  background: rgba(0,0,0,0.04);
}

.podcast-chapter.active{
  border-color: rgba(139,208,255,.45);
  background: rgba(139,208,255,.15);
}

.podcast-transcript{
  margin-top: 10px;
  max-height: none;
  overflow: visible;
  overflow-anchor: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: rgba(255,255,255,0.03);
}

body[data-theme="light"] .podcast-transcript{
  background: rgba(0,0,0,0.02);
}

.podcast-line{
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 0.88rem;
  line-height: 1.35;
  cursor: pointer;
}

.podcast-line.active{
  border-color: rgba(139,208,255,.45);
  background: rgba(139,208,255,.12);
}

.podcast-speaker{
  font-weight: 700;
  margin-right: 6px;
}

.podcast-feedback{
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 820px){
  .podcast-prefs{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .podcast-player{
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }
  .podcast-play-cluster{
    grid-column: 1 / -1;
    justify-content: center;
  }
  .podcast-volume{
    grid-column: 1 / -1;
    justify-self: end;
  }
}


.hide-translation .columns {
  grid-template-columns: 1fr;
}

.ai-thinking {
  opacity: 0.6;
  font-style: italic;
}

.ai-link-note {
  margin: 10px 0 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted2);
  font-size: 0.9rem;
}

.ai-link-note strong {
  color: var(--ink);
}


/* === TRANSLATION TOGGLE — FINAL OVERRIDE === */
.reader.hide-translation #translation {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}


.reader.hide-translation #headtranslation {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}


.app-loading .reader,
.app-loading .inspector,
.app-loading .ai-panel {
  opacity: 0.4;
  pointer-events: none;
}

.app-loading-indicator {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.6);
  z-index: 200;
}

.app-loading-indicator.hidden {
  display: none;
}

.loading-card {
  width: min(420px, 90vw);
  background: rgba(18, 20, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.loading-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink);
}

.loading-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(139, 208, 255, 0.9), rgba(255, 214, 140, 0.9));
  transition: width 200ms ease;
}

.loading-meta {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted2);
}

.survey-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.6);
  z-index: 220;
}

.survey-modal-content {
  width: min(420px, 90vw);
  background: rgba(18, 20, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.survey-lede {
  color: var(--muted2);
  margin: 6px 0 14px;
}

.survey-required {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255, 214, 140, 0.2);
  color: rgba(255, 214, 140, 0.95);
}

.survey-rating {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.survey-rating-btn {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 8px 0;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.survey-rating-btn.active {
  border-color: rgba(139, 208, 255, 0.6);
  background: rgba(139, 208, 255, 0.18);
  transform: translateY(-1px);
}

.survey-modal textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

.survey-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* =========================
   Toggle Switches
   ========================= */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.86rem;
  color: var(--muted);
}

/* hide native checkbox */
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* track */
.switch .slider {
  width: 38px;
  height: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

/* knob */
.switch .slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--line);
  transition: transform 160ms ease;
}

/* checked state */
.switch input:checked + .slider {
  background: #7bb5df;
  border-color: #5a8fb6;
}

.switch input:checked + .slider::before {
  transform: translateX(16px);
}

/* label text */
.switch-label {
  font-size: 0.85rem;
  color: var(--muted2);
}

.switch input:checked + .slider {
  box-shadow: 0 0 0 2px rgba(123, 181, 223, 0.28);
}

.switch input:checked ~ .switch-label {
  color: var(--text);
}

.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px rgba(72, 97, 92, 0.24);
}

@media (prefers-reduced-motion: reduce) {
  .switch .slider,
  .switch .slider::before {
    transition: none;
  }
}

.hidden {
  display: none;
}


/* =========================
   Landing Page (Refined)
   ========================= */

body.landing {
  background:
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

/* --- top nav --- */

.landing-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

/* --- main hero --- */

.landing-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 90px 20px 60px;
  text-align: center;
}

.landing-main h1 {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}

.landing-tagline {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--muted);
  margin-bottom: 44px;
}

/* --- actions --- */

.landing-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.landing-actions .btn {
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.btn.primary {
  background: rgba(139,208,255,0.85);
  color: #000;
}

.btn.primary.large {
  padding: 12px 20px;
  font-size: 0.95rem;
  border-radius: 12px;
  font-weight: 650;
}

.btn.glow {
  position: relative;
  overflow: hidden;
  background: var(--accent);
  color: #0f1218;
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn.glow::after {
  content: none;
}

.btn.glow:hover::after {
  transform: translateY(-6px);
  opacity: 0.6;
}

.btn.ghost.softer {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.12);
  color: var(--text);
}

.btn.ghost.softer:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.22);
}

.btn.primary:hover {
  background: rgba(139,208,255,1);
}

.btn.subtle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.subtle:hover {
  border-color: rgba(139,208,255,0.5);
}

/* --- footer --- */

.landing-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 28px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted2);
  border-top: 1px solid var(--line);
}


/* =========================
   Library
   ========================= */

.library {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

.library h1 {
  margin-bottom: 22px;
}

.library-list {
  display: grid;
  gap: 14px;
}

.library-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 18px;
  flex-wrap: wrap;
}

.library-search-input {
  flex: 1 1 280px;
  min-width: 220px;
  padding: 10px 12px;

  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);

  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;

  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

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

.library-search-input:focus {
  border-color: rgba(139, 208, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 3px rgba(139, 208, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.library-search-count {
  font-size: 0.85rem;
  color: var(--muted2);
}

.library-item {
  padding: 20px 20px 18px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 22px 50px rgba(0,0,0,0.14);
}

.library-item:hover {
  background: rgba(139,208,255,0.1);
  border-color: rgba(139,208,255,0.32);
  transform: translateY(-4px);
  box-shadow: 0 26px 56px rgba(0,0,0,0.2);
}

body[data-theme="light"] .library-search-input{
  background: #ffffff;
  border: 1px solid rgba(20,24,32,0.14);
}

body[data-theme="light"] .library-search-input:focus{
  border-color: rgba(20,24,32,0.35);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(20,24,32,0.08);
}

body[data-theme="light"] .library-item{
  background:
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.96)),
    #ffffff;
  border: 1px solid rgba(20,24,32,0.12);
  box-shadow: 0 20px 48px rgba(26,34,52,0.08);
}

body[data-theme="light"] .library-language{
  border: 1px solid rgba(20,24,32,0.2);
  background: rgba(0,0,0,0.03);
}

body[data-theme="light"] .library-item:hover{
  background: rgba(255,255,255,0.98);
  border-color: rgba(20,24,32,0.22);
  box-shadow: 0 24px 58px rgba(26,34,52,0.12);
  transform: translateY(-4px);
}

.library-title {
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 1.18rem;
  line-height: 1.35;
  font-weight: 700;
}

.library-meta {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.6;
}

.library-language {
  display: inline-block;
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.08);
}

.library-language-greek {
  color: #7fc5ff;
  border-color: rgba(127,197,255,0.55);
  background: rgba(38,125,224,0.22);
}

.library-language-latin {
  color: #ff9a9a;
  border-color: rgba(255,115,115,0.55);
  background: rgba(191,45,45,0.2);
}

.library-language-spanish {
  color: #ffde66;
  border-color: rgba(255, 214, 64, 0.72);
  background: rgba(170, 130, 10, 0.28);
}

.library-item:hover .library-language {
  border-color: rgba(139,208,255,0.6);
}

.library-item:hover .library-language-greek {
  border-color: rgba(127,197,255,0.85);
}

.library-item:hover .library-language-latin {
  border-color: rgba(255,115,115,0.85);
}

.library-item:hover .library-language-spanish {
  border-color: rgba(255, 214, 64, 0.95);
}

body[data-theme="light"] .library-language-greek {
  color: #0e4ea6;
  border-color: rgba(32,94,182,0.35);
  background: rgba(88,149,240,0.16);
}

body[data-theme="light"] .library-language-latin {
  color: #a32020;
  border-color: rgba(173,46,46,0.35);
  background: rgba(214,79,79,0.14);
}

body[data-theme="light"] .library-language-spanish {
  color: #8a6200;
  border-color: rgba(156, 117, 0, 0.45);
  background: rgba(255, 218, 86, 0.24);
}

.library-meta {
  font-size: 0.85rem;
  color: var(--muted2);
}

.btn {
  padding: 0.8rem 1.8rem;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.btn.ghost:hover {
  background: var(--bg-soft);
}

body[data-theme="light"] .btn{
  background: #ffffff;
  border: 1px solid rgba(20,24,32,0.18);
  color: #1f2430;
  box-shadow: none;
}

body[data-theme="light"] .btn.ghost:hover{
  background: rgba(0,0,0,0.04);
}

.word.has-annotation {
  text-decoration: underline dotted rgba(181,255,207,.6);
}

/* =========================
   Annotation input
   ========================= */

#annotationInput {
  width: 100%;
  min-height: 90px;
  resize: vertical;

  padding: 10px 12px;
  margin-top: 6px;

  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);

  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;

  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

#annotationInput::placeholder {
  color: var(--muted2);
}

/* focus state */
#annotationInput:focus {
  border-color: rgba(139, 208, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 3px rgba(139, 208, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#annotationInput.has-note {
  background: rgba(181, 255, 207, 0.06);
}

.library-author {
  margin-bottom: 2.5rem;
}

.library-author-name {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
  color: var(--ink);
}

.library-author-works {
  display: grid;
  gap: 0.75rem;
}

.compare-actions {
  margin-top: 1rem;
}

.compare-links {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.compare-links svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.compare-windows {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
}

.compare-window {
  position: absolute;
  width: min(420px, 90vw);
  max-height: 70vh;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
}

.compare-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
}

.compare-window-header:active {
  cursor: grabbing;
}

.compare-window-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.compare-window-actions {
  display: inline-flex;
  gap: 6px;
}

.compare-window-body {
  padding: 12px;
  overflow: auto;
}

.compare-window-body .text {
  font-size: 0.95rem;
}

.compare-window.connecting {
  border-color: rgba(139, 208, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(139, 208, 255, 0.25);
}

.compare-link-line {
  pointer-events: none;
}

.nav-btn.active {
  background: rgba(139, 208, 255, 0.18);
  border-color: rgba(139, 208, 255, 0.55);
}

.word-connecting {
  background: rgba(255, 214, 140, 0.2);
  border-radius: 4px;
}

.compare-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
}

.compare-modal.hidden {
  display: none;
}

.compare-modal-content {
  width: min(420px, 90vw);
  background: rgba(16, 18, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

body[data-theme="light"] .compare-modal-content {
  background: var(--panel2);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(26, 34, 52, 0.16);
}

.compare-modal-body {
  display: grid;
  gap: 12px;
  margin: 12px 0 18px;
}

.compare-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.exam-modal-content {
  width: min(620px, 94vw);
}

body[data-theme="light"] .exam-modal-content {
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border: 1px solid rgba(26, 34, 52, 0.12);
  box-shadow: 0 16px 34px rgba(26, 34, 52, 0.16);
}

body[data-theme="light"] .exam-modal-content h2 {
  color: #1d2534;
}

body:not([data-theme="light"]) .exam-modal-content {
  background: linear-gradient(180deg, rgba(14, 18, 30, 0.98), rgba(9, 12, 22, 0.98));
  border: 1px solid rgba(139, 208, 255, 0.24);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.52);
}

body:not([data-theme="light"]) .exam-modal-content h2 {
  color: #eef3ff;
}

.exam-modal-body {
  gap: 10px;
}

body[data-theme="light"] .exam-modal-body .meta {
  color: rgba(26, 34, 52, 0.72);
}

body[data-theme="light"] .exam-modal-body select {
  background: #ffffff;
  border: 1px solid rgba(26, 34, 52, 0.16);
  color: #1d2534;
}

body[data-theme="light"] .exam-modal-body select:focus {
  border-color: rgba(108, 122, 146, 0.56);
  box-shadow: 0 0 0 3px rgba(108, 122, 146, 0.18);
}

body:not([data-theme="light"]) .exam-modal-body .meta {
  color: rgba(231, 237, 252, 0.82);
}

body:not([data-theme="light"]) .exam-modal-body select {
  background: rgba(14, 20, 34, 0.92);
  border-color: rgba(139, 208, 255, 0.28);
}

.exam-modal-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
}

body[data-theme="light"] .exam-modal-textarea {
  background: #ffffff;
  border: 1px solid rgba(26, 34, 52, 0.16);
  color: #1d2534;
}

body[data-theme="light"] .exam-modal-textarea:focus {
  outline: none;
  border-color: rgba(108, 122, 146, 0.56);
  box-shadow: 0 0 0 3px rgba(108, 122, 146, 0.18);
}

body:not([data-theme="light"]) .exam-modal-textarea {
  background: rgba(10, 16, 28, 0.92);
  border-color: rgba(139, 208, 255, 0.32);
}

body:not([data-theme="light"]) .exam-modal-textarea:focus {
  outline: none;
  border-color: rgba(139, 208, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(139, 208, 255, 0.18);
}

.exam-modal-confirm {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted2);
}

body[data-theme="light"] .exam-modal-confirm {
  color: rgba(26, 34, 52, 0.72);
}

body[data-theme="light"] #examModalStatus {
  color: rgba(26, 34, 52, 0.8);
}

body:not([data-theme="light"]) .exam-modal-confirm {
  color: rgba(231, 237, 252, 0.74);
}

body:not([data-theme="light"]) #examModalStatus {
  color: rgba(231, 237, 252, 0.86);
}

.autoflash-modal-content {
  width: min(500px, 92vw);
}

.autoflash-modal-body {
  gap: 10px;
}

.exam-question-block {
  margin-top: 6px;
  display: grid;
  gap: 10px;
}

.exam-question-meta {
  font-size: 0.8rem;
  color: var(--muted2);
}

.exam-question-text {
  font-size: 0.95rem;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

body[data-theme="light"] .exam-question-text {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
}

.exam-answer-input {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.45;
}

body[data-theme="light"] .exam-answer-input {
  background: rgba(255, 255, 255, 0.92);
}

.exam-question-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.exam-feedback {
  border-radius: 12px;
  border: 1px solid rgba(139, 208, 255, 0.28);
  background: rgba(139, 208, 255, 0.1);
  padding: 10px 12px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.45;
}

.exam-fixed-answer {
  border-radius: 12px;
  border: 1px solid rgba(120, 255, 170, 0.35);
  background: rgba(120, 255, 170, 0.09);
  padding: 10px 12px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.5;
}

.exam-fixed-answer.is-typing::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: rgba(120, 255, 170, 0.95);
  animation: exam-fix-cursor-blink 0.9s steps(1, end) infinite;
}

.exam-fix-added {
  background: rgba(120, 255, 170, 0.25);
  color: #d7ffe8;
  border-radius: 4px;
}

body[data-theme="light"] .exam-fix-added {
  background: rgba(64, 182, 112, 0.26);
  color: #124f2e;
}

@keyframes exam-fix-cursor-blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.has-shared-annotation {
  background: rgba(150, 150, 150, 0.15);
}

#annotationSearch {
  min-width: 220px;
  width: 260px;
  padding: 10px;

  margin-top: 6px;

  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);

  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;

  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

#annotationSearch:focus,
#annotationSearch:active {
  border-color: rgba(120, 255, 170, 0.7);
  background: rgba(120, 255, 170, 0.08);
  box-shadow: 0 0 0 3px rgba(120, 255, 170, 0.26);
}

.annotation-status {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.annotation-status.error {
  color: #ffcccc;
  background: rgba(255,80,80,0.08);
  border-color: rgba(255,120,120,0.26);
}

.annotation-status.success {
  color: #b9ffd8;
  background: rgba(120,255,170,0.08);
  border-color: rgba(120,255,170,0.26);
}

.flashcard-adder {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.flashcard-adder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

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

.flashcard-picker-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.flashcard-picker-row input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
}

.flashcard-hint {
  font-size: 0.85rem;
  color: var(--muted2);
}

/* =========================
   Flashcards Page
   ========================= */

.flashcards-page .topbar {
  position: static;
}

.flashcards-shell {
  max-width: 1200px;
  margin: 22px auto 40px;
  padding: 0 18px 20px;
}

.flashcards-hero {
  padding: 20px;
  margin-bottom: 18px;
}

.flashcards-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
}

@media (max-width: 1000px) {
  .flashcards-grid {
    grid-template-columns: 1fr;
  }
}

.empty-state {
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--muted);
}

.set-list {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flashcard-set {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.flashcard-set.active {
  border-color: rgba(139,208,255,0.5);
  background: rgba(139,208,255,0.06);
}

.flashcard-set-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.set-title {
  font-weight: 650;
}

.set-meta {
  color: var(--muted2);
  font-size: 0.9rem;
}

.flashcard-set-actions {
  display: flex;
  gap: 8px;
}

.flashcard-set-actions .danger {
  color: #ffb3b3;
}

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

.review-actions {
  display: flex;
  gap: 8px;
}

.review-actions .active {
  border-color: rgba(139,208,255,0.5);
  background: rgba(139,208,255,0.08);
}

.flashcard-review-card {
  min-height: 220px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.flip-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.fc-face {
  display: none;
}

.flip-card .front {
  display: block;
}

.flip-card.show-back .front {
  display: none;
}

.flip-card.show-back .back {
  display: block;
}

.fc-term {
  font-size: 1.2rem;
  font-weight: 650;
}

.fc-sub {
  margin-top: 6px;
  color: var(--muted);
}

.fc-sub.subtle {
  color: var(--muted2);
}

.fc-translation {
  margin-top: 8px;
  color: var(--muted);
  font-style: italic;
}

.review-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.review-buttons {
  display: flex;
  gap: 8px;
}

.set-cards-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.flashcard-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.flashcard-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.fc-word {
  font-weight: 640;
}

.fc-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.fc-meta.subtle {
  color: var(--muted2);
}

.review-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: grid;
  place-items: center;
  padding: 18px;
}

.reviewing-flashcards {
  overflow: hidden;
}

.review-overlay.hidden {
  display: none;
}

.review-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.42);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

body[data-theme="light"] .review-overlay-backdrop {
  background: rgba(247, 249, 252, 0.56);
}

.review-overlay-dialog {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel2);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
  padding: 18px;
  display: grid;
  gap: 12px;
}

body[data-theme="light"] .review-overlay-dialog {
  box-shadow: 0 16px 36px rgba(26, 34, 52, 0.16);
}

.review-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.review-overlay-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.review-overlay-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.overlay-flip-card {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  padding: 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  perspective: 1200px;
  text-align: center;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 180ms ease;
}

body[data-theme="light"] .overlay-flip-card {
  background: rgba(0,0,0,0.02);
}

.overlay-flip-card:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 208, 255, 0.42);
  box-shadow: 0 0 0 4px rgba(139, 208, 255, 0.12);
}

.overlay-card-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  padding: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 380ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.overlay-front {
  transform: rotateY(0deg);
}

.overlay-back {
  transform: rotateY(180deg);
}

.overlay-flip-card.show-back .overlay-front {
  transform: rotateY(-180deg);
}

.overlay-flip-card.show-back .overlay-back {
  transform: rotateY(0deg);
}

.overlay-card-face .fc-term {
  font-size: clamp(1.2rem, 2.8vw, 1.9rem);
}

.overlay-card-face .fc-sub {
  margin-top: 12px;
  font-size: 1.02rem;
  line-height: 1.5;
}

.review-overlay-controls {
  display: flex;
  justify-content: flex-end;
}

.autoflash-dialog {
  width: min(640px, 100%);
}

.autoflash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.autoflash-field {
  display: grid;
  gap: 6px;
}

.autoflash-field input,
.autoflash-field select {
  width: 100%;
  min-width: 0;
}

.autoflash-status-error {
  color: #ffb3b3;
}

.autoflash-status-success {
  color: #b9ffd8;
}

@media (max-width: 720px) {
  .review-overlay {
    padding: 10px;
  }

  .review-overlay-dialog {
    padding: 12px;
    gap: 10px;
  }

  .overlay-flip-card {
    min-height: 240px;
  }

  .overlay-card-face {
    padding: 14px;
  }

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

@media (prefers-reduced-motion: reduce) {
  .overlay-card-face {
    transition: none;
  }
}

/* =========================
   Memorize Page
   ========================= */

.memorize-page .topbar {
  position: static;
}

.memorize-shell {
  max-width: 1200px;
  margin: 22px auto 40px;
  padding: 0 18px 20px;
}

.memorize-hero {
  padding: 20px;
  margin-bottom: 18px;
}

.memorize-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
}

@media (max-width: 1000px) {
  .memorize-grid {
    grid-template-columns: 1fr;
  }
}

.selection-body {
  max-height: 70vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.02);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sentence-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 6px 0;
}

.sentence-text {
  line-height: 1.4;
}

.practice-body {
  min-height: 260px;
}

.practice-input {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  margin-top: 6px;
}

.practice-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.practice-feedback {
  margin-top: 10px;
}

.practice-feedback .success {
  color: #a7ffc7;
}

.practice-feedback .error {
  color: #ffb3b3;
}

.diff-list {
  padding-left: 16px;
  margin: 4px 0 0;
}

.answer-text {
  margin-top: 4px;
  color: var(--muted);
}

.prompt-mode {
  font-size: 0.9rem;
  color: var(--muted2);
}

.practice-prompt {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}


/* =========================
   Upgrade Page
   ========================= */

body.upgrade {
  background:
    radial-gradient(1000px 600px at 20% 0%, rgba(90,140,255,.22), transparent 60%),
    radial-gradient(1000px 600px at 85% 8%, rgba(0,255,200,.12), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

.upgrade-shell {
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 18px 40px;
}

.upgrade-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 22px;
  padding: 24px;
}

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

.eyebrow {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--muted2);
  margin: 0 0 8px;
}

.upgrade-hero h1 {
  margin: 0 0 14px;
  font-size: 2rem;
  letter-spacing: 0.01em;
}

.lede {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 18px;
}

.price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 10px 0 8px;
}

.price-tag {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 180px;
}

.price {
  font-size: 1.4rem;
  font-weight: 700;
}

.price-sub {
  color: var(--muted2);
  font-size: 0.9rem;
}

.upgrade-cta-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.cta-title {
  font-weight: 650;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

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

.perk {
  display: flex;
  gap: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.perk-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(139,208,255,0.9);
  box-shadow: 0 0 0 6px rgba(139,208,255,0.12);
  margin-top: 6px;
}

.fine-print {
  color: var(--muted2);
  margin-top: 12px;
  font-size: 0.9rem;
}

/* =========================
   Library Page
   ========================= */

.library-shell {
  max-width: 1100px;
  margin: 28px auto 60px;
  padding: 0 18px;
}

.library-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 22px;
  padding: 28px;
  margin-bottom: 24px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    var(--panel2);
  box-shadow: 0 28px 70px rgba(0,0,0,0.22);
}

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

@media (max-width: 640px) {
  .hide-on-mobile {
    display: none !important;
  }
}

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

.library-hero .stat {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.library-hero .stat-label {
  color: var(--muted2);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.library-hero .stat-value {
  font-weight: 620;
  line-height: 1.5;
}

.bookmark-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.bookmark-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}

.bookmark-label {
  font-weight: 650;
}

.bookmark-meta {
  color: var(--muted2);
  font-size: 0.9rem;
}

.bookmark-actions {
  display: flex;
  gap: 8px;
}
