:root {
  --primary: #722F37; /* Refined Crimson */
  --primary-hover: #5A252B;
  --bg-color: #F9F8F6; /* Ivory / Old Paper */
  --sidebar-bg: #F4F2EC;
  --content-bg: #FFFFFF;
  --text-main: #1C1C1C; /* Ink Black */
  --text-muted: #5A5A5A;
  --border-color: #E5E0D8; /* Subtle hairline */
  
  --level1-bg: #FDFDFD;
  --level1-text: #333333;
  
  --level3-border: #D1CAC0;
  --level3-text: #4A4A4A;

  --tooltip-bg: #1A1A1A;
  --tooltip-text: #F4F2EC;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Serif SC', 'Crimson Pro', serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.8;
  min-height: 100vh;
  /* Very subtle paper texture using noise could be added, but keeping it clean for now */
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Styling: The Index */
.sidebar {
  width: 320px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 40px 32px 20px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.sidebar-header h1 {
  font-family: 'EB Garamond', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.subtitle {
  font-family: 'EB Garamond', serif;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 8px;
}

.sidebar-footer {
  padding: 20px;
  text-align: center;
  border-top: 1px solid var(--border-color);
  font-family: 'EB Garamond', serif;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-muted);
}

.question-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 24px 16px;
}

.question-item {
  padding: 16px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
}

.question-item:hover {
  background: rgba(0,0,0,0.02);
}

.question-item.active {
  background: var(--content-bg);
  border-left-color: var(--primary);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-top: -1px; /* collapse border */
}

.q-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tag {
  font-family: 'EB Garamond', serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.tag::before {
  content: '[';
  opacity: 0.5;
}
.tag::after {
  content: ']';
  opacity: 0.5;
}

.q-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.5;
}

/* Main Content Styling: The Reading Room */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 60px 40px;
  background: var(--content-bg);
}

.content-container {
  max-width: 760px;
  margin: 0 auto;
}

.welcome-screen {
  text-align: center;
  margin-top: 25vh;
  color: var(--text-muted);
  font-family: 'EB Garamond', serif;
}

.welcome-screen h2 {
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--text-main);
  margin-bottom: 16px;
}

.welcome-screen p {
  font-style: italic;
  font-size: 1.1rem;
}

.decorative-line {
  width: 60px;
  height: 1px;
  background: var(--primary);
  margin: 24px auto;
  opacity: 0.3;
}

/* Question Header */
.question-header {
  margin-bottom: 48px;
  padding-bottom: 24px;
  border-bottom: 1px double var(--border-color);
}

.question-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
}

.question-content {
  font-size: 1.15rem;
  line-height: 2;
  color: var(--text-main);
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-family: 'EB Garamond', serif;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Pagination Footer */
.pagination-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}
.pagination-footer:has(.prev-btn) {
  justify-content: flex-start;
}

.pagination-btn {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 24px;
  font-family: 'EB Garamond', serif;
  font-size: 1.1rem;
  font-style: italic;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pagination-btn:hover {
  background: var(--primary);
  color: var(--content-bg);
}

/* Level Sections */
.level-section {
  margin-bottom: 48px;
}

.level-header {
  font-family: 'EB Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  color: var(--text-main);
  transition: opacity 0.2s;
}

.level-header:hover {
  opacity: 0.7;
}

.level-body {
  padding-top: 12px;
}

/* -------------------------------------
   Level 1: High-End Print Editorial Layout
   ------------------------------------- */
.editorial-l1-wrapper {
  margin-top: 32px;
  margin-bottom: 48px;
  border-top: 3px solid var(--text-main);
  border-bottom: 1px solid var(--text-main);
  padding: 8px 0;
}

.ed-section {
  padding: 32px 0;
  border-bottom: 1px solid var(--border-color);
}
.ed-section:last-child {
  border-bottom: none;
  padding-bottom: 16px;
}

.ed-heading {
  font-family: 'EB Garamond', 'Noto Serif SC', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  letter-spacing: 0.05em;
}

.ed-num {
  font-family: 'Crimson Pro', serif;
  font-size: 1.3rem;
  color: var(--primary);
  font-style: italic;
  font-weight: 700;
}

.ed-en {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: auto;
}

/* Common List Layout for Level 1 */
.ed-insight-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.ed-insight-item {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.ed-insight-num {
  font-family: 'Crimson Pro', serif;
  font-size: 2.8rem;
  line-height: 0.8;
  color: var(--primary);
  opacity: 0.2;
  font-style: italic;
  font-weight: 700;
  margin-top: 4px;
}

.ed-insight-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text-main);
  margin: 0;
  flex: 1;
}

/* No specific media queries needed for this layout as flex naturally handles it well */

/* Level 2: Steps */
.step-item {
  position: relative;
  padding: 16px 0;
  margin-bottom: 8px;
}

.step-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.step-badge {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text-main);
}

.step-badge::after {
  content: ".";
}

.step-title {
  font-family: 'Noto Serif SC', serif;
  font-weight: 600;
  color: var(--text-main);
  font-size: 1.1rem;
}

.step-role {
  display: none;
}

.step-content {
  font-size: 1.1rem;
  line-height: 2;
  padding-left: 28px;
}

/* Level 3: Annotations */
.anno-container {
  display: none;
  margin-top: 20px;
  padding-left: 28px;
}

.anno-container.show {
  display: block;
}

.toggle-anno-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 2px;
  padding: 2px 10px;
  font-family: 'EB Garamond', serif;
  font-size: 0.85rem;
  cursor: pointer;
  margin-left: auto;
  transition: all 0.2s ease;
  font-style: italic;
}

.toggle-anno-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.annotation-block {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: #FCFBFA;
  border-left: 2px solid var(--level3-border);
  font-size: 0.95rem;
  color: var(--level3-text);
}

.anno-label {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  font-style: italic;
  margin-bottom: 8px;
  color: var(--text-main);
}

.anno-content p {
  margin-bottom: 8px;
}
.anno-content p:last-child {
  margin-bottom: 0;
}

/* Annotation Types with Academic Colors */
.anno-type-expansion {
  border-left-color: #5A7F5A; /* Muted Green */
  background: #F6FAF6;
}

.anno-type-reasoning {
  border-left-color: #C19A6B; /* Antique Gold/Yellow */
  background: #FCFAEF;
}

.anno-type-knowledge_card {
  border-left-color: #8C8C8C; /* Slate Gray */
  background: #F7F7F7;
}

.anno-type-mistake_warning {
  border-left-color: #A64B4B; /* Muted Crimson/Red */
  background: #FAF2F2;
}

/* Tooltip (Hover Cards) - Marginalia Style */
.anchor-text {
  border-bottom: 1px dashed var(--text-muted);
  cursor: help;
  position: relative;
  color: inherit;
  transition: all 0.2s;
}

.anchor-text:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.knowledge-tooltip {
  position: absolute;
  z-index: 100;
  width: 360px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  padding: 24px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.2);
  font-size: 0.95rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: translateY(5px);
  font-family: 'Noto Serif SC', serif;
}

.knowledge-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.kt-title {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kt-content {
  line-height: 1.6;
}

.kt-examples {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-style: italic;
  color: #D1CAC0;
}

/* Summary Section */
.summary-section {
  border-top: 1px double var(--border-color);
  padding-top: 40px;
  margin-top: 40px;
  margin-bottom: 60px;
}

.summary-title {
  font-family: 'EB Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-main);
  text-align: center;
}

.summary-item {
  margin-bottom: 20px;
  text-align: center;
}

.summary-label {
  font-family: 'EB Garamond', serif;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.summary-content {
  font-size: 1.1rem;
  color: var(--primary);
  font-style: italic;
}

/* Animations */
.fade-in {
  animation: fadeIn 0.8s ease-out forwards;
}

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

/* Scrollbar Refinement */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: #D1CAC0;
}
::-webkit-scrollbar-thumb:hover {
  background: #A39B90;
}
