/* OPMedEd — Psychiatry Rotation Study Hub */
:root {
  --bg: #f4f1ea;
  --bg-elevated: #fffcf7;
  --bg-soft: #e9e4d8;
  --ink: #1a2332;
  --ink-muted: #5c6675;
  --ink-faint: #8b93a0;
  --line: #d8d2c4;
  --accent: #0d6e6e;
  --accent-deep: #094f4f;
  --accent-soft: #d4efef;
  --accent-glow: rgba(13, 110, 110, 0.15);
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --card: #fffcf7;
  --shadow: 0 1px 2px rgba(26, 35, 50, 0.06), 0 8px 24px rgba(26, 35, 50, 0.06);
  --shadow-lg: 0 4px 12px rgba(26, 35, 50, 0.08), 0 20px 40px rgba(26, 35, 50, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-ui: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --max: 1120px;
  --nav-h: 64px;
  --sidebar-w: 280px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dceceb 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e6d4 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

p { margin: 0 0 1em; }
a { color: var(--accent-deep); }
button, input, select, textarea { font: inherit; }

/* Layout */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(255, 252, 247, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #0d6e6e, #1a8f8f 50%, #0a4f4f);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(13, 110, 110, 0.35);
}

.brand-text strong {
  display: block;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.brand-text span {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 1rem;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  transition: 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.student-chip {
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  max-width: 220px;
}
.student-chip.visible { display: flex; }
.student-chip .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.student-chip .email-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
}

main {
  flex: 1;
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 4rem;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(13, 110, 110, 0.28);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-soft);
  color: var(--ink);
}
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 2rem 2.1rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--accent), #2a9d8f);
}
.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.hero h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.45rem);
  margin-bottom: 0.75rem;
}
.hero .lede {
  color: var(--ink-muted);
  font-size: 1.05rem;
  max-width: 42ch;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.4rem;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.stat .num {
  font-family: var(--font);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: -0.03em;
}
.stat .label {
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-weight: 500;
}

/* Sections */
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 1rem;
}
.section-head h2 {
  font-size: 1.45rem;
  margin: 0;
}
.section-head p {
  margin: 0.25rem 0 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

/* Module cards */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}
.module-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: 0.18s ease;
  text-align: left;
  width: 100%;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 160px;
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #c5bfb0;
}
.module-card .icon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.module-card .icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  background: var(--module-soft, var(--accent-soft));
}
.module-card .badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.module-card h3 {
  font-size: 1.12rem;
  margin: 0;
}
.module-card .short {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin: 0;
  flex: 1;
}
.module-card .meta-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}
.pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-muted);
  border: 1px solid var(--line);
}
.pill.accent {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: transparent;
}
.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}

/* Guide layout */
.guide-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.25rem;
  align-items: start;
}
.guide-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  max-height: calc(100vh - var(--nav-h) - 2rem);
  overflow: auto;
}
.guide-sidebar h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin: 0 0 0.7rem;
  font-family: var(--font-ui);
  font-weight: 700;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  text-decoration: none;
  color: var(--ink-muted);
  font-size: 0.86rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border-left: 2px solid transparent;
}
.toc-list a:hover {
  background: var(--bg-soft);
  color: var(--ink);
}
.guide-main {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.guide-header {
  padding: 1.5rem 1.75rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(13, 110, 110, 0.08), transparent 50%),
    var(--bg-elevated);
}
.guide-header h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.35rem;
}
.guide-header .short {
  color: var(--ink-muted);
  margin: 0;
}
.guide-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.guide-body {
  padding: 1.25rem 1.75rem 2rem;
  font-family: var(--font);
  font-size: 1.05rem;
}
.guide-section {
  margin-bottom: 1.75rem;
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}
.guide-section h2 {
  font-size: 1.25rem;
  color: var(--accent-deep);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
  margin-bottom: 0.85rem;
}
.guide-section ul {
  margin: 0;
  padding-left: 1.15rem;
}
.guide-section li {
  margin-bottom: 0.45rem;
  color: var(--ink);
}
.guide-section li::marker {
  color: var(--accent);
}

/* Audio player */
.audio-bar {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: 40;
  background: #123333;
  color: #e8f5f5;
  border-top: 1px solid #1f4a4a;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
}
.audio-bar.visible {
  display: block;
}
.audio-inner {
  width: min(var(--max), 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}
.audio-controls {
  display: flex;
  gap: 0.4rem;
}
.audio-bar .btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}
.audio-bar .btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}
.audio-meta {
  min-width: 0;
}
.audio-meta strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-meta span {
  font-size: 0.78rem;
  opacity: 0.75;
}
.audio-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  margin-top: 0.45rem;
  overflow: hidden;
}
.audio-progress > i {
  display: block;
  height: 100%;
  width: 0%;
  background: #5eead4;
  border-radius: 999px;
  transition: width 0.2s linear;
}

/* Quiz */
.quiz-shell {
  max-width: 760px;
  margin: 0 auto;
}
.quiz-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.5rem 1.6rem;
}
.quiz-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-weight: 600;
}
.progress-track {
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.progress-track > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2a9d8f);
  width: 0%;
  transition: width 0.25s ease;
}
.quiz-stem {
  font-family: var(--font);
  font-size: 1.2rem;
  margin-bottom: 1.2rem;
  line-height: 1.4;
}
.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.option-btn {
  text-align: left;
  background: var(--bg-elevated);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  transition: 0.12s ease;
  color: inherit;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option-btn:disabled {
  cursor: default;
}
.option-btn .letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.option-btn.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.option-btn.correct .letter {
  background: var(--ok);
  color: #fff;
}
.option-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.option-btn.wrong .letter {
  background: var(--danger);
  color: #fff;
}
.quiz-feedback {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.ok {
  background: var(--ok-soft);
  color: #14532d;
}
.quiz-feedback.bad {
  background: var(--danger-soft);
  color: #7f1d1d;
}
.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.quiz-source {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.75rem;
}

.score-card {
  text-align: center;
  padding: 2rem 1rem;
}
.score-card .big-score {
  font-family: var(--font);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: -0.04em;
  line-height: 1;
}
.score-card .score-sub {
  color: var(--ink-muted);
  margin: 0.5rem 0 1.5rem;
}

/* Forms / email */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.panel h2 { margin-top: 0; }
.form-grid {
  display: grid;
  gap: 0.9rem;
}
.form-row {
  display: grid;
  gap: 0.35rem;
}
.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.form-row input,
.form-row select,
.form-row textarea {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  background: var(--bg-elevated);
  color: var(--ink);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.topic-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.45rem;
}
.topic-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 0.88rem;
  cursor: pointer;
}
.topic-check input { accent-color: var(--accent); }
.help-text {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin: 0.5rem 0 0;
}
.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
.alert-info {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.alert-ok {
  background: var(--ok-soft);
  color: #14532d;
}
.alert-warn {
  background: var(--warn-soft);
  color: #92400e;
}

/* Quiz hub list */
.quiz-hub-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.quiz-hub-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.quiz-hub-item .qi {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.quiz-hub-item .info { flex: 1; min-width: 0; }
.quiz-hub-item h3 {
  margin: 0 0 0.15rem;
  font-size: 1.05rem;
}
.quiz-hub-item p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.quiz-hub-item .actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Progress */
.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.progress-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.progress-card h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}
.bar {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* Empty / loading */
.loading, .empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 1.25rem 2rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-align: center;
}
.site-footer .inner {
  width: min(var(--max), 100%);
  margin: 0 auto;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 35, 50, 0.45);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 18px;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
}
.modal h2 { margin-top: 0; }

/* Search */
.search-wrap {
  position: relative;
  max-width: 320px;
}
.search-wrap input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 1rem 0.55rem 2.2rem;
  background: var(--card);
}
.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  font-size: 0.95rem;
}

/* Workflow steps */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1rem 0 0;
}
.step {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.step .n {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.55rem;
}
.step h3 {
  font-size: 0.95rem;
  margin: 0 0 0.3rem;
}
.step p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Filters */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.chip-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}
.chip-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Speaking highlight */
.guide-section.speaking {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
  background: rgba(13, 110, 110, 0.04);
}

/* Print */
@media print {
  .topbar, .audio-bar, .guide-toolbar, .guide-sidebar, .site-footer, .btn { display: none !important; }
  .guide-layout { display: block; }
  .guide-main { box-shadow: none; border: none; }
  body { background: #fff; }
}

/* Responsive */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-sidebar { position: static; max-height: none; }
  .steps { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }
  .menu-toggle { display: inline-flex; }
  .audio-inner { grid-template-columns: 1fr; gap: 0.6rem; }
  .quiz-hub-item { flex-direction: column; align-items: stretch; }
}

@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  main { width: calc(100% - 1.25rem); }
  .guide-body { padding: 1rem 1.1rem 1.5rem; }
  .hero-card { padding: 1.35rem; }
}

/* ===== Flashcards ===== */
.flashcard {
  width: 100%;
  min-height: 240px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--bg-elevated), var(--accent-soft));
  padding: 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: inherit;
  font: inherit;
}
.flashcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.flashcard.flipped {
  background: linear-gradient(160deg, var(--bg-elevated), var(--ok-soft));
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}
.flashcard-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.flashcard-text {
  font-family: var(--font);
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  line-height: 1.4;
  max-width: 36ch;
}
.flashcard-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ===== Search ===== */
.search-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elevated);
  transition: 0.12s ease;
}
.search-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.search-result .pill { grid-row: span 2; align-self: center; }
.search-result strong { font-size: 0.95rem; }
.search-result .muted {
  grid-column: 2;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* ===== Dark mode ===== */
[data-theme="dark"] {
  --bg: #0f1419;
  --bg-elevated: #1a222c;
  --bg-soft: #243040;
  --ink: #e8eef4;
  --ink-muted: #9aa8b8;
  --ink-faint: #6b7a8c;
  --line: #2d3a4a;
  --accent: #2dd4bf;
  --accent-deep: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-glow: rgba(45, 212, 191, 0.2);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.15);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --card: #1a222c;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.25);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.35), 0 20px 40px rgba(0,0,0,0.3);
}
[data-theme="dark"] body {
  background:
    radial-gradient(1000px 500px at 10% -10%, #143030 0%, transparent 55%),
    radial-gradient(800px 400px at 100% 0%, #1a2030 0%, transparent 50%),
    var(--bg);
}
[data-theme="dark"] .topbar {
  background: rgba(26, 34, 44, 0.9);
}
[data-theme="dark"] .brand-mark {
  box-shadow: 0 4px 12px rgba(45, 212, 191, 0.25);
}
[data-theme="dark"] .audio-bar {
  background: #0a1616;
  border-top-color: #1f3a3a;
}
[data-theme="dark"] .option-btn {
  background: var(--bg-soft);
}
[data-theme="dark"] .hero-card::before {
  background: linear-gradient(180deg, var(--accent), #0d9488);
}

/* Theme toggle */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

/* ===== Fillable handouts ===== */
.handout-body {
  font-family: var(--font-ui);
  font-size: 0.98rem;
}
.handout-heading {
  font-family: var(--font);
  font-size: 1.2rem;
  color: var(--accent-deep);
  margin: 1.5rem 0 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}
.handout-line {
  margin: 0.45rem 0;
  line-height: 1.75;
}
.blank-input {
  display: inline-block;
  min-width: 5.5rem;
  max-width: 14rem;
  width: 8rem;
  margin: 0 0.15rem;
  padding: 0.2rem 0.45rem;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 4px 4px 0 0;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.blank-input:focus {
  outline: none;
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--card));
  border-bottom-color: var(--accent-deep);
}
.handout-note {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.handout-note label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 0.4rem;
}
.note-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: var(--card);
  color: var(--ink);
  resize: vertical;
  font: inherit;
}
.note-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== Rotation path ===== */
.path-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.path-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow);
}
.path-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.path-item.done {
  opacity: 0.92;
}
.path-day {
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  min-width: 3.5rem;
}
.path-info { flex: 1; min-width: 0; }
.path-info h3 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.path-info p { margin: 0; font-size: 0.85rem; color: var(--ink-muted); }
.path-today h2 { font-size: 1.5rem; }

@media (max-width: 700px) {
  .path-item { flex-direction: column; align-items: stretch; }
  .blank-input { max-width: 100%; width: 6.5rem; }
}

@media print {
  .handout-body .blank-input,
  .handout-body .note-input {
    border-bottom: 1px solid #333 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .guide-sidebar { display: none !important; }
}

/* ===== Improved study notes ===== */
.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.note-item {
  position: relative;
  padding: 0.65rem 0.85rem 0.65rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  border-left: 3px solid var(--accent);
  line-height: 1.5;
  font-size: 0.98rem;
}
.note-item.note-warn {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.note-item.note-tx {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}
.note-item.note-dx {
  border-left-color: #3b82f6;
  background: color-mix(in srgb, #3b82f6 10%, var(--card));
}
.note-item.note-adr {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}
.note-item .term {
  font-weight: 700;
  color: var(--accent-deep);
  margin-right: 0.25rem;
}
.note-item .term-sep {
  color: var(--ink-faint);
  margin-right: 0.35rem;
}
.note-item .drug {
  color: var(--accent-deep);
}
.sec-num {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-right: 0.45rem;
}
.guide-section h2 {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
}

/* Audio card at top of guide */
.guide-audio-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #0d6e6e, #0f766e 55%, #134e4a);
  color: #ecfdf5;
  box-shadow: 0 8px 24px rgba(13, 110, 110, 0.28);
}
.guide-audio-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.guide-audio-left strong {
  display: block;
  font-size: 0.95rem;
}
.guide-audio-left span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.85;
}
.guide-audio-card .btn-primary {
  background: #fff;
  color: #0d6e6e;
  box-shadow: none;
}
.guide-audio-card .btn-ghost {
  color: #ecfdf5;
  border-color: rgba(255,255,255,0.25);
}
.guide-audio-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.rate-select {
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.2);
  color: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Side scratch notes */
.side-notes {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  background: var(--bg-elevated);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  resize: vertical;
  min-height: 120px;
}
.side-notes:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== Inline word blanks (not huge boxes) ===== */
.handout-body {
  font-size: 1.02rem;
  line-height: 1.85;
}
.handout-line {
  margin: 0.35rem 0;
  line-height: 1.9;
}
.handout-line.static {
  color: var(--ink);
  opacity: 0.95;
}
.inline-blank {
  display: inline;
  width: 9ch;
  min-width: 5ch;
  max-width: 100%;
  margin: 0 0.12rem;
  padding: 0.05rem 0.25rem 0.08rem;
  border: none;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 700;
  font-size: 0.98em;
  line-height: 1.2;
  vertical-align: baseline;
  transition: background 0.12s ease, width 0.1s ease;
}
.inline-blank:hover,
.inline-blank:focus {
  outline: none;
  background: var(--accent-soft);
  border-bottom-color: var(--accent-deep);
}
.inline-blank.long {
  display: inline-block;
  width: min(100%, 28ch);
  min-width: 12ch;
  font-weight: 500;
  color: var(--ink);
}
.handout-inline-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.25rem 0;
}
.handout-inline-note .mini-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  flex-shrink: 0;
}
.handout-inline-note .inline-blank.long {
  flex: 1;
  border-bottom-color: var(--line);
  font-weight: 500;
}

/* Remove old large blank styles dominance */
.blank-input {
  /* legacy — prefer inline-blank */
  display: inline;
  min-width: 6ch;
  max-width: 18ch;
  width: auto;
  margin: 0 0.1rem;
  padding: 0.05rem 0.3rem;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  border-radius: 0;
  font-weight: 700;
  color: var(--accent-deep);
}
.handout-note {
  display: none; /* deprecated large boxes */
}

[data-theme="dark"] .guide-audio-card {
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
[data-theme="dark"] .note-item {
  background: var(--bg-soft);
}
[data-theme="dark"] .inline-blank {
  color: var(--accent);
}

@media print {
  .inline-blank, .side-notes {
    border-bottom: 1px solid #333 !important;
    background: transparent !important;
    color: #000 !important;
  }
  .guide-audio-card { display: none !important; }
}

/* ===== Improved sticky audio player ===== */
.audio-bar {
  display: none;
}
.audio-bar.visible {
  display: block;
}
.audio-bar[hidden] {
  display: none !important;
}
.audio-inner {
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
}
.audio-controls {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.audio-bar .btn-icon {
  min-width: 42px;
  height: 42px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.audio-bar .audio-play-main {
  min-width: 48px;
  height: 48px;
  font-size: 1rem;
  background: rgba(94, 234, 212, 0.22) !important;
  border-color: rgba(94, 234, 212, 0.45) !important;
}
.audio-bar .audio-play-main.is-playing {
  background: rgba(94, 234, 212, 0.35) !important;
}
.audio-bar .audio-play-main.is-paused {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.55);
}
.audio-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.audio-title-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-status-pill {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: #e8f5f5;
}
.audio-status-pill.playing {
  background: rgba(52, 211, 153, 0.25);
  color: #a7f3d0;
}
.audio-status-pill.paused {
  background: rgba(251, 191, 36, 0.22);
  color: #fde68a;
}
.audio-status-pill.loading {
  background: rgba(147, 197, 253, 0.22);
  color: #bfdbfe;
}
.audio-progress {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  margin-top: 0.5rem;
  cursor: pointer;
  touch-action: none;
}
.audio-progress > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5eead4, #99f6e4);
  border-radius: 999px;
  transition: width 0.08s linear;
  pointer-events: none;
}
.audio-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  margin-left: -7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  pointer-events: none;
  transition: left 0.08s linear;
}
.audio-progress:hover {
  height: 10px;
}
.audio-end {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.audio-end .rate-select {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.audio-end .rate-select option {
  color: #111;
}

/* Guide card listen button active state */
#guide-audio-play.audio-active,
button.audio-active[data-audio-module] {
  box-shadow: 0 0 0 2px rgba(13, 110, 110, 0.25);
}
.guide-audio-card #guide-audio-play.audio-active {
  box-shadow: 0 0 0 2px rgba(255,255,255,0.45);
}

@media (max-width: 700px) {
  .audio-inner {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .audio-controls {
    justify-content: center;
  }
  .audio-end {
    justify-content: space-between;
  }
}
