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

:root {
  --bg: #0a0f16;
  --surface: #131a24;
  --border: #2a3344;
  --border-hover: #3d5070;
  --text: #d4dce8;
  --text-dim: #8a9ab0;
  --text-faint: #5a6a80;
  --accent: #c9a84c;
  --accent-dim: rgba(201, 168, 76, 0.1);
  --accent-border: rgba(201, 168, 76, 0.35);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Fira Code', Menlo, monospace;
  --radius: 8px;
}

[data-theme="light"] {
  --bg: #ede9df;
  --surface: #ffffff;
  --border: #d0ccc3;
  --border-hover: #a09890;
  --text: #1a1a1a;
  --text-dim: #4a4a4a;
  --text-faint: #888888;
  --accent: #8a6020;
  --accent-dim: rgba(138, 96, 32, 0.08);
  --accent-border: rgba(138, 96, 32, 0.3);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.site-header {
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

.site-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.site-name span {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}
.theme-toggle:hover { color: var(--accent); }

/* Layout */
.main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
}

@media (min-width: 800px) {
  .main {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.125rem;
    padding: 2rem 1.75rem;
    align-items: start;
  }
}

/* Column cards */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  border-top: 3px solid transparent;
}

[data-theme="light"] .section {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Per-card accent colours matching detail pages */
.section--reading   { border-top-color: #1E3A5F; }
.section--resources { border-top-color: #1E6080; }
.section--rabbit    { border-top-color: #3D1A60; }

.section--reading   .section-title-link { color: #1E3A5F; }
.section--resources .section-title-link { color: #1E6080; }
.section--rabbit    .section-title-link { color: #3D1A60; }

[data-theme="dark"] .section--reading   .section-title-link { color: #5a8abf; }
[data-theme="dark"] .section--resources .section-title-link { color: #3a9abf; }
[data-theme="dark"] .section--rabbit    .section-title-link { color: #9a5abf; }

.section-title-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 1.1rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.15s;
}
.section-title-link:hover { opacity: 0.75; }

.section-title-link .arrow {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  opacity: 0.5;
  transition: transform 0.15s, opacity 0.15s;
  letter-spacing: 0;
}
.section-title-link:hover .arrow {
  transform: translateX(3px);
  opacity: 1;
}

/* Reading entries */
.reading-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.reading-entry:first-child { padding-top: 0; }
.reading-entry:last-child { border-bottom: none; padding-bottom: 0; }

.reading-class {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
}

.reading-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.reading-author {
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.reading-note {
  margin-top: 0.4rem;
  font-size: 0.825rem;
  color: var(--text-faint);
  font-style: italic;
}

/* Link entries */
.link-list { display: grid; }

.link-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 0.2rem;
}
.link-item:first-child { padding-top: 0; }
.link-item:last-child { border-bottom: none; padding-bottom: 0; }

.link-row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.link-title {
  color: var(--text);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  transition: color 0.12s;
}
.link-title:hover { color: var(--accent); }

.link-domain {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.link-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.link-note {
  font-size: 0.825rem;
  color: var(--text-faint);
  line-height: 1.4;
}

/* States */
.empty, .loading {
  color: var(--text-faint);
  font-size: 0.875rem;
}

/* Full-page layout (reading.html, resources.html, rabbit-hole.html) */
.page-header {
  padding: 2rem 1.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  border-top: 4px solid transparent;
}

/* Per-page accent strip — top of page header */
body.page-reading   .page-header { border-top-color: #1E3A5F; }
body.page-resources .page-header { border-top-color: #1E6080; }
body.page-rabbit    .page-header { border-top-color: #3D1A60; }

.page-back {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  text-decoration: none;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  transition: color 0.15s;
}
.page-back:hover { color: var(--accent); }

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-family: Georgia, 'Times New Roman', serif;
}

.page-desc {
  margin-top: 0.4rem;
  font-size: 0.925rem;
  color: var(--text-dim);
}

.page-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.75rem;
}

/* ── Works / File Cabinet (reading.html) ─────────────────────────── */

.page-content-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2.5rem;
}

@media (max-width: 600px) {
  .page-content-wide { padding: 1.5rem 1.25rem; }
  .page-header { padding: 1.5rem 1.25rem 1.25rem; }
}

/* Active reading cards grid */
.active-reading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 0;
}

.active-card-note {
  padding: 0.75rem 1.25rem;
  font-size: 0.825rem;
  color: var(--text-faint);
  font-style: italic;
  background: var(--surface);
  flex: 1;
}


.cabinet-section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

/* Each work card */
.work-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .work-card {
  box-shadow: 0 2px 10px rgba(0,0,0,0.09);
}

/* Header color variants by class */
.work-header               { background: #1E3A5F; } /* IB LIT — navy */
.work-header.lang-lit      { background: #6B2D42; } /* IB LANG & LIT — wine */
.work-header.e10           { background: #1A472A; } /* E10 — forest green */

.work-header {
  padding: 1rem 1.25rem 0.9rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.work-header-text { flex: 1; min-width: 0; }

.work-title {
  font-size: 0.975rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.work-author {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.65);
  margin-top: 0.2rem;
}

.work-class-badge {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(201, 168, 76, 0.2);
  border: 1px solid rgba(201, 168, 76, 0.45);
  color: #c9a84c;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  white-space: nowrap;
  align-self: flex-start;
}

/* Cabinet drawer */
.work-cabinet {
  background: var(--surface);
  padding: 0.875rem 1.25rem;
  flex: 1;
}

.cabinet-drawer-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 0.6rem;
}

.cabinet-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.1s;
  border-radius: 3px;
}
.cabinet-file:last-child { border-bottom: none; }
.cabinet-file:hover .cabinet-file-name { color: var(--accent); }

.cabinet-file-type {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  background: rgba(30, 58, 95, 0.12);
  border: 1px solid rgba(30, 58, 95, 0.25);
  color: #2a5fa0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

[data-theme="dark"] .cabinet-file-type {
  background: rgba(100, 160, 240, 0.1);
  border-color: rgba(100, 160, 240, 0.2);
  color: #7aaee8;
}

.cabinet-file-name {
  font-size: 0.875rem;
  color: var(--text);
  transition: color 0.12s;
  line-height: 1.3;
}

.cabinet-empty {
  font-size: 0.825rem;
  color: var(--text-faint);
  font-style: italic;
}

/* Expandable files toggle */
.files-overflow { display: grid; }

.files-toggle {
  background: none;
  border: none;
  padding: 0.35rem 0 0;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 0.03em;
  text-align: left;
  transition: opacity 0.15s;
}
.files-toggle:hover { opacity: 0.7; }

/* ── 3-column class layout (reading.html) ───────────────────────── */

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

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

.class-col-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
  border-bottom: 3px solid #1E3A5F;
  letter-spacing: -0.01em;
}

.class-col--iblanglit .class-col-header { border-bottom-color: #6B2D42; }
.class-col--e10       .class-col-header { border-bottom-color: #1A472A; }

.active-reading-col { margin-bottom: 0; }

.works-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.library-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0 1.25rem;
}

/* ── Link cards (resources.html, rabbit-hole.html) ───────────────── */

.link-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.link-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .link-card {
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.link-card-header {
  background: #1E6080; /* teal — resources */
  padding: 0.9rem 1.25rem;
}

.link-card-header.plum {
  background: #3D1A60; /* plum — rabbit hole */
}

.link-card-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  transition: opacity 0.15s;
}
.link-card-title:hover { opacity: 0.8; text-decoration: underline; text-underline-offset: 2px; }

.link-card-domain {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: rgba(255,255,255,0.5);
}

.link-card-body {
  background: var(--surface);
  padding: 0.75rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.link-card-note {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.link-card-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  align-self: flex-start;
}
