/* Hallmark Critique: Google-Doc & Academic Journal Hybrid PhD Dissertation Manuscript on archival paper tokens, strict 4px spacing grid, booktabs tables, presentation slide mode, and print-to-PDF layout. Waivers: none. */
:root {
  --bg-desk: #edefec;
  --bg-present: #e4e7e3;
  --bg-paper: #fdfcf9;
  --bg-surface: #f8f9f6;
  --bg-subtle: #f1f3f0;
  --bg-teal-soft: #eef8f6;
  --bg-crimson-soft: #fdf2f4;
  --bg-amber-soft: #fff8ed;
  --toolbar-bg: #fafaf7;
  --modal-backdrop: rgba(17, 26, 40, 0.88);
  --shadow-bar: 0 8px 24px rgba(17, 26, 40, 0.25);
  --shadow-drawer: -8px 0 28px rgba(17, 26, 40, 0.14);
  --border-present-btn: rgba(248, 251, 250, 0.28);
  --on-accent: #f8fbfa;
  --ink-primary: #111a28;
  --ink-secondary: #2d3a4b;
  --ink-muted: #536377;
  --border-subtle: #d8dfdb;
  --border-strong: #b4c0bb;
  --border-teal-soft: #bfe3dd;
  --border-crimson-soft: #f3c4ce;
  --border-amber-soft: #f0d7b4;
  --accent-teal: #0f766e;
  --accent-teal-dark: #115e59;
  --accent-crimson: #be123c;
  --accent-orange: #c2410c;
  --accent-blue: #1d4ed8;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sheet-width: 840px;
  --sidebar-width: 268px;
  --radius-sm: 6px;
  --radius-md: 10px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-desk);
  color: var(--ink-primary);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.72;
  overflow-x: clip;
  scroll-behavior: smooth;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--ink-primary);
  line-height: 1.24;
  font-weight: 600;
  margin: 0 0 12px 0;
  overflow-wrap: break-word;
  min-width: 0;
  text-wrap: balance;
}

p {
  margin: 0 0 16px 0;
  color: var(--ink-secondary);
}

a {
  color: var(--accent-teal);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-teal-dark);
}

:focus-visible {
  outline: 2.5px solid var(--accent-orange);
  outline-offset: 2px;
}

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

section[id],
.manuscript-sec[id] {
  scroll-margin-top: 76px;
}

/* Google-Doc Top Manuscript Toolbar */
.doc-toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  background-color: var(--toolbar-bg);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
}

.toolbar-inner {
  max-width: 1420px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.doc-badge-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: var(--accent-teal);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.84rem;
  flex-shrink: 0;
}

.doc-file-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-status-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-teal);
  background-color: var(--bg-teal-soft);
  border: 1px solid var(--border-teal-soft);
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

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

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-paper);
  color: var(--ink-primary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.tb-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

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

.tb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tb-btn-primary {
  background-color: var(--accent-teal);
  border-color: var(--accent-teal);
  color: var(--on-accent);
}

.tb-btn-primary:hover {
  background-color: var(--accent-teal-dark);
  border-color: var(--accent-teal-dark);
  color: var(--on-accent);
}

.tb-btn-active {
  background-color: var(--bg-crimson-soft);
  border-color: var(--border-crimson-soft);
  color: var(--accent-crimson);
}

/* Workspace Grid: Left Document Outline + Centered Archival Paper Sheet */
.doc-workspace {
  max-width: 1420px;
  margin: 0 auto;
  padding: 24px 20px 64px 20px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.outline-sidebar {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 16px 12px;
  background-color: var(--toolbar-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
}

.outline-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-muted);
  padding: 0 8px 8px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.outline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.outline-list li {
  margin-bottom: 4px;
}

.outline-link {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.80rem;
  line-height: 1.35;
  color: var(--ink-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.outline-link:hover {
  background-color: var(--bg-subtle);
  color: var(--accent-teal);
}

.outline-link.sub {
  padding-left: 16px;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.outline-link.active {
  background-color: var(--bg-teal-soft);
  color: var(--accent-teal-dark);
  font-weight: 600;
  border-left-color: var(--accent-teal);
}

.outline-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  gap: 8px;
}

/* Archival Paper Sheet */
.paper-column {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.paper-sheet {
  width: 100%;
  max-width: var(--sheet-width);
  background-color: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 60px 64px;
  min-width: 0;
}

/* Formal Title Block */
.title-block {
  border-bottom: 2px solid var(--ink-primary);
  padding-bottom: 24px;
  margin-bottom: 28px;
}

.journal-meta-line {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent-teal);
  margin-bottom: 12px;
}

.paper-title {
  font-size: clamp(1.75rem, 3vw, 2.32rem);
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.author-block {
  font-family: var(--font-sans);
  font-size: 0.90rem;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

.affiliation-block {
  font-family: var(--font-sans);
  font-size: 0.80rem;
  color: var(--ink-muted);
  margin-bottom: 16px;
}

.paper-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Structured Abstract Box */
.abstract-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-teal-soft);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 28px;
}

.abstract-heading {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-teal-dark);
  margin-bottom: 12px;
}

.abstract-box p {
  font-size: 0.96rem;
  line-height: 1.66;
  margin-bottom: 12px;
}

.abstract-box p:last-child {
  margin-bottom: 0;
}

.keywords-line {
  font-family: var(--font-sans);
  font-size: 0.80rem;
  color: var(--ink-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Manuscript Section Typography */
.slide-unit {
  margin-bottom: 36px;
}

.slide-unit h2 {
  font-size: 1.52rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin: 32px 0 16px 0;
}

.slide-unit h3 {
  font-size: 1.18rem;
  color: var(--accent-teal-dark);
  margin: 24px 0 12px 0;
}

.slide-unit p {
  text-align: justify;
  hyphens: auto;
}

/* Equations */
.equation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 24px 0;
  padding: 12px 20px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.equation-math {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.equation-num {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
  flex-shrink: 0;
}

/* Scholarly Figures */
.figure-block {
  margin: 28px 0 28px 0;
  padding: 16px;
  background-color: var(--bg-paper);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.figure-img-wrap {
  cursor: zoom-in;
  overflow: hidden;
  border-radius: 4px;
}

.figure-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.figure-caption {
  font-family: var(--font-sans);
  font-size: 0.84rem;
  line-height: 1.52;
  color: var(--ink-secondary);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Booktabs Academic Tables */
.table-block {
  margin: 28px 0 28px 0;
}

.table-caption {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.48;
  color: var(--ink-primary);
  margin-bottom: 8px;
}

.table-scroll {
  overflow-x: auto;
  border-top: 2px solid var(--ink-primary);
  border-bottom: 2px solid var(--ink-primary);
}

.booktabs {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.80rem;
  line-height: 1.42;
}

.booktabs thead th {
  text-align: left;
  font-weight: 700;
  color: var(--ink-primary);
  padding: 8px 12px;
  border-bottom: 1.5px solid var(--ink-primary);
  background-color: var(--bg-surface);
  white-space: nowrap;
}

.booktabs tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  vertical-align: top;
}

.booktabs tbody tr:last-child td {
  border-bottom: none;
}

.booktabs tbody tr.row-highlight td {
  background-color: var(--bg-teal-soft);
  font-weight: 600;
  color: var(--ink-primary);
}

.booktabs tbody tr.row-leak td {
  background-color: var(--bg-crimson-soft);
  color: var(--accent-crimson);
  font-weight: 600;
}

.table-footnote {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 8px;
}

/* Highlighted Methodological Callout */
.thesis-callout {
  background-color: var(--bg-amber-soft);
  border: 1px solid var(--border-amber-soft);
  padding: 16px 20px;
  border-radius: 6px;
  margin: 20px 0;
  font-size: 0.94rem;
}

.thesis-callout strong {
  color: var(--accent-orange);
}

/* References List */
.ref-list {
  padding-left: 24px;
  margin: 12px 0 0 0;
  font-size: 0.86rem;
  line-height: 1.58;
  color: var(--ink-secondary);
}

.ref-list li {
  margin-bottom: 12px;
}

.ref-links {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  margin-left: 4px;
}

/* Downloads Grid in Supplementary Appendix */
.download-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  font-family: var(--font-sans);
}

.dl-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-primary);
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.dl-card:hover {
  border-color: var(--accent-teal);
  background-color: var(--bg-teal-soft);
}

.dl-card strong {
  font-size: 0.84rem;
  color: var(--accent-teal-dark);
}

.dl-card span {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Presentation Slide Mode */
body.presentation-mode {
  background-color: var(--bg-present);
}

body.presentation-mode .outline-sidebar {
  display: none;
}

body.presentation-mode .doc-workspace {
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: 92px;
}

body.presentation-mode .paper-sheet {
  max-width: 980px;
  padding: 44px 56px;
}

body.presentation-mode .slide-unit {
  display: none;
}

body.presentation-mode .slide-unit.slide-active {
  display: block;
}

.present-bar {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 60;
  background-color: var(--ink-primary);
  color: var(--on-accent);
  font-family: var(--font-sans);
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-bar);
  align-items: center;
  gap: 12px;
}

body.presentation-mode .present-bar {
  display: flex;
}

.present-btn {
  background-color: transparent;
  color: var(--on-accent);
  border: 1px solid var(--border-present-btn);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.80rem;
  font-weight: 600;
  cursor: pointer;
}

.present-btn:hover {
  background-color: var(--accent-teal);
  border-color: var(--accent-teal);
}

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

.present-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.present-counter {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  min-width: 96px;
  text-align: center;
}

/* Defense Q&A Slide-Over Drawer */
.qa-drawer {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: min(460px, 94vw);
  background-color: var(--bg-paper);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-drawer);
  z-index: 55;
  transform: translateX(102%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
}

.qa-drawer.open {
  transform: translateX(0);
}

.qa-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
}

.qa-header h3 {
  font-family: var(--font-sans);
  font-size: 0.96rem;
  margin: 0;
  color: var(--ink-primary);
}

.qa-body {
  padding: 16px 20px 28px 20px;
  overflow-y: auto;
  display: grid;
  gap: 16px;
}

.qa-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background-color: var(--bg-surface);
}

.qa-q {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-crimson);
  margin-bottom: 8px;
}

.qa-a {
  font-size: 0.82rem;
  line-height: 1.54;
  color: var(--ink-secondary);
}

.qa-jump {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-teal);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  white-space: nowrap;
  text-decoration: underline;
}

/* Lightbox Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background-color: var(--modal-backdrop);
  padding: 24px;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background-color: var(--bg-paper);
  max-width: 1120px;
  max-height: 92vh;
  width: 100%;
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: var(--font-sans);
}

.modal-card img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive Breakpoints */
@media (max-width: 1080px) {
  .doc-workspace {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 16px 48px 16px;
  }
  .outline-sidebar {
    position: static;
    max-height: none;
  }
  .paper-sheet {
    padding: 36px 32px;
  }
}

@media (max-width: 680px) {
  .doc-status-pill,
  .hide-mobile {
    display: none;
  }
  .paper-sheet {
    padding: 24px 20px;
  }
  .slide-unit p {
    text-align: left;
  }
  .download-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html, body {
    scroll-behavior: auto;
  }
  .tb-btn, .outline-link, .dl-card, .qa-drawer {
    transition: none;
  }
}

/* Print to Publication PDF */
@media print {
  body {
    background-color: var(--bg-paper);
    font-size: 11pt;
    line-height: 1.5;
  }
  .doc-toolbar,
  .outline-sidebar,
  .present-bar,
  .qa-drawer,
  .modal-backdrop {
    display: none !important;
  }
  .doc-workspace {
    display: block;
    padding: 0;
  }
  .paper-sheet {
    max-width: 100%;
    border: none;
    padding: 0;
  }
  .figure-block,
  .table-block {
    break-inside: avoid;
  }
}
