/* ── TOKENS ── */
:root {
  --bg:      #F0EBE1;
  --surface: #FAF7F2;
  --text:    #1A1816;
  --muted:   #9B8F80;
  --accent:  #C2AF96;
  --line:    #E2D9CE;

  --font-d: 'Cormorant', Georgia, serif;
  --font-b: 'Crimson Pro', Georgia, serif;

  --speed: 500ms;
  --ease:  cubic-bezier(0.4, 0, 0.2, 1);
}

body.deep {
  --bg:      #E6DDD1;
  --surface: #F2EDE5;
  --speed:   1200ms;
}

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

body {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.65;
  transition: background var(--speed) var(--ease);
  -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  z-index: 1;
}

/* ── TYPE ── */
.wordmark {
  font-family: var(--font-d);
  font-style: italic;
  font-weight: 400;
  font-size: 3.6rem;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.wordmark-sm {
  font-family: var(--font-d);
  font-style: italic;
  font-weight: 400;
  font-size: 1.2rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.muted { color: var(--muted); }

/* ── INPUTS ── */
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
  font-family: var(--font-b);
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.25s;
}
input::placeholder { color: var(--accent); }
input:focus { border-bottom-color: var(--text); }

textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.25rem 1.5rem;
  font-family: var(--font-b);
  font-size: 1rem;
  color: var(--text);
  line-height: 1.75;
  outline: none;
  resize: vertical;
  min-height: 300px;
  transition: border-color 0.25s;
}
textarea::placeholder { color: var(--accent); }
textarea:focus { border-color: var(--muted); }

/* ── BUTTONS ── */
.btn-main {
  background: var(--text);
  color: var(--surface);
  border: none;
  padding: 0.6rem 1.4rem;
  font-family: var(--font-b);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 2px;
  transition: opacity 0.2s;
}
.btn-main:hover    { opacity: 0.75; }
.btn-main:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.btn-text:hover { color: var(--text); }

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--text); }

.pill {
  background: none;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 0.35rem 0.9rem;
  font-family: var(--font-b);
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.pill:hover  { border-color: var(--muted); color: var(--text); }
.pill.on     { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ── AUTH SCREEN ── */
.auth-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 2rem;
}
.auth-tagline {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  margin-top: -2rem;
}
.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.tab-row {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.tab.active, .tab:hover { color: var(--text); }
.err-text {
  color: #9B5050;
  font-size: 0.85rem;
  min-height: 1rem;
  font-style: italic;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-style: italic;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
#google-signin-btn { min-height: 44px; }

/* ── SHARED HEADER ── */
.site-header,
.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 2.5rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.subject-label {
  font-size: 0.82rem;
  font-style: italic;
}

/* ── INPUT SCREEN ── */
#screen-input { overflow: hidden; }

.input-main {
  flex: 1;
  min-height: 0;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  padding: 1.75rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-hero { display: flex; flex-direction: column; gap: 0.3rem; }

.input-heading {
  font-family: var(--font-d);
  font-size: 2.4rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.1;
}
.input-sub {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

#file-upload { display: none; }

.upload-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
  white-space: nowrap;
}
.upload-btn:hover { color: var(--text); }

.upload-filename {
  font-style: italic;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Textarea card ── */
.notes-drop-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.25s;
}
.notes-drop-wrap:focus-within {
  border-color: var(--muted);
}
.notes-drop-wrap textarea {
  flex: 1;
  min-height: 0;
  border: none;
  background: transparent;
  border-radius: 3px 3px 0 0;
  padding: 1.25rem 1.5rem 1rem;
  resize: none;
}
.notes-drop-wrap textarea:focus {
  border-color: transparent;
}

.notes-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem 0.7rem;
  border-top: 1px solid var(--line);
}
.notes-card-footer .muted { font-size: 0.8rem; }

.notes-drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 3px;
  color: var(--muted);
  font-style: italic;
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.notes-drop-wrap.drag-over .notes-drop-overlay { opacity: 1; }

.spin {
  width: 13px; height: 13px;
  border: 1px solid var(--line);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mode cards ── */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.mode-card {
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.85rem 1.1rem 0.9rem;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-b);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.2s, background 0.2s;
}
.mode-card:hover { border-color: var(--muted); }
.mode-card.active {
  border-color: var(--text);
  background: var(--surface);
}
.mode-card-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.mode-card-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.mode-card.active .mode-card-dot {
  background: var(--text);
  border-color: var(--text);
}
.mode-card-name {
  font-size: 0.88rem;
  color: var(--text);
}
.mode-card-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Submit row ── */
.input-submit-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

/* ── PROCESSING SCREEN ── */
#screen-processing {
  align-items: center;
  justify-content: center;
}
.proc-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}
.proc-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: proc 1.8s ease-in-out infinite;
}
@keyframes proc {
  0%,100% { transform: scale(1);   opacity: 0.4; }
  50%      { transform: scale(2.2); opacity: 1; }
}
.proc-msg {
  font-family: var(--font-d);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
  transition: opacity 0.4s;
}

/* ── NAV HINT ── */
.nav-hint {
  font-size: 0.75rem;
  color: var(--accent);
  font-style: italic;
  pointer-events: none;
  transition: opacity 0.6s;
}
.nav-hint.hidden { opacity: 0; }

/* ── STUDY SCREEN ── */
#screen-study { overflow: hidden; }

.mode-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.mode-tab {
  background: none;
  border: none;
  font-family: var(--font-b);
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.mode-tab.active, .mode-tab:hover { color: var(--text); }
.nav-dot { color: var(--line); font-size: 0.75rem; }

/* ── STUDY BODY + MODES ── */
.study-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.mode {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease);
}
.mode.active {
  opacity: 1;
  pointer-events: all;
}

/* ── FLOW MODE ── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 2.5rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s;
}
.crumb:hover { opacity: 0.8; }
.crumb.done  { opacity: 0.65; }
.crumb.active { opacity: 1; }
.crumb-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  flex-shrink: 0;
  transition: background 0.3s, border-color 0.3s;
}
.crumb.done   .crumb-dot  { background: var(--accent); }
.crumb.active .crumb-dot  { background: var(--text); border-color: var(--text); }
.crumb-name {
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  max-width: 0;
  overflow: hidden;
  transition: max-width 0.4s var(--ease);
}
.crumb.active .crumb-name { max-width: 160px; }
.crumb-line {
  width: 18px; height: 1px;
  background: var(--line);
  flex-shrink: 0;
}

.flow-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.flow-scroll::before,
.flow-scroll::after {
  content: '';
  flex: 1;
  min-height: 1.5rem;
}
.flow-inner {
  max-width: min(1000px, 92vw);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  opacity: 1;
  transition: opacity 0.22s ease;
}
.flow-inner.fading { opacity: 0; }

.flow-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
}
.flow-title {
  font-family: var(--font-d);
  font-size: clamp(2.6rem, 5vw, 3.8rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.flow-body {
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  line-height: 1.85;
  color: var(--text);
}
.flow-ctx {
  padding-left: 1.25rem;
  border-left: 1px solid var(--accent);
  color: var(--muted);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.75;
  display: none;
}
.flow-ctx.show { display: block; }

.flow-check-box {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.flow-check-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent);
}

.flow-done {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.flow-done-title {
  font-family: var(--font-d);
  font-size: 2.8rem;
  font-style: italic;
  font-weight: 400;
}
.flow-done-sub { color: var(--muted); font-size: 0.95rem; font-style: italic; }
.flow-done-btns { display: flex; gap: 0.75rem; }

.flow-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 2.5rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--bg);
  transition: background var(--speed) var(--ease);
}
.flow-pos {
  margin-left: auto;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* ── MAP MODE ── */
#mode-map { flex-direction: row; overflow: hidden; }

.map-sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 1.5rem 0;
}
.map-section-hdr {
  padding: 0.75rem 1.75rem 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.map-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  padding: 0.55rem 1.75rem;
  font-family: var(--font-b);
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: color 0.2s, border-color 0.2s;
}
.map-item:hover  { color: var(--text); }
.map-item.active { color: var(--text); border-left-color: var(--text); }
.map-item.italic { font-style: italic; }

.map-vocab-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.75rem;
  font-family: var(--font-b);
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.map-vocab-toggle:hover { color: var(--text); }
.map-vocab-items { display: none; padding-bottom: 0.5rem; }
.map-vocab-items.open { display: block; }
.map-vocab-term {
  padding: 0.3rem 1.75rem 0.3rem 2.25rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
  cursor: pointer;
  transition: color 0.2s;
}
.map-vocab-term:hover { color: var(--text); }

.map-main {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem 3.5rem;
  background: var(--surface);
}
.map-main-inner { max-width: 620px; margin: 0 auto; }
.map-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.map-heading {
  font-family: var(--font-d);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 1.5rem;
}
.map-intro {
  color: var(--muted);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: 2rem;
}
.map-steps-list { display: flex; flex-direction: column; gap: 1.25rem; }
.map-step { border-bottom: 1px solid var(--line); padding-bottom: 1.25rem; }
.map-step:last-child { border-bottom: none; }
.map-step-n {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.map-step-body { font-size: 1rem; line-height: 1.75; }
.map-step-ctx  {
  font-size: 0.92rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.45rem;
  line-height: 1.65;
}
.map-check-block {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 2px;
}
.map-check-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.map-summary-body { font-size: 1.05rem; line-height: 1.8; }

/* MAP vocab detail */
.map-vocab-detail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.map-vocab-card {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1rem 1.1rem;
}
.map-vocab-card strong { display: block; font-size: 0.95rem; margin-bottom: 0.2rem; }
.map-vocab-card span   { font-size: 0.88rem; color: var(--muted); line-height: 1.5; }

/* ── DRILL MODE ── */
#mode-drill {
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem;
}
.drill-status { font-size: 0.82rem; letter-spacing: 0.04em; }

.drill-card {
  width: 100%;
  max-width: 460px;
  height: 250px;
  perspective: 1000px;
  cursor: pointer;
  flex-shrink: 0;
}
.drill-inner-card {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease);
}
.drill-card.flipped .drill-inner-card { transform: rotateY(180deg); }

.drill-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  text-align: center;
  gap: 0.75rem;
}
.drill-face-back {
  transform: rotateY(180deg);
  background: var(--bg);
}
.drill-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent);
}
.drill-term {
  font-family: var(--font-d);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.25;
}
.drill-def  { font-size: 1rem; line-height: 1.65; color: var(--text); }
.drill-hint {
  font-size: 0.75rem;
  color: var(--accent);
  font-style: italic;
  position: absolute;
  bottom: 1.1rem;
}

.drill-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
}
.drill-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 0.45rem 1.4rem;
  font-family: var(--font-b);
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.drill-btn:hover     { color: var(--text); border-color: var(--muted); }
.drill-btn.confirm   { border-color: var(--text); color: var(--text); }
.drill-btn.confirm:hover { background: var(--text); color: var(--surface); }

/* Drill summary */
.drill-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}
.drill-score {
  font-family: var(--font-d);
  font-style: italic;
  font-size: 5rem;
  font-weight: 400;
  line-height: 1;
}
.drill-score-sub { color: var(--muted); font-size: 0.9rem; font-style: italic; }
.drill-summary-btns { display: flex; gap: 0.75rem; margin-top: 0.75rem; }

/* ── CHAT ── */
.chat-fab {
  position: fixed;
  bottom: 2rem; right: 2rem;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  border: none;
  cursor: pointer;
  font-family: var(--font-b);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  box-shadow: 0 2px 14px rgba(26,24,22,0.18);
  transition: opacity 0.2s, transform 0.2s;
}
.chat-fab:hover { opacity: 0.8; transform: scale(1.06); }

.chat-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 52vh;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transform: translateY(100%);
  transition: transform 0.38s var(--ease);
}
.chat-drawer.open { transform: translateY(0); }

.chat-drawer-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
  font-style: italic;
}
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.chat-msg {
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 72%;
}
.chat-bot  { align-self: flex-start; color: var(--text); }
.chat-user { align-self: flex-end; color: var(--muted); font-style: italic; }
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.75rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-input-row input { flex: 1; font-size: 0.95rem; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,24,22,0.18);
  opacity: 0;
  pointer-events: none;
  z-index: 85;
  transition: opacity 0.3s;
}
.overlay.visible { opacity: 1; pointer-events: all; }

/* ── LIBRARY SCREEN ── */
#screen-library { overflow-y: auto; }

.library-main {
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.library-heading {
  font-family: var(--font-d);
  font-style: italic;
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.2;
}
.library-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.library-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 1rem;
}
.library-item {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: opacity 0.2s;
}
.library-item:first-child { border-top: 1px solid var(--line); }
.library-item:hover { opacity: 0.75; }
.library-item-body { flex: 1; min-width: 0; }
.library-item-subject {
  font-family: var(--font-d);
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 0.3rem;
}
.library-item-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.library-item-summary {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-item-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  flex-shrink: 0;
  transition: color 0.2s;
  line-height: 1;
  align-self: center;
}
.library-item-del:hover { color: #9B5050; }

/* ── FULLSCREEN BUTTON ── */
.btn-fullscreen {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: color 0.2s;
  opacity: 0.6;
}
.btn-fullscreen:hover { color: var(--text); opacity: 1; }

/* ── GOAL TIMER ── */
.goal-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.btn-goal {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.8rem;
  font-style: italic;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
  opacity: 0.7;
}
.btn-goal:hover { color: var(--text); opacity: 1; }
.btn-goal.active { color: var(--text); opacity: 1; }

.goal-popover {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(26,24,22,0.08);
}
.goal-popover input[type="number"] {
  width: 52px;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.2rem 0;
  font-size: 0.95rem;
  text-align: center;
  background: transparent;
}
.goal-popover input[type="number"]::-webkit-outer-spin-button,
.goal-popover input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.goal-popover .muted { font-size: 0.82rem; }

/* ── MODE SELECT (input screen) ── */
.mode-select {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  align-self: flex-start;
}
.mode-select-btn {
  background: none;
  border: none;
  padding: 0.45rem 1.1rem;
  font-family: var(--font-b);
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.mode-select-btn + .mode-select-btn { border-left: 1px solid var(--line); }
.mode-select-btn.active { background: var(--text); color: var(--surface); }
.mode-select-btn:not(.active):hover { color: var(--text); }

/* ── HIGHLIGHTS ── */
mark.hl-yellow { background: #FFE066; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.hl-green  { background: #A8E6A3; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.hl-pink   { background: #FFB3C1; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.hl-blue   { background: #A3D4FF; color: inherit; border-radius: 2px; padding: 0 1px; }

/* ── ANNOTATION TOOLBAR ── */
.ann-toolbar {
  position: fixed;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 0.3rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 2px 12px rgba(26,24,22,0.12);
}
.ann-color {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, border-color 0.15s;
  color: var(--text);
}
.ann-color:hover { transform: scale(1.15); border-color: var(--muted); }

/* ── EMOJI PICKER ── */
.emoji-picker {
  position: fixed;
  z-index: 310;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.45rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: 0 4px 20px rgba(26,24,22,0.12);
  max-width: 284px;
}
.emoji-btn {
  width: 30px; height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.emoji-btn:hover { background: var(--line); }

/* ── STUDY TOAST ── */
.study-toast {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
  z-index: 200;
  transform: translateY(-100%);
  transition: transform 0.4s var(--ease);
}
.study-toast.show { transform: translateY(0); }

/* ── PRICING SCREEN ── */
#screen-pricing { overflow-y: auto; }

.pricing-main {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  padding: 3rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.pricing-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.pricing-heading {
  font-family: var(--font-d);
  font-size: 2.6rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.1;
}
.pricing-sub {
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

.pricing-tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}

.tier-card {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1.75rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}
.tier-highlighted {
  border-color: var(--text);
  background: var(--surface);
}

.tier-badge {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.8rem;
  border-radius: 0 0 3px 3px;
  white-space: nowrap;
}

.tier-name {
  font-family: var(--font-d);
  font-size: 1.9rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1;
}
.tier-price {
  font-family: var(--font-d);
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1;
  color: var(--text);
}
.tier-period {
  font-size: 1rem;
  color: var(--muted);
}
.tier-tagline {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-top: -0.5rem;
}

.tier-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}
.tier-features li {
  font-size: 0.875rem;
  color: var(--muted);
  padding-left: 1.1rem;
  position: relative;
  line-height: 1.45;
}
.tier-features li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.72rem;
  top: 0.1em;
}

.tier-btn {
  width: 100%;
  padding: 0.6rem 1rem;
  font-family: var(--font-b);
  font-size: 0.88rem;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  transition: opacity 0.2s;
  margin-top: 0.25rem;
}
.tier-btn-current {
  opacity: 0.45;
  cursor: default;
}
.tier-btn-upgrade {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.tier-btn-upgrade:hover { opacity: 0.8; }
