/* Reader — markdown side-by-side */

.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

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

.reader-path-input {
  flex: 1;
  min-width: 220px;
  font-family: var(--mono);
  font-size: 12px;
}

.reader-status {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.reader-shortcuts-hint {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .reader-shortcuts-hint { display: none; }
}

.reader-body {
  display: flex;
  gap: 16px;
  min-height: calc(100vh - 180px);
}

.reader-layout {
  flex: 1;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.reader-layout.reader-single {
  grid-template-columns: 1fr;
}

.reader-layout.reader-single .reader-pane-left,
.reader-layout.reader-single .reader-pane-right {
  display: none;
}

.reader-layout.reader-split {
  grid-template-columns: 1fr 1fr;
}

.reader-layout.reader-split .reader-pane-single {
  display: none;
}

.reader-pane {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.reader-pane-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 480px;
}

.reader-pane-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.reader-pane-head h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 120px;
}

.reader-lang-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
}

.reader-md {
  flex: 1;
  overflow: auto;
  padding: 20px 22px;
  font-size: 15px;
  line-height: 1.7;
  max-width: 46rem;
}

.reader-md.prose h1 { font-size: 1.5rem; margin: 0 0 12px; }
.reader-md.prose h2 { font-size: 1.15rem; margin: 20px 0 10px; color: var(--text); }
.reader-md.prose h3 { font-size: 1rem; margin: 16px 0 8px; }
.reader-md.prose p { margin: 0 0 12px; }
.reader-md.prose ul, .reader-md.prose ol { margin: 0 0 12px; padding-left: 22px; }
.reader-md.prose code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
}
.reader-md.prose pre {
  background: #1d1d1f;
  color: #f5f5f7;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0 0 14px;
}
.reader-md.prose pre code { background: none; padding: 0; color: inherit; }
.reader-md.prose table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.reader-md.prose th, .reader-md.prose td { border: 1px solid var(--border-light); padding: 6px 10px; text-align: left; }
.reader-md.prose blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 12px;
  padding: 8px 14px;
  background: var(--surface2);
  color: var(--muted);
}

.reader-related {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  align-self: flex-start;
  position: sticky;
  top: 12px;
}

.reader-related-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
}

.reader-related-group { margin-bottom: 14px; }
.rr-label { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }

.reader-related-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--surface2);
  font-size: 11px;
  font-family: var(--mono);
  cursor: pointer;
  color: var(--accent);
}
.reader-related-link:hover { background: rgba(0, 113, 227, 0.08); border-color: var(--accent); }

.reader-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  min-height: calc(100vh - 160px);
}

.reader-shell.picker-collapsed {
  grid-template-columns: 1fr;
}

.reader-shell.picker-collapsed .reader-picker {
  display: none;
}

.reader-picker {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 160px);
  overflow: hidden;
}

.reader-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.reader-tab {
  flex: 1;
  padding: 12px 10px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

.reader-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(0, 113, 227, 0.04);
}

.reader-picker-filters {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 1 auto;
  max-height: 58%;
  overflow-y: auto;
}

.reader-filter-search {
  font-size: 13px;
  width: 100%;
}

.reader-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.reader-filter-select {
  font-size: 11px;
  padding: 6px 8px;
  width: 100%;
}

.reader-filter-count {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.reader-picker-list {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reader-pick-row {
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}

.reader-pick-row:hover { border-color: var(--accent); }
.reader-pick-row.active {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.06);
  box-shadow: 0 0 0 1px rgba(0, 113, 227, 0.15);
}

.rpr-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 4px;
}

.rpr-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.rpr-path {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
  word-break: break-all;
}

.reader-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--border-light);
  text-transform: capitalize;
}

.reader-tag.pair {
  background: rgba(52, 199, 89, 0.12);
  color: #248a3d;
  border-color: rgba(52, 199, 89, 0.3);
}

.reader-tag.muted { color: var(--muted); }
.reader-tag.track { background: rgba(88, 86, 214, 0.1); color: #5856d6; border-color: rgba(88, 86, 214, 0.25); }
.reader-tag.order { background: rgba(52, 199, 89, 0.1); color: #248a3d; border-color: rgba(52, 199, 89, 0.28); }

.reader-track-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(88, 86, 214, 0.08);
  color: #5856d6;
  font-size: 11px;
}

.reader-track-step { display: flex; align-items: center; gap: 7px; margin-top: 2px; font-size: 11px; }
.reader-track-step span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #5856d6;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.reader-phase-grid,
.reader-module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.reader-phase-card,
.reader-module-option {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.reader-phase-card { min-height: 62px; }
.reader-module-option { min-height: 58px; }
.reader-phase-card:hover,
.reader-module-option:hover { border-color: #5856d6; }
.reader-phase-card.active,
.reader-module-option.active { border-color: #5856d6; background: rgba(88, 86, 214, 0.08); box-shadow: 0 0 0 1px rgba(88, 86, 214, 0.12); }
.reader-phase-card.done,
.reader-module-option.done { border-color: rgba(52, 199, 89, 0.42); }
.reader-phase-card span,
.reader-module-option span { color: #5856d6; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.reader-phase-card strong,
.reader-module-option strong { overflow: hidden; font-size: 10px; line-height: 1.3; }
.reader-phase-card small,
.reader-module-option small { color: var(--muted); font-size: 9px; }

.reader-phase-milestone {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-left: 3px solid #5856d6;
  border-radius: 0 7px 7px 0;
  background: rgba(88, 86, 214, 0.06);
}
.reader-phase-milestone strong { font-size: 10px; }
.reader-phase-milestone span,
.reader-track-prompt { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.4; }

.reader-selection-empty { padding: 24px 14px; text-align: center; color: var(--muted); }
.reader-selection-empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 13px; }
.reader-selection-empty p { margin: 0; font-size: 11px; line-height: 1.5; }

.reader-module-context {
  display: grid;
  gap: 9px;
  padding: 11px;
  margin-bottom: 2px;
  border: 1px solid rgba(88, 86, 214, 0.22);
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(88, 86, 214, 0.08), rgba(52, 199, 89, 0.035));
}

.reader-module-kicker {
  color: #5856d6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.reader-module-head,
.reader-module-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reader-module-head h3 { margin: 0 0 3px; font-size: 14px; }
.reader-module-head p,
.reader-module-evidence p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.reader-module-head > strong { color: #5856d6; font-size: 16px; }

.reader-module-evidence {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 10px;
}
.reader-module-evidence > div { padding: 8px; border-radius: 7px; background: rgba(255, 255, 255, 0.66); }
.reader-module-evidence ul { margin: 5px 0 0; padding-left: 16px; color: var(--muted); line-height: 1.45; }
.reader-module-actions { justify-content: center; }

.reader-module-complete {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.reader-module-complete:hover { border-color: #5856d6; }
.reader-module-complete.checked {
  border-color: rgba(52, 199, 89, 0.42);
  background: rgba(52, 199, 89, 0.08);
  color: #248a3d;
}
.reader-module-complete input { width: 15px; height: 15px; margin: 0; accent-color: #248a3d; }
.reader-module-complete input:disabled { cursor: wait; }

@media (max-width: 720px) {
  .reader-phase-grid,
  .reader-module-grid { grid-template-columns: 1fr; }
  .reader-module-evidence { grid-template-columns: 1fr; }
  .reader-module-actions { flex-wrap: wrap; }
}

.rpr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rpr-actions-study {
  align-items: center;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
  min-height: 26px;
}

.reader-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.reader-content-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.reader-content-actions.hidden { display: none; }

.reader-sequence-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.reader-sequence-nav.hidden { display: none; }

.reader-sequence-meta {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.reader-sequence-meta span,
.reader-sequence-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-sequence-meta span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reader-sequence-meta strong {
  font-size: 12px;
  color: var(--text);
}

.reader-content-hint {
  font-size: 12px;
  color: var(--muted);
}

.reader-fs-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.reader-fs-btn svg { flex-shrink: 0; }

.reader-empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.reader-empty-state p { margin: 0 0 8px; }

.reader-api-banner {
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 149, 0, 0.35);
  background: rgba(255, 149, 0, 0.08);
  color: #9a6700;
  font-size: 13px;
  line-height: 1.5;
}

.reader-api-banner.hidden { display: none; }

.reader-restart-cmd {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.06);
  font-family: var(--mono);
  font-size: 12px;
}

.reader-exit-fullscene {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: rgba(29, 29, 31, 0.88);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
}

.reader-exit-fullscene:hover { background: #1d1d1f; }
.reader-exit-fullscene.hidden { display: none; }

.reader-fullscreen-study-nav { display: none; }

body.reader-fullscene .reader-fullscreen-study-nav:not(.hidden) {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 9998;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: min(760px, calc(100vw - 250px));
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(29, 29, 31, 0.92);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.reader-full-nav-btn {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.reader-full-nav-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.reader-full-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.reader-full-nav-module { min-width: 0; padding: 0 4px; }
.reader-full-nav-module span,
.reader-full-nav-module strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-full-nav-module span { margin-bottom: 2px; color: rgba(255, 255, 255, 0.58); font-size: 9px; text-transform: uppercase; }
.reader-full-nav-module strong { color: #fff; font-size: 11px; }

.reader-full-nav-complete {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.reader-full-nav-complete.checked { border-color: rgba(52, 199, 89, 0.65); background: rgba(52, 199, 89, 0.16); color: #7ee69a; }
.reader-full-nav-complete input { width: 15px; height: 15px; margin: 0; accent-color: #34c759; }

/* Full-scene reading — hide chrome + maximize content */
body.reader-fullscene .sidebar,
body.reader-fullscene .topbar,
body.reader-fullscene .reader-toolbar,
body.reader-fullscene .reader-api-banner,
body.reader-fullscene .reader-picker,
body.reader-fullscene .reader-related,
body.reader-fullscene .reader-content-actions {
  display: none !important;
}

body.reader-fullscene .app {
  grid-template-columns: 1fr;
}

body.reader-fullscene .content-area {
  padding: 0 !important;
}

body.reader-fullscene #page-reader {
  height: 100vh;
}

body.reader-fullscene .reader-shell {
  grid-template-columns: 1fr;
  min-height: 100vh;
  max-height: none;
  gap: 0;
}

body.reader-fullscene .reader-body {
  min-height: 100vh;
}

body.reader-fullscene .reader-layout {
  min-height: 100vh;
}

body.reader-fullscene .reader-pane {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

body.reader-fullscene .reader-pane-inner {
  min-height: 100vh;
}

body.reader-fullscene .reader-md {
  padding: 28px clamp(20px, 5vw, 48px);
  max-width: 920px;
  margin: 0 auto;
}

body.reader-fullscene-study .reader-md { padding-bottom: 120px; }

@media (max-width: 900px) {
  body.reader-fullscene .reader-fullscreen-study-nav:not(.hidden) {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: auto 1fr auto;
    width: auto;
    transform: none;
  }
  .reader-full-nav-complete { grid-column: 1 / -1; justify-content: center; grid-row: 2; }
  body.reader-fullscene-study .reader-exit-fullscene { top: 12px; right: 12px; bottom: auto; }
  body.reader-fullscene-study .reader-md { padding-bottom: 150px; }
}

body.reader-fullscene .reader-layout.reader-split .reader-md {
  max-width: none;
  margin: 0;
}

body.reader-fullscene .reader-layout.reader-split .reader-pane-inner {
  min-height: 100vh;
}

/* Dark reading theme (Reader panes only) */
body.reader-dark .reader-pane {
  background: #1d1d1f;
  border-color: #333;
}

body.reader-dark .reader-pane-head {
  background: #2c2c2e;
  border-color: #333;
}

body.reader-dark .reader-pane-head h3 { color: #f5f5f7; }

body.reader-dark .reader-md {
  color: #e8e8ed;
}

body.reader-dark .reader-md.prose h2,
body.reader-dark .reader-md.prose h3 { color: #f5f5f7; }

body.reader-dark .reader-md.prose code {
  background: #2c2c2e;
  color: #ff9f0a;
}

body.reader-dark .reader-md.prose blockquote {
  background: #2c2c2e;
  color: #a1a1a6;
}

body.reader-dark .reader-lang-badge {
  background: rgba(10, 132, 255, 0.2);
  color: #64d2ff;
}

body.reader-dark .reader-empty-state { color: #a1a1a6; }

/* Study hub browser */
.study-browser-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.study-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.study-cat-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}
.study-cat-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.study-doc-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }

.study-doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.study-doc-row:hover { border-color: var(--accent); background: rgba(0, 113, 227, 0.04); }

.study-doc-title { flex: 1; font-size: 13px; font-weight: 500; }
.study-doc-path { font-size: 10px; font-family: var(--mono); color: var(--muted); }

.study-progress-select {
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #fff;
}

@media (max-width: 1024px) {
  .reader-shell { grid-template-columns: 1fr; }
  .reader-picker { max-height: 320px; }
  .reader-picker-filters { max-height: 52%; }
  .reader-picker-list { min-height: 100px; }
  .reader-content-actions { align-items: flex-start; }
  .reader-sequence-nav { width: 100%; order: 3; }
}

@media (max-width: 900px) {
  .reader-layout.reader-split { grid-template-columns: 1fr; }
  .reader-related { width: 100%; position: static; }
  .reader-body { flex-direction: column; }
}
