:root {
  --navy: #10233f;
  --navy-light: #19385f;
  --gold: #d8aa3d;
  --gold-soft: #f4dfa4;
  --gold-deep: #a97713;
  --paper: #fffaf0;
  --text: #10233f;
  --muted: rgba(16, 35, 63, 0.68);
  --line: rgba(16, 35, 63, 0.14);
  --danger: #c62828;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #fffdf8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 24px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--navy);
}

#nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link,
.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-link {
  padding: 8px 10px;
  color: rgba(16, 35, 63, 0.72);
  font-size: 14px;
}

.nav-link:hover {
  color: var(--navy);
  background: rgba(16, 35, 63, 0.06);
}

.btn {
  min-height: 42px;
  padding: 10px 16px;
  background: var(--navy);
  color: white;
}

.btn:hover {
  background: var(--navy-light);
}

.btn.gold {
  background: var(--gold);
  color: var(--navy);
}

.btn.ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
}

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

.container {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0;
}

.narrow {
  max-width: 480px;
}

.medium {
  max-width: 760px;
}

.eyebrow {
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  max-width: 800px;
  margin-top: 12px;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.06;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 20px;
}

p {
  margin: 0;
}

.lead {
  max-width: 660px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card,
.dark-card,
.paper-card {
  border-radius: 8px;
}

.card {
  border: 1px solid var(--line);
  background: white;
  padding: 22px;
}

.dark-card {
  display: block;
  background: var(--navy);
  color: var(--gold-soft);
  padding: 24px;
}

.dark-card:hover {
  background: var(--navy-light);
}

.dark-card h3,
.dark-card .code,
.dark-card strong {
  color: var(--gold);
}

.dark-card .code {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.dark-card p,
.card p {
  margin-top: 8px;
  color: inherit;
  line-height: 1.55;
}

.section {
  padding: 30px 0;
}

.section-title {
  margin-bottom: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 5px;
  padding: 4px 8px;
  background: var(--gold);
  color: var(--navy);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.tab {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: rgba(16, 35, 63, 0.68);
  cursor: pointer;
  padding: 9px 13px;
  font-weight: 700;
}

.tab.active {
  background: var(--navy);
  color: white;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

label {
  color: rgba(16, 35, 63, 0.72);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input {
  width: 100%;
  border: 1px solid rgba(16, 35, 63, 0.22);
  border-radius: 6px;
  padding: 12px 13px;
  color: var(--navy);
  background: white;
  outline: none;
}

input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(216, 170, 61, 0.28);
}

.error {
  margin: 6px 0 14px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.hint {
  color: rgba(16, 35, 63, 0.58);
  font-size: 13px;
  line-height: 1.5;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(16, 35, 63, 0.04);
  padding: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: rgba(16, 35, 63, 0.58);
  font-size: 13px;
}

.crumbs a {
  font-weight: 700;
  color: var(--navy);
}

.list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.list a {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.list li:first-child a {
  border-top: 0;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
  gap: 28px;
  align-items: start;
}

.paper-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: white;
  padding: 34px;
}

.paper-card::before {
  content: "exam-prep";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-28deg);
  color: rgba(16, 35, 63, 0.045);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 70px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.paper-card > * {
  position: relative;
}

.questions {
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.questions li {
  border-top: 1px solid var(--line);
  padding: 22px 0;
}

.questions li:first-child {
  border-top: 0;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-weight: 800;
}

.coach {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.coach-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  font-weight: 800;
}

.chat {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.bubble {
  width: fit-content;
  max-width: 92%;
  margin: 0 0 12px;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-line;
  line-height: 1.5;
  font-size: 14px;
}

.bubble.user {
  margin-left: auto;
  background: var(--navy);
  color: white;
}

.bubble.coach {
  background: rgba(16, 35, 63, 0.06);
  color: var(--navy);
}

.coach form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

/* Document Viewer Styles */
.document-viewer {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: calc(100vh - 180px);
  min-height: 600px;
}

.paper-header {
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: white;
  position: relative;
  z-index: 2;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px;
  background: rgba(16, 35, 63, 0.04);
  border-radius: 6px;
  width: fit-content;
}

.viewer-controls .btn {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 14px;
}

.viewer-controls #zoomLevel {
  min-width: 50px;
  text-align: center;
  font-weight: 700;
  color: var(--navy);
}

.document-container {
  flex: 1;
  position: relative;
  overflow: auto;
  background: #525659;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.document-container:fullscreen {
  background: #525659;
}

.document-container:-webkit-full-screen {
  background: #525659;
}

.document-container:-moz-full-screen {
  background: #525659;
}

.document-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  pointer-events: auto;
}

/* Disable text selection and drag in viewer */
.document-container * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
}

/* Hide PDF.js download/print buttons if using PDF.js */
.document-container #toolbarViewerRight {
  display: none !important;
}

.document-container #download,
.document-container #print,
.document-container #openFile {
  display: none !important;
}

/* Print media query - hide document when printing */
@media print {
  .document-viewer,
  .document-container,
  .document-container iframe {
    display: none !important;
    visibility: hidden !important;
  }
  body::before {
    content: "This document cannot be printed. On-screen viewing only.";
    display: block;
    padding: 40px;
    font-size: 18px;
    text-align: center;
    color: #c62828;
  }
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border-top: 1px solid var(--line);
  color: rgba(16, 35, 63, 0.6);
  font-size: 13px;
}

@media (max-width: 860px) {
  .grid.two,
  .grid.three,
  .grid.four,
  .reader-layout {
    grid-template-columns: 1fr;
  }

  .topbar,
  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  #nav {
    flex-wrap: wrap;
  }

  .coach {
    position: static;
    height: 560px;
  }
}

@media (max-width: 520px) {
  .container {
    width: min(100% - 28px, 1120px);
    padding: 28px 0;
  }

  .paper-card {
    padding: 22px;
  }

  h1 {
    font-size: 36px;
  }
}
