/* Subject view styles */
.subject-view {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 76px);
}

.navigator {
  border-right: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 32px 22px;
  position: sticky;
  top: 76px;
  align-self: start;
  height: calc(100vh - 76px);
  overflow-y: auto;
}
.nav-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 14px;
}
.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 28px;
}
.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  font-weight: 500;
  font-family: var(--sans);
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-tab:hover { background: rgba(0,0,0,0.04); color: var(--ink); }
.nav-tab.active { background: var(--ink); color: var(--paper); }
.nav-tab .count { margin-left: auto; font-family: var(--mono); font-size: 11px; opacity: 0.7; }

.nav-sections {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-section {
  display: flex;
  align-items: center;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: var(--sans);
  border-left: 2px solid transparent;
  padding-left: 14px;
  margin-left: -2px;
  transition: background 0.12s ease;
  line-height: 1.4;
}
.nav-section:hover { background: rgba(0,0,0,0.04); color: var(--ink); }
.nav-section.active { background: rgba(198,106,61,0.10); color: var(--ink); border-left-color: var(--accent); font-weight: 500; }

.subject-main {
  padding: 40px 56px 80px;
  max-width: 880px;
  width: 100%;
}
.school-system-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 2px 7px;
}

.subject-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 36px;
  gap: 20px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 24px;
}
.subject-header .crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0;
  margin-bottom: 12px;
  cursor: pointer;
}
.subject-header .crumb:hover { color: var(--ink); }
.subject-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(36px, 4.5vw, 52px);
  font-weight: 600;
  line-height: 1.0;
  letter-spacing: -0.02em;
}
.subject-header .accent-bar {
  display: inline-block;
  width: 56px;
  height: 4px;
  margin-bottom: 10px;
}

/* Reading panel: needs relative positioning for absolute sticky notes */
.reading { position: relative; }

/* ---- Sticky notes ---- */
.sticky-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
.sticky-wrap {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
}
.sticky-wrap:active { cursor: grabbing; }
.sticky-editing { cursor: default; }
.sticky-ghost { position: absolute; opacity: 0.88; }

/* The pin dot at the top center */
.sticky-pin-dot {
  width: 13px;
  height: 13px;
  background: radial-gradient(circle at 38% 35%, #bbb, #666 60%, #333);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.35);
  margin: 0 auto;
  position: relative;
  z-index: 2;
  /* overlap the body slightly */
  margin-bottom: -6px;
}

/* The paper body */
.sticky-body {
  position: relative;
  border-radius: 2px 2px 3px 3px;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.18),
    0 1px 2px rgba(0,0,0,0.12),
    inset 0 -1px 0 rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* subtle ruled-paper lines */
  background-image: repeating-linear-gradient(
    transparent 0px,
    transparent 23px,
    rgba(0,0,0,0.07) 23px,
    rgba(0,0,0,0.07) 24px
  );
  background-position: 0 32px;
}
/* folded corner */
.sticky-body::after {
  content: "";
  position: absolute;
  bottom: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 0 18px 18px;
  border-color: transparent transparent rgba(0,0,0,0.12) transparent;
}

.sticky-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 7px 2px;
  flex-shrink: 0;
}
.sticky-color-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.1s, background 0.1s;
}
.sticky-color-btn:hover { background: rgba(0,0,0,0.08); opacity: 1; }
.sticky-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: rgba(0,0,0,0.35);
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}
.sticky-del-btn:hover { background: rgba(0,0,0,0.12); color: rgba(0,0,0,0.7); }

.sticky-palette {
  position: absolute;
  top: 28px;
  left: 6px;
  right: 6px;
  background: rgba(255,255,255,0.97);
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.20), 0 1px 3px rgba(0,0,0,0.10);
  padding: 10px 12px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}
.sticky-pal-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.10);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.sticky-pal-dot:hover { transform: scale(1.2); border-color: rgba(0,0,0,0.35); }
.sticky-pal-dot.active {
  border-color: rgba(0,0,0,0.6);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.18);
}

.sticky-text {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  line-height: 24px;   /* match ruled lines */
  color: rgba(0,0,0,0.75);
  padding: 0 10px 6px;
  cursor: text;
  overflow: hidden;
}
.sticky-text::placeholder { color: rgba(0,0,0,0.3); font-style: italic; }

/* Rotation handle at bottom-right */
.sticky-rot-handle {
  position: absolute;
  bottom: 6px; right: 7px;
  width: 20px; height: 20px;
  background: none;
  border: none;
  cursor: grab;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: rgba(0,0,0,0.35);
  user-select: none;
  line-height: 1;
}
.sticky-rot-handle:hover { color: rgba(0,0,0,0.7); }

.sticky-drop-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  font-style: italic;
  color: rgba(0,0,0,0.4);
  font-family: system-ui, sans-serif;
  pointer-events: none;
}

/* The drag-to-create handle button in the reading toolbar */
.sticky-create-handle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-3);
  padding: 4px 10px;
  border-radius: 5px;
  cursor: grab;
  user-select: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.sticky-create-handle:hover { background: var(--paper-2); color: var(--ink-2); border-color: var(--rule-2); }
.sticky-create-handle:active { cursor: grabbing; }

/* Reading panel */
.reading article {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 680px;
}
.reading article h2 {
  margin: 0 0 18px;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.reading article p {
  margin: 0 0 1.1em;
}
.reading-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  min-height: 36px;
  position: relative;
  z-index: 30;
}
.reading-toolbar.draw-mode {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 20px;
}

/* Drawing toolbar */
.draw-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}
.draw-chip {
  background: var(--accent) !important;
  color: #fff !important;
  flex-shrink: 0;
}
.draw-tools { display: flex; gap: 3px; }
.draw-tool-btn {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px;
  transition: background 0.1s, border-color 0.1s;
  padding: 0;
}
.draw-tool-btn:hover { border-color: var(--rule-2); background: var(--paper); }
.draw-tool-btn.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.draw-colors { display: flex; gap: 5px; align-items: center; padding: 0 2px; }
.draw-color-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer; padding: 0;
  transition: transform 0.1s, border-color 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.draw-color-dot:hover { transform: scale(1.2); }
.draw-color-dot.active { border-color: var(--ink); transform: scale(1.18); }

.draw-widths { display: flex; gap: 3px; align-items: center; }
.draw-width-btn {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 5px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2);
  transition: background 0.1s, border-color 0.1s;
  padding: 0;
}
.draw-width-btn:hover { border-color: var(--rule-2); }
.draw-width-btn.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Erase hover feedback */
.draw-erasable { transition: opacity 0.1s; }
.draw-erasable:hover { opacity: 0.35 !important; cursor: pointer; }
.reading-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-3);
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
}

.reading-end {
  margin-top: 56px;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.reading-end-rule {
  width: 60px;
  height: 1px;
  background: var(--rule-2);
  margin-bottom: 14px;
}
.reading-end-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Tools grid (flashcards + practice) */
.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}
.tools-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.tools-header .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Flashcard */
.flashcard-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px 0;
}
.flashcard {
  width: 100%;
  max-width: 540px;
  height: 320px;
  perspective: 1200px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.55s cubic-bezier(.4,.0,.2,1);
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  inset: 0;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.flashcard-face.back {
  transform: rotateY(180deg);
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.flashcard-face .corner {
  position: absolute;
  top: 14px; left: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.flashcard-face.back .corner { color: rgba(243,237,224,0.55); }
.flashcard-face .content {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.35;
  font-weight: 500;
  max-width: 100%;
}
.flashcard-face.back .content { font-size: 21px; font-weight: 400; line-height: 1.5; }
.flashcard-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.flashcard-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.flashcard-counter {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  min-width: 60px;
  text-align: center;
}

/* Flashcard deck filter tabs */
.fc-deck-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.fc-deck-tab {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.fc-deck-tab:hover { border-color: var(--rule-2); color: var(--ink); }
.fc-deck-tab.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.fc-tab-count { font-family: var(--mono); font-size: 11px; opacity: 0.65; }
.fc-deck-tab.active .fc-tab-count { opacity: 0.75; }

/* Flashcard list (edit mode) */
.fc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.fc-list-item {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease;
  position: relative;
}
.fc-list-item:hover { border-color: var(--rule-2); }
.fc-list-item .front { font-family: var(--serif); font-size: 16px; font-weight: 500; margin-bottom: 6px; color: var(--ink); line-height: 1.35; }
.fc-list-item .back { color: var(--ink-3); font-size: 13px; line-height: 1.45; }
.fc-list-item.fc-learned { opacity: 0.55; }
.fc-list-item.fc-learned:hover { opacity: 0.8; }
.fc-learned-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-family: var(--mono); font-weight: 700;
  color: oklch(0.50 0.12 145);
}
.fc-section-tag {
  margin-top: 8px; padding-top: 6px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em;
}

/* Section group in card list */
.fc-group { margin-top: 28px; }
.fc-group:first-child { margin-top: 0; }
.fc-section-header {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

/* Practice */
.practice-q {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 32px 36px;
  box-shadow: var(--shadow);
}
.practice-q .num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.q-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.q-tags { display: flex; gap: 6px; align-items: center; }
.q-type-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  background: var(--paper-2);
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.q-diff {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.q-diff.diff-easy   { background: oklch(0.93 0.05 145); color: oklch(0.40 0.10 145); }
.q-diff.diff-medium { background: oklch(0.93 0.06 75);  color: oklch(0.42 0.12 75); }
.q-diff.diff-hard   { background: oklch(0.92 0.06 25);  color: oklch(0.45 0.13 25); }

/* True/False */
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-choice {
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 22px 18px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tf-choice:hover:not(:disabled) { border-color: var(--ink-3); background: #fff; }
.tf-choice.correct { border-color: var(--good); background: oklch(0.95 0.04 145); }
.tf-choice.wrong { border-color: var(--bad); background: oklch(0.95 0.04 25); }
.tf-choice:disabled { cursor: default; }

/* Short answer */
.short-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.short-input {
  flex: 1;
  min-width: 200px;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--serif);
  outline: none;
  transition: all 0.15s ease;
}
.short-input:focus { border-color: var(--accent); background: #fff; }
.short-input.correct { border-color: var(--good); background: oklch(0.95 0.04 145); }
.short-input.wrong { border-color: var(--bad); background: oklch(0.95 0.04 25); }
.short-feedback {
  width: 100%;
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink-2);
}
.short-feedback strong { color: var(--ink); font-style: italic; }
.practice-q .question {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.4;
  font-weight: 500;
  margin: 0 0 20px;
  letter-spacing: -0.005em;
}
.practice-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.practice-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  color: var(--ink);
  transition: all 0.15s ease;
  font-family: var(--sans);
}
.practice-choice:hover:not(:disabled) {
  border-color: var(--ink-3);
  background: #fff;
}
.practice-choice .letter {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper-2); color: var(--ink-2);
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.practice-choice.correct {
  border-color: var(--good); background: oklch(0.95 0.04 145);
}
.practice-choice.correct .letter { background: var(--good); color: white; }
.practice-choice.wrong {
  border-color: var(--bad); background: oklch(0.95 0.04 25);
}
.practice-choice.wrong .letter { background: var(--bad); color: white; }
.practice-choice:disabled { cursor: default; }

.practice-explanation {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--paper-2);
  border-radius: 8px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-2);
}
.practice-explanation strong { color: var(--ink); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; display: block; margin-bottom: 6px; }

.practice-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
}
.score-pill {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  padding: 6px 12px;
  background: var(--paper-2);
  border-radius: 999px;
}

.empty-tool {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-3);
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  background: var(--card);
  border: 1px dashed var(--rule-2);
  border-radius: 10px;
}

@media (max-width: 820px) {
  .subject-view { grid-template-columns: 1fr; }
  .navigator { position: relative; top: 0; height: auto; padding: 20px; }
  .subject-main { padding: 28px 24px 60px; }
}
