:root {
  color-scheme: light;
  --bg: #071019;
  --panel: #fff;
  --ink: #20352f;
  --muted: #6a7771;
  --line: #e0e6e2;
  --brand: #16775f;
  --brand-dark: #105b49;
  --tint: #eaf4ef;
  --note-ink: #24382f;
  --note-paper: #fffefa;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
summary {
  cursor: pointer;
}
button {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  line-height: 1.3;
  min-height: 36px;
}
button:hover {
  background: var(--tint);
  border-color: #b6cfc2;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.active,
.primary,
.tool-action,
#saveNote {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #72ae9b;
  outline-offset: 3px;
}
input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  color: var(--ink);
}
h1,
h2,
h3,
p {
  margin: 0;
}
h2 {
  font-size: 16px;
}
p {
  line-height: 1.65;
}
small,
.muted {
  color: var(--muted);
}
[hidden] {
  display: none !important;
}
.app-shell {
  height: 100dvh;
  min-height: 500px;
}
.workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.app-topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 26px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--brand);
  color: white;
  border-radius: 12px;
  font-weight: 750;
  font-size: 22px;
}
.topnav-brand strong {
  display: block;
  font-size: 19px;
  letter-spacing: -0.5px;
}
.topnav-brand span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  max-width: 200px;
}
.topnav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-item {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 10px 14px;
  display: flex;
  gap: 7px;
  align-items: center;
}
.nav-item.active {
  background: var(--tint);
  color: var(--brand);
  font-weight: 600;
}
.topnav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.local-badge {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.icon-button {
  min-width: 38px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 28px 8px;
}
.page-title {
  min-width: 0;
}
.page-title strong {
  display: block;
  font-size: 22px;
  letter-spacing: -0.4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  max-width: 65vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  flex: 0 0 240px;
}
.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
}
.workspace-status {
  padding: 0 28px 12px;
  display: flex;
  gap: 20px;
  align-items: center;
  min-height: 30px;
  font-size: 12px;
  color: var(--muted);
}
#appNotice {
  color: var(--brand);
}
#appNotice.error {
  color: #9b352d;
}
#saveStatus {
  white-space: nowrap;
}
.study-grid {
  display: grid;
  grid-template-columns: minmax(0, var(--study-left-width, 55%)) 14px minmax(340px, 1fr);
  padding: 0 24px 24px;
  flex: 1;
  min-height: 0;
}
.source-panel,
.study-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  overflow: hidden;
}
.source-panel {
  display: flex;
  flex-direction: column;
}
.study-panel {
  display: flex;
  flex-direction: column;
}
.study-splitter {
  cursor: col-resize;
  position: relative;
  touch-action: none;
}
.study-splitter::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 45%;
  height: 36px;
  width: 4px;
  background: #c7d3cb;
  border-radius: 4px;
}
.study-splitter:hover::after {
  background: var(--brand);
}
.highlight-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.highlight-swatches {
  display: flex;
  gap: 5px;
}
.highlight-swatches button {
  width: 21px;
  height: 21px;
  min-height: 21px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}
.highlight-swatches button.active {
  border-color: var(--ink);
}
.yellow {
  background: #ffe79a !important;
}
.green {
  background: #bbe9cd !important;
}
.blue {
  background: #bcddff !important;
}
.pink {
  background: #ffd1df !important;
}
.highlight-tools input {
  flex: 1;
  min-width: 60px;
  font-size: 12px;
  padding: 8px;
}
.highlight-tools #applyHighlight {
  background: var(--tint);
  color: var(--brand);
  border: 0;
}
.source-mode-switch {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 12px 18px 0;
}
.mode-chip {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.mode-chip.active {
  background: var(--tint);
  color: var(--brand);
}
.source-warning {
  font-size: 12px;
  color: #825916;
  background: #fff8e9;
  border-radius: 8px;
  margin: 8px 18px 0;
  padding: 8px 12px;
  line-height: 1.5;
}
.source-reader {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.reader-surface {
  height: 100%;
  overflow: auto;
  padding: 16px 20px 24px;
}
.reader-surface-original {
  display: none;
}
.source-panel[data-source-view="original"] .reader-surface-extracted {
  display: none;
}
.source-panel[data-source-view="original"] .reader-surface-original {
  display: block;
}
.document-page {
  max-width: 760px;
  margin: auto;
  padding: 28px 30px;
  line-height: 1.8;
  color: #34423b;
}
.document-hero {
  display: none !important;
}
.page-kicker {
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-size: 11px !important;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 12px !important;
}
.document-page h1 {
  font-size: clamp(25px, 2.5vw, 36px);
  line-height: 1.22;
  letter-spacing: -0.7px;
  margin-bottom: 24px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.document-page p[data-paragraph] {
  font-size: calc(16px * var(--reading-text-scale, 1));
  line-height: 1.85;
  margin-bottom: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.document-page[data-fit="wide"] {
  max-width: none;
}
.source-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
  background: #fbfcfb;
}
.source-toolbar > div:first-of-type:not(.page-controls) {
  display: none;
}
.source-toolbar strong {
  font-size: 12px;
}
.source-toolbar > div > span {
  font-size: 11px;
}
.source-page-pin,
.pdf-surface-status-inline {
  display: none;
}
.page-controls,
.reading-tools,
.page-fit-tools {
  display: flex;
  gap: 5px;
}
.page-controls button {
  min-width: 36px;
}
.reading-tools button,
.page-fit-tools button {
  font-size: 11px;
  padding: 7px 9px;
}
.page-fit-tools {
  margin-left: auto;
}
.focus-controls {
  display: none;
  padding: 8px 16px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.focus-reading .focus-controls {
  display: flex;
}
.focus-hint {
  color: var(--muted);
  margin-left: auto;
}
.focus-reading [data-paragraph] {
  opacity: 0.5;
}
.focus-reading .focus-active {
  opacity: 1;
  background: #f1f7ec;
  border-left: 3px solid var(--brand);
  padding: 8px 12px;
}
.highlight-yellow {
  background: #ffedaa;
}
.highlight-green {
  background: #c8edd4;
}
.highlight-blue {
  background: #cde5ff;
}
.highlight-pink {
  background: #ffd8e3;
}
.search-hit {
  background: #fde495;
}
.highlight-sticker {
  padding: 0 3px;
  min-height: 22px;
  font-size: 12px;
  margin: 0 3px;
  vertical-align: middle;
}
.highlight-popover {
  position: fixed;
  z-index: 60;
  max-width: 280px;
  border: 1px solid var(--line);
  padding: 14px;
  background: #fffef4;
  border-radius: 10px;
  box-shadow: 0 8px 30px #20352f22;
}
.highlight-popover p {
  margin-top: 6px;
}
.pdf-stage {
  height: 100%;
  overflow: auto;
}
.pdf-stage-dock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
}
.pdf-stage-title strong {
  display: block;
}
.pdf-stage-title span {
  color: var(--muted);
  font-size: 12px;
}
.pdf-stage-zoom {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pdf-pages {
  width: max-content;
  min-width: 100%;
  display: flex;
  justify-content: center;
}
.pdf-page-canvas {
  flex-shrink: 0;
  max-width: none;
  box-shadow: 0 4px 20px #20352f16;
}
#pdfEmpty {
  padding: 32px 16px;
  color: var(--muted);
}
.tool-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  padding: 8px 12px 0;
  gap: 2px;
  overflow: auto;
}
.tool-tab {
  flex: 1;
  border: 0;
  border-radius: 0;
  padding: 12px 10px;
  color: var(--muted);
  background: white;
  white-space: nowrap;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tool-tab.active {
  background: white;
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 650;
}
.tool-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px;
}
.answer-block {
  display: grid;
  gap: 18px;
}
.study-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  min-width: 0;
  overflow-wrap: anywhere;
}
.study-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
}
.study-card p,
.study-card li {
  font-size: 14px;
  line-height: 1.65;
}
.study-card ul,
.study-card ol {
  padding-left: 20px;
  margin: 10px 0 0;
}
.study-context {
  background: #f8faf8;
  border: 0;
  padding: 12px 14px;
}
.study-context strong {
  display: none;
}
.study-context p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.study-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.study-context-state,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  font-size: 11px;
  background: var(--tint);
  color: var(--brand-dark);
  border-radius: 5px;
  padding: 3px 6px;
  line-height: 1.4;
}
.section-banner {
  display: none;
}
.tool-action {
  margin-bottom: 16px;
  padding: 10px 16px;
}
.report-hero {
  background: #f8faf8;
}
.report-hero-summary {
  display: none;
}
.report-hero-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.report-hero-header p {
  font-size: 12px;
  color: var(--muted);
}
.report-metrics {
  display: none;
}
.summary-board .study-card strong {
  color: var(--brand-dark);
}
.notes-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.note-card {
  border: 0;
  padding: 0;
}
.note-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.note-title-row strong {
  margin: 0;
  font-size: 17px;
}
.note-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.note-settings-toggle {
  font-size: 12px;
}
.note-export-menu {
  position: relative;
}
.note-export-menu summary {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}
.note-export-menu-body {
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 5;
  background: white;
  padding: 8px;
  box-shadow: 0 5px 20px #20352f22;
  border-radius: 8px;
  min-width: 140px;
  display: grid;
  gap: 4px;
}
.note-mode-row {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}
.note-mode-row button {
  font-size: 11px;
  padding: 5px 9px;
  min-height: 30px;
}
.math-symbol-row {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  margin: 10px 0;
}
.note-fixed-tools:has([data-note-mode="math"].active) .math-symbol-row {
  display: flex;
}
.math-symbol-row button {
  padding: 5px 8px;
  min-height: 30px;
}
.note-scroll-area {
  display: block;
}
.note-a4-preview {
  padding: 16px;
  background: var(--note-paper);
  border: 1px solid #dedfd6;
  border-radius: 10px;
  min-height: 260px;
  width: 100%;
}
.note-box {
  width: 100%;
  height: 270px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--note-paper);
  color: var(--note-ink);
  font-size: var(--note-font-size, 14px);
  line-height: var(--note-line-height, 1.6);
  display: block;
}
.note-box.lined {
  background-image: linear-gradient(
    transparent calc(var(--note-row) - 1px),
    #dce4db var(--note-row)
  );
  background-size: 100% var(--note-row);
}
.note-box.grid,
.note-box.math {
  background-image:
    linear-gradient(to right, #e4e9df 1px, transparent 1px),
    linear-gradient(#e4e9df 1px, transparent 1px);
  background-size: 22px 22px;
}
.note-font-serif {
  font-family: Georgia, serif;
}
.note-font-mono {
  font-family: monospace;
}
.save-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.save-row .tag {
  background: none;
  color: var(--muted);
}
.saved-items {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: grid;
  gap: 12px;
}
.saved-items h2 span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.saved-note {
  padding: 14px;
  background: #f8faf8;
  border-radius: 9px;
  overflow-wrap: anywhere;
}
.saved-note p {
  white-space: pre-wrap;
  margin-bottom: 8px;
}
.saved-note small {
  margin-right: 16px;
}
.saved-note button {
  font-size: 11px;
  padding: 5px 9px;
  min-height: 28px;
  margin-left: 5px;
}
.vocabulary-list {
  padding-top: 12px;
}
.vocabulary-list h2 {
  margin-bottom: 12px;
}
.vocabulary-list button {
  margin: 0 6px 6px 0;
  background: var(--tint);
  font-size: 12px;
  border: 0;
}
.note-settings-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: #172a2255;
  z-index: 100;
  padding: 24px;
  align-items: center;
  justify-content: center;
}
.note-settings-backdrop.open {
  display: flex;
}
.note-settings-modal {
  width: min(100%, 440px);
  max-height: 90dvh;
  overflow: auto;
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 50px #0002;
}
.note-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.note-settings-header strong {
  font-size: 20px;
}
.note-settings-grid {
  display: grid;
  gap: 16px;
}
.note-settings-grid label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.note-settings-grid input {
  min-width: 0;
  max-width: 65%;
}
.note-settings-grid input[type="color"] {
  padding: 2px;
  width: 80px;
  height: 36px;
}
.deck-grid {
  gap: 14px;
}
.flashcard-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.flashcard-card details {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.flashcard-answer {
  padding-top: 12px;
}
.quiz-card-header {
  display: flex;
  justify-content: space-between;
}
.quiz-options {
  display: grid;
  gap: 8px;
}
.quiz-options button {
  width: 100%;
  text-align: left;
}
.quiz-answer-panel {
  margin-top: 16px;
}
.quiz-answer-panel summary {
  color: var(--brand);
  padding: 8px 0;
}
.quiz-answer-callout {
  background: var(--tint);
  padding: 12px;
  border-radius: 8px;
}
.quiz-answer-callout strong {
  display: inline;
}
.control-label {
  display: block;
  font-size: 12px;
  margin: 18px 0 8px;
  color: var(--muted);
}
.segmented-control,
.level-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.level-card {
  flex: 1;
  min-width: 110px;
  text-align: left;
}
.level-card strong {
  margin-bottom: 5px;
}
.level-card span {
  font-size: 12px;
  line-height: 1.5;
}
.companion-flow,
.companion-checks {
  display: grid;
  gap: 12px;
}
.companion-status .tag {
  margin-top: 10px;
}
.pdf-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 170px;
  max-height: 420px;
  overflow: auto;
  padding: 0 0 18px;
}
.chat-message {
  padding: 12px 14px;
  background: #f2f5f2;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.chat-message.user {
  background: var(--tint);
  margin-left: 24px;
}
.chat-message.assistant {
  margin-right: 12px;
}
.chat-message strong {
  font-size: 11px;
  color: var(--muted);
}
.pdf-chat-form {
  display: flex;
  gap: 8px;
  align-items: end;
}
.pdf-chat-form textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
  min-height: 44px;
  max-height: 150px;
}
.pdf-chat-form button {
  background: var(--brand);
  color: white;
  min-height: 44px;
}
.chat-side-tools {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.chat-suggestions,
.chat-voice-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chat-label {
  display: block;
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.chat-suggestions button,
.chat-voice-controls button {
  font-size: 12px;
}
.voice-status {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.ask-help summary {
  font-size: 13px;
  color: var(--brand);
}
.library-book-row,
.book-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px;
  margin-bottom: 8px;
}
.library-book-row strong,
.book-card strong {
  display: block;
}
.library-book-row span,
.book-card span {
  display: block;
  font-size: 12px;
  margin-top: 4px;
}
.library-book-row.active {
  background: var(--tint);
  color: var(--brand);
  border-color: #adccbd;
}
.library-group-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 10px;
}
.library-page-list {
  display: grid;
  gap: 8px;
}
.library-page-list button {
  text-align: left;
}
.library-page-list span {
  display: block;
  font-size: 12px;
}
.library-summary,
.library-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.source-container-card dl {
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.source-container-card dl > div {
  display: flex;
  gap: 12px;
}
.source-container-card dt {
  color: var(--muted);
  min-width: 48px;
}
.source-container-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.import-status {
  font-size: 13px;
  line-height: 1.6;
  margin: 10px 0;
  color: var(--muted);
}
.import-status-error {
  color: #9b352d;
}
.danger-zone {
  border-color: #ead9d4;
}
.danger-zone button {
  color: #973e30;
  margin-top: 12px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.metric-card {
  padding: 18px;
  background: #f5f8f5;
  border-radius: 10px;
}
.metric-card strong {
  display: block;
  font-size: 25px;
  color: var(--brand);
}
.metric-card span {
  font-size: 12px;
  color: var(--muted);
}
.progress-meter {
  height: 8px;
  background: #e9efea;
  border-radius: 8px;
  margin: 18px 0 10px;
  overflow: hidden;
}
.progress-meter span {
  display: block;
  height: 100%;
  background: var(--brand);
}
.progress-hero em {
  font-size: 12px;
  color: var(--muted);
  font-style: normal;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.settings-button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.settings-card p {
  color: var(--muted);
  margin-bottom: 12px;
}
.context-menu {
  display: none;
  position: fixed;
  z-index: 70;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 30px #0002;
}
.context-menu.open {
  display: grid;
  gap: 4px;
}
.context-menu button {
  text-align: left;
  border: 0;
}
.empty-state {
  padding: 24px;
}
.empty-state h2 {
  margin-bottom: 12px;
}
.app-shell:not([data-view="study"]) .source-panel,
.app-shell:not([data-view="study"]) .study-splitter {
  display: none;
}
.app-shell:not([data-view="study"]) .study-grid {
  grid-template-columns: minmax(0, 920px);
  justify-content: center;
}
.app-shell:not([data-view="study"]) .tool-tabs {
  display: none;
}
.app-shell:not([data-view="study"]) .tool-content {
  padding: 28px;
}
.app-shell.study-collapsed[data-view="study"] .study-grid {
  grid-template-columns: 1fr;
}
.app-shell.study-collapsed[data-view="study"] .study-panel,
.app-shell.study-collapsed .study-splitter {
  display: none;
}
.mobile-switch {
  display: none;
}
/* APR navy shell; document and study surfaces retain their reading contrast. */
.app-topnav {
  background: #0a141f;
  border-bottom-color: #1d2a37;
}
.topnav-brand strong,
.page-title strong {
  color: #f1f5f9;
}
.topnav-brand span,
.local-badge,
.page-title span,
.workspace-status {
  color: #8fa1b3;
}
.nav-item {
  color: #aab8c7;
}
.nav-item:hover {
  color: #f1f5f9;
  background: #111d29;
}
.nav-item.active {
  color: #bce9d9;
  background: #13372f;
}
.topnav-actions .icon-button {
  background: #0d1824;
  border-color: #1d2a37;
  color: #c4d0da;
}
#appNotice {
  color: #8bd5b6;
}
#appNotice.error {
  color: #ffb4a9;
}
.study-splitter::after {
  background: #3c5367;
}

@media (max-width: 1100px) {
  .app-topnav {
    gap: 12px;
    padding: 12px 18px;
  }
  .local-badge,
  .topnav-brand span {
    display: none;
  }
  .nav-item {
    padding: 10px;
  }
  .study-grid {
    grid-template-columns: minmax(0, 1fr) 10px minmax(320px, 0.9fr);
    padding: 0 16px 16px;
  }
  .document-page {
    padding: 20px 12px;
  }
  .tool-content {
    padding: 16px;
  }
  .study-context-header {
    align-items: start;
    flex-direction: column;
  }
  .page-fit-tools {
    margin-left: 0;
  }
  .reading-tools {
    flex-wrap: wrap;
  }
  .topnav-actions {
    gap: 6px;
  }
}
@media (max-width: 760px) {
  .app-shell {
    min-height: 0;
  }
  .app-topnav {
    padding: 10px 14px;
    gap: 12px;
    flex-wrap: wrap;
  }
  .topnav-brand strong {
    font-size: 17px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .topnav-actions {
    margin-left: auto;
  }
  .topnav-tabs {
    order: 3;
    width: 100%;
    overflow: auto;
    justify-content: space-between;
    gap: 0;
  }
  .nav-item {
    padding: 10px 8px;
    font-size: 12px;
    min-height: 40px;
  }
  .nav-item > span:first-child {
    display: none;
  }
  .icon-button {
    display: none;
  }
  .topbar {
    padding: 14px 16px 6px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .page-title strong {
    font-size: 19px;
  }
  .page-title span {
    max-width: 90vw;
  }
  .search-box {
    flex: 1 1 100%;
    max-height: 36px;
  }
  .search-box input {
    padding: 8px;
    font-size: 13px;
  }
  .workspace-status {
    padding: 2px 16px 8px;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 11px;
  }
  .mobile-switch {
    display: flex;
    padding: 0 16px 10px;
    gap: 6px;
  }
  .mobile-switch button {
    flex: 1;
    background: #e7ede8;
    border: 0;
    min-height: 38px;
  }
  .app-shell[data-mobile-pane="reader"] #mobileReader,
  .app-shell[data-mobile-pane="study"] #mobileStudy {
    background: var(--brand);
    color: white;
  }
  .study-grid,
  .app-shell.study-collapsed[data-view="study"] .study-grid {
    display: flex;
    min-height: 0;
    padding: 0 10px 10px;
  }
  .study-splitter {
    display: none;
  }
  .source-panel,
  .study-panel {
    width: 100%;
    flex: 1;
  }
  .app-shell[data-view="study"][data-mobile-pane="reader"] .study-panel {
    display: none;
  }
  .app-shell[data-view="study"][data-mobile-pane="study"] .source-panel {
    display: none;
  }
  .app-shell[data-view="study"][data-mobile-pane="study"] .study-panel {
    display: flex;
  }
  .app-shell:not([data-view="study"]) .mobile-switch {
    display: none;
  }
  .highlight-tools {
    padding: 9px 10px;
    gap: 6px;
  }
  .highlight-tools input {
    font-size: 11px;
  }
  .highlight-swatches {
    gap: 3px;
  }
  .highlight-swatches button {
    width: 18px;
    height: 18px;
    min-height: 18px;
  }
  .highlight-tools button {
    font-size: 11px;
    padding: 7px;
  }
  .source-mode-switch {
    padding: 8px 10px 0;
  }
  .source-warning {
    margin: 6px 10px 0;
    font-size: 11px;
    padding: 6px 9px;
  }
  .reader-surface {
    padding: 10px 8px;
  }
  .document-page {
    padding: 12px;
  }
  .document-page h1 {
    font-size: 25px;
    margin-bottom: 18px;
  }
  .document-page p[data-paragraph] {
    font-size: 15px;
    line-height: 1.75;
  }
  .source-toolbar {
    padding: 8px 10px;
    gap: 5px;
  }
  .source-toolbar #sourcePage {
    display: none;
  }
  .reading-tools button,
  .page-fit-tools button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 11px;
  }
  .page-fit-tools {
    display: none;
  }
  .tool-tabs {
    padding: 4px 6px 0;
  }
  .tool-tab {
    padding: 12px 7px;
    font-size: 12px;
    min-height: 44px;
  }
  .tool-content {
    padding: 14px;
    overflow-x: hidden;
  }
  .note-a4-preview {
    min-height: 200px;
    padding: 12px;
  }
  .note-box {
    height: 220px;
    min-width: 0;
  }
  .study-context-header {
    gap: 7px;
  }
  .note-settings-backdrop {
    padding: 14px;
  }
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .level-grid,
  .segmented-control {
    flex-direction: column;
  }
  .level-card {
    width: 100%;
  }
  .source-panel .focus-hint {
    display: none;
  }
  .source-panel .focus-controls {
    flex-wrap: wrap;
  }
  .app-shell:not([data-view="study"]) .tool-content {
    padding: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

.book-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.book-picker label {
  font-size: 12px;
  color: var(--muted);
}
.book-picker select {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 8px;
}
.book-picker button {
  font-size: 11px;
  white-space: nowrap;
}
.page-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.page-jump input {
  width: 76px;
  padding: 6px;
}
.page-jump button {
  padding: 6px 9px;
}
@media (max-width: 760px) {
  .book-picker {
    padding: 8px 10px;
    gap: 6px;
  }
  .book-picker button {
    font-size: 10px;
    padding: 7px;
  }
  .book-picker select {
    font-size: 12px;
  }
  .page-jump input {
    width: 65px;
  }
}

.study-scope {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f4f8f6;
  flex-shrink: 0;
}
.study-scope form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}
.study-scope form > strong {
  flex-basis: 100%;
}
.study-scope label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}
.study-scope input {
  width: 70px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}
.study-scope p {
  font-size: 12px;
  margin: 8px 0 0;
}
.source-citation {
  color: #09624e;
  margin-top: 8px;
  text-align: left;
}
.source-evidence blockquote,
.written-practice blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid #288773;
  background: #f1f7f4;
  overflow-wrap: anywhere;
}
.written-practice textarea {
  display: block;
  width: 100%;
  min-height: 90px;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}
.written-practice details {
  margin-top: 12px;
}
.restore-backup {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}
.restore-backup input {
  max-width: 100%;
}
.extraction-gap {
  border-color: #a36c18;
  background: #fff8e9;
}

.navigation-collapsed .topnav-tabs {
  display: none;
}
#toggleNavigation,
#toggleStudyPanel {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: #e7f0f8;
  background: #132637;
  border-color: #2a4053;
}
.study-panel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.study-panel-toolbar label {
  font-size: 12px;
  color: var(--muted);
}
.study-panel-toolbar select {
  flex: 1;
  min-width: 0;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tools-folded .tool-tabs {
  display: none;
}
.app-shell:not([data-view="study"]) .study-panel-toolbar {
  display: none;
}
.tutor-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}
.tutor-header h2 {
  font-size: 22px;
  margin: 0;
}
.tutor-header p {
  margin: 6px 0 12px;
}
.tutor-header label {
  display: flex;
  gap: 10px;
  align-items: center;
}
.tutor-header select {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.tutor-header small {
  display: block;
  color: var(--muted);
  margin-top: 8px;
}
.tutor-chat .pdf-chat-messages {
  flex: 1;
  min-height: 200px;
  max-height: 48vh;
  padding: 4px;
}
.tutor-chat .pdf-chat-form {
  display: flex;
  gap: 8px;
  align-items: end;
  padding: 8px 0;
}
.tutor-chat .pdf-chat-form textarea {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: vertical;
}
.chat-message p {
  white-space: pre-wrap;
}
.chat-source {
  margin-top: 12px;
}
.chat-source blockquote {
  margin: 8px 0;
  padding: 10px;
  border-left: 3px solid #288773;
}
.tutor-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tutor-voice {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.tutor-voice .chat-voice-controls {
  margin-top: 12px;
  flex-direction: row;
  flex-wrap: wrap;
}
@media (max-width: 700px) {
  .app-topnav {
    flex-wrap: wrap;
    gap: 8px;
  }
  .topnav-actions {
    margin-left: auto;
    gap: 6px;
  }
  #toggleStudyPanel {
    display: none;
  }
  .study-panel-toolbar label {
    display: none;
  }
  .study-panel-toolbar {
    padding: 8px;
  }
  .study-scope {
    padding: 8px 12px;
  }
}
/* Keep the composer nearby, with panel scrolling when controls exceed its height. */
.tool-content:has(> .tutor-chat) {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #82968f #edf2ef;
}
.tutor-chat {
  flex: 1;
  height: 100%;
  min-height: 0;
}
.tutor-chat > :not(.pdf-chat-messages) {
  flex-shrink: 0;
}
.tutor-chat .pdf-chat-messages {
  min-height: 70px;
  max-height: none;
  overflow: auto;
}
.tutor-voice[open] {
  max-height: 150px;
  overflow: auto;
}

/* Main navigation lives beside the workspace and folds completely out of the way. */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}
.app-shell.navigation-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.workspace {
  min-width: 0;
}
.app-topnav {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 24px;
  height: 100dvh;
  min-height: 0;
  padding: 20px 16px;
  border-bottom: 0;
  border-right: 1px solid #1d2a37;
  overflow-y: auto;
}
.app-topnav[hidden] {
  display: none;
}
.app-topnav .topnav-brand {
  align-items: flex-start;
}
.app-topnav .topnav-brand span {
  display: block;
  max-width: 145px;
  line-height: 1.5;
  margin-top: 5px;
}
.app-topnav .topnav-tabs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
  width: 100%;
  gap: 6px;
  overflow: visible;
  order: initial;
}
.app-topnav .nav-item {
  width: 100%;
  padding: 12px;
}
.app-topnav .topnav-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin: auto 0 0;
}
.app-topnav .local-badge {
  display: block;
  padding: 0 4px;
}
.app-topnav #toggleStudyPanel {
  display: flex;
  justify-content: center;
}
#closeSidebar {
  color: #c4d0da;
  background: #132637;
  border-color: #2a4053;
  text-align: left;
}
.topbar {
  flex-wrap: nowrap;
}
.topbar .page-title {
  flex: 1;
  min-width: 0;
}
.topbar #toggleNavigation {
  flex-shrink: 0;
}
.sidebar-backdrop {
  display: none;
}
@media (max-width: 700px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-topnav {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 85vw);
    z-index: 101;
    flex-wrap: nowrap;
  }
  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 100;
    border: 0;
    border-radius: 0;
    background: #0008;
  }
  .topbar {
    flex-wrap: wrap;
    padding-top: 14px;
  }
  .topbar .page-title {
    flex-basis: calc(100% - 85px);
  }
  .topbar .search-box {
    flex-basis: 100%;
  }
}

.pdf-stage {
  overscroll-behavior: contain;
}

.study-scope {
  max-height: 38vh;
  overflow: auto;
}
.study-scope select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.study-scope .scope-main {
  flex: 1;
  min-width: 150px;
}
.study-scope details {
  margin-top: 8px;
  font-size: 12px;
}
#chapterForm {
  margin-top: 10px;
}
#chapterForm label:has(select),
#chapterForm label:has(#chapterName) {
  flex-basis: 100%;
}
#chapterName {
  width: 100%;
}
.scope-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
}
.ask-scope-label {
  font-size: 12px;
  color: var(--muted);
}

#courseRulesForm {
  display: grid;
  gap: 12px;
}
#courseRulesForm label {
  display: grid;
  gap: 6px;
}
#courseRulesForm input,
#courseRulesForm select,
#courseRulesForm textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.privacy-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
}
.privacy-option input {
  flex-shrink: 0;
  margin-top: 5px;
}
.course-policy-strip {
  padding: 8px 14px;
  background: #f2f6f4;
  color: #34564c;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  flex-shrink: 0;
}

.learning-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
}
.learning-panel form,
.learning-panel label {
  display: grid;
  gap: 8px;
}
.learning-panel input:not([type="checkbox"]),
.learning-panel textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid #a6b4c2;
  border-radius: 8px;
  font: inherit;
}
.learning-panel button {
  white-space: normal;
  overflow-wrap: anywhere;
}
.course-folder {
  padding: 12px;
  border: 1px solid #ccd5df;
  border-radius: 10px;
}
.course-folder button,
#reviewCandidates button {
  display: block;
  margin: 8px 0;
  max-width: 100%;
}
.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.learning-panel blockquote {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow: auto;
}

/* Reader actions open above the footer without consuming PDF height. */
#readerToolsToggle {
  white-space: nowrap;
}
#readerToolsMenu {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 180px;
  max-height: min(300px, 70vh);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 8px 28px #07101933;
}
#readerToolsMenu:popover-open {
  display: grid;
  gap: 4px;
}
#readerToolsMenu button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
}

#studentPreferencesForm {
  display: grid;
  gap: 14px;
}
#studentPreferencesForm label:not(.privacy-option) {
  display: grid;
  gap: 6px;
}
#studentPreferencesForm input:not([type="checkbox"]),
#studentPreferencesForm select {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
}
.student-high-contrast {
  --muted: #37483f;
  --line: #67796e;
}
.student-high-contrast button,
.student-high-contrast input,
.student-high-contrast select,
.student-high-contrast textarea {
  border-color: #596d61;
}
.student-sans-reading #documentPage,
.student-sans-reading #documentPage p {
  font-family: Arial, Helvetica, sans-serif;
}
.student-reduced-motion *,
.student-reduced-motion *::before,
.student-reduced-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Shared company footer stays outside the scrolling study panels. */
.company-footer {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 20px;
  padding: 4px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
}
.company-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}
.company-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: inherit;
  text-decoration: none;
  text-underline-offset: 4px;
}
.company-footer .company-footer-brand {
  font-weight: 700;
}
.company-footer a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}
.company-footer a:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}
@media (max-width: 700px) {
  .company-footer {
    padding: 2px 14px;
    gap: 0 12px;
  }
  .company-footer a {
    min-height: 36px;
  }
  .company-footer nav {
    gap: 0 18px;
  }
}
@media print {
  .company-footer {
    display: none;
  }
}
