:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --radius: 10px;
}

body.theme-work {
  --primary: #ea580c;
  --primary-dark: #c2410c;
}

body.theme-work .search-input-wrapper:focus-within {
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

body.theme-work .rl-tag {
  background: rgba(234, 88, 12, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #131314;
  color: #e3e3e3;
  line-height: 1.6;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  display: none;
}

/* Home tabs */

.topnav button,
.topnav a.btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.topnav button:hover,
.topnav a.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.topnav a.btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.topnav a.work-mode-btn {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
  font-weight: 600;
}
.topnav a.work-mode-btn:hover {
  background: #c2410c;
  border-color: #c2410c;
  color: #fff;
}

/* Home tabs */

.header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.header-row .site-title {
  margin: 0;
  flex: 1 1 auto;
}

.site-title {
  font-size: 20px;
  font-weight: 700;
}

.topnav {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topnav:empty {
  display: none;
}

.menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 36px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.menu-btn:hover {
  border-color: var(--primary);
}

.menu-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
}

.menu-btn:hover .menu-bar {
  background: var(--primary);
}

.home-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  min-width: 140px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 8px;
}

.home-menu .btn {
  width: 100%;
  text-align: center;
}

/* ===== Top mode bar — "Work ▾" selector + profile (Gemini-style) ===== */
#mode-bar {
  display: none;
}
.mode-label {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
}
.mode-label:hover { background: var(--bg); }
.mode-caret {
  font-size: 20px;
  flex-shrink: 0;
}
.profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}
/* Global mode-bar profile is now redundant — profile lives in each sidebar */
#profile-icon {
  display: none;
}
.mode-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 14px;
  z-index: 90;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 6px;
}
.mode-menu[hidden] { display: none; }
.mode-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
.mode-item:hover { background: var(--bg); }
.mode-item.active { color: var(--primary); font-weight: 600; }

body.theme-work #mode-bar {
  background: transparent;
  border-bottom: none;
}
body.theme-work .mode-label {
  color: #e3e3e3;
}
body.theme-work .mode-label:hover { background: #282a2c; }
body.theme-work .mode-menu {
  background: #1e1f20;
  border-color: #2f3032;
}
body.theme-work .mode-item { color: #e3e3e3; }
body.theme-work .mode-item:hover { background: #282a2c; }
body.theme-work .mode-item.active { color: #a8c7fa; }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.tabs .tab {
  flex: 1;
  text-align: center;
  background: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  top: 1px;
  transition: all 0.2s ease;
}

.tabs .tab:hover {
  background: #cbd5e1;
  color: var(--text);
}

.tabs .tab.active {
  background: var(--card);
  color: var(--primary);
  border-color: var(--border);
  z-index: 2;
}

.tabs .tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 10px 10px 0 0;
}

.main-tabs {
  margin-bottom: 0;
}

.main-tabs .tab {
  border-bottom: 1px solid var(--border);
  border-radius: 10px;
  top: 0;
}

.inner-section {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  padding: 16px;
}

.inner-tabs {
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
}

.inner-tabs .tab {
  flex: 0 1 auto;
  min-width: 0;
  padding: 8px 14px;
  font-size: 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  top: 0;
}

.inner-tabs .tab:hover {
  background: #e2e8f0;
  color: var(--text);
}

.inner-tabs .tab.active {
  background: #e0f2fe;
  color: var(--primary);
}

.inner-tabs .tab.active::before {
  display: none;
}

.inner-tabs .tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.paper-group-empty {
  font-size: 13px;
  font-style: italic;
  margin-bottom: 8px;
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn + .btn {
  margin-left: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  color: var(--text);
}

/* Homepage */
.paper-list {
  display: grid;
  gap: 12px;
}

.paper-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.paper-card:hover {
  border-color: var(--primary);
}

.paper-card h2 {
  font-size: 17px;
  margin-bottom: 4px;
}

.paper-card .subject {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.rl-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: middle;
  margin-left: 6px;
  white-space: nowrap;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--ok);
  transition: width 0.3s;
}

.paper-card-wrap {
  display: flex;
  flex-direction: column;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.quiz-score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-score-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-score-big {
  font-size: 22px;
  font-weight: 700;
  color: var(--ok);
}

.quiz-score-meta {
  color: var(--muted);
  font-size: 14px;
}

/* Question view */
.q-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.q-text {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.q-intro {
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 400;
}

.q-intro p {
  margin-bottom: 2px;
}

.options {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  width: 100%;
  color: var(--text);
}

.option:hover:not(:disabled) {
  border-color: var(--primary);
}

.option .letter {
  font-weight: 700;
  flex: 0 0 auto;
}

.option:disabled {
  cursor: default;
}

.option.correct {
  background: var(--ok-bg);
  border-color: var(--ok);
}

.option.wrong {
  background: var(--err-bg);
  border-color: var(--err);
}

.option.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.multi-hint {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.options-tf {
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.options-tf .option {
  justify-content: center;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  padding: 18px 14px;
}

.options-tf .option .letter {
  display: none;
}

.source-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 16px;
}

.verify-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.verify-row .btn {
  font-size: 13px;
  padding: 6px 10px;
}

.slide-ref {
  display: inline-block;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
}

.year-ref {
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

.q-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 6px;
  user-select: all;
  cursor: text;
}

.q-key .q-id {
  font-weight: 600;
  color: var(--primary);
}

.explanation {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
}

.review-explanation {
  margin-top: 8px;
  color: var(--text);
}

/* Clickable document citations inside explanations (PNAP/APSEC codes). */
.cite-ref {
  color: var(--primary);
  background: rgba(26, 115, 232, 0.10);
  border-bottom: 1px dashed var(--primary);
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}
.cite-ref:hover {
  background: rgba(26, 115, 232, 0.20);
}
.cite-ref.cite-flash {
  background: rgba(26, 115, 232, 0.35);
  transition: background 0.2s ease;
}
.ai-file-link.cite-flash {
  background: rgba(26, 115, 232, 0.2);
  border-radius: 3px;
  transition: background 0.2s ease;
}

/* File links (full URLs / relative paths) produced by the citation linkifier
   outside the Work/AI chat pane. */
.ai-file-link {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
.ai-file-link:hover {
  text-decoration-style: solid;
}

.pdf-btn {
  margin-top: 10px;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}

.pdf-modal.open {
  display: block;
}

.pdf-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
}

.pdf-dialog {
  position: absolute;
  inset: 24px;
  margin: auto;
  max-width: 1000px;
  max-height: calc(100vh);
  background: var(--card);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-info {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  max-width: 50%;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.pdf-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.pdf-title {
  font-weight: 600;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-pageno {
  color: var(--muted);
  white-space: nowrap;
}

.pdf-navbar {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
}
.pdf-nav-page {
  font-size: 13px;
  padding: 0 4px;
  color: var(--text);
}
.pdf-nav-control .material-symbols-outlined {
  font-size: 22px;
}

.pdf-search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  line-height: 0;
}
.pdf-search-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
.pdf-search-toggle .material-symbols-outlined {
  font-size: 20px;
}

.pdf-corner-bottom-left {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 5;
}
#pdf-modal .pdf-search-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transition: background 0.15s ease, transform 0.1s ease;
}
#pdf-modal .pdf-search-circle:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: scale(1.05);
}
#pdf-modal .pdf-search-circle .material-symbols-outlined {
  font-size: 24px;
}

.pdf-zoom-bar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 5;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.pdf-zoom-bar.pdf-corner-bottom {
  bottom: 16px;
  right: 16px;
}
.pdf-zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  line-height: 0;
}
.pdf-zoom:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
.pdf-zoom .material-symbols-outlined {
  font-size: 20px;
}
.pdf-zoom:disabled {
  opacity: 0.4;
  cursor: default;
}

.pdf-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: #eef0f3;
}

.pdf-loading {
  margin: auto;
  color: var(--muted);
  font-size: 14px;
}

.pdf-load-error {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--text);
  padding: 24px;
}

.pdf-load-error-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.pdf-load-error-sub {
  font-family: monospace;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  word-break: break-all;
}

.pdf-load-error-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.pdf-retry-btn {
  margin: 0 auto;
}

#pdf-canvas {
  display: block;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  max-width: 100%;
  height: auto;
}

.md-content {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.7;
}

.md-page {
  background: #fff;
  color: #1f2933;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  margin: 0 auto 24px;
  padding: 48px 56px 40px;
  position: relative;
}

.md-page-body h2,
.md-page-body h3 {
  margin: 1.2em 0 0.5em;
}

.md-page-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.md-page-body p {
  margin: 0.6em 0;
}

.md-page-body p.md-i1 { margin-left: 1.5em; }
.md-page-body p.md-i2 { margin-left: 3em; }
.md-page-body p.md-i3 { margin-left: 4.5em; }
.md-page-body p.md-i4 { margin-left: 6em; }
.md-page-body p.md-i5 { margin-left: 7.5em; }

.md-page-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 14px;
}

.md-table th,
.md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

.md-table th {
  background: #f1f5f9;
}

.feedback {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 15px;
  display: none;
}

.feedback.correct {
  background: var(--ok-bg);
  border: 1px solid var(--ok);
  display: block;
}

.feedback.wrong {
  background: var(--err-bg);
  border: 1px solid var(--err);
  display: block;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.nav-row .btn {
  flex: 1 1 0;
}

.jump-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.jump-grid button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.jump-grid button.done {
  background: var(--ok-bg);
  border-color: var(--ok);
}

.jump-grid button.current {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Review */
.review-q {
  margin-bottom: 14px;
}

.review-q .q-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
}

.review-answer {
  margin-top: 8px;
  font-size: 14px;
}

.review-answer .correct-letter {
  color: var(--ok);
  font-weight: 700;
}

.review-answer .your-letter {
  font-weight: 700;
}

.review-answer .your-letter.right {
  color: var(--ok);
}

.review-answer .your-letter.wrong {
  color: var(--err);
}

.notes-box {
  width: 100%;
  min-height: 70px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}

.static-notes {
  margin-top: 10px;
  background: var(--bg);
  border-left: 3px solid var(--primary);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 14px;
  white-space: pre-wrap;
}

.empty-note {
  color: var(--muted);
  font-style: italic;
}

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

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.muted {
  color: var(--muted);
}

/* ---- Landing page ---- */
.landing {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f172a, #1e3a8a 55%, #2563eb);
  color: #fff;
  text-align: center;
  transition: opacity 0.4s ease;
}

.landing.hidden {
  opacity: 0;
  pointer-events: none;
}

.landing.mode-work {
  background: linear-gradient(160deg, #431407, #9a3412 55%, #ea580c);
}

.landing-inner {
  max-width: 480px;
  width: 100%;
}

.landing-kicker {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 10px;
}

.landing-title {
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 14px;
}

.landing-count {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 22px;
}

.landing-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 14px 8px;
  min-width: 84px;
}

.landing-num span:first-child {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.landing-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-top: 6px;
}

.landing-date {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 30px;
}

.landing-btn {
  font-size: 17px;
  font-weight: 700;
  padding: 14px 40px;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.landing-btn:hover {
  background: #e0e7ff;
}

.landing-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.landing-btn.study-btn {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: none;
}

.landing-btn.study-btn.selected {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.landing-btn.work-btn {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: none;
}

.landing-btn.work-btn.selected {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.landing-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.landing-btn.selected:hover {
  background: inherit;
}

.landing-go {
  display: block;
  margin: 14px auto 0;
  min-width: 180px;
  background: #fff;
  color: #1d4ed8;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.landing.mode-work .landing-go {
  color: #c2410c;
}

.landing-go:hover {
  background: #e0e7ff;
}

/* Auth gate */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.auth-card h1 {
  font-size: 20px;
  margin-bottom: 8px;
}

.auth-card .muted {
  margin-bottom: 20px;
}

/* Password gate */
.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: linear-gradient(160deg, #0f172a, #1e3a8a 55%, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.gate-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: #2563eb;
}
.gate-icon svg {
  width: 100%;
  height: 100%;
}
.gate-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #1f2933;
}
.gate-sub {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 20px;
}
.gate-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.gate-card input[type="password"]:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.gate-btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}
.gate-err {
  color: #dc2626;
  font-size: 13px;
  margin-bottom: 10px;
}

/* Google auth gate (replaces password gate) */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: #131314;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: #1e1f20;
  border: 1px solid #333537;
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-logo {
  font-size: 22px;
  font-weight: 700;
  color: #e3e3e3;
  margin-bottom: 6px;
}
.auth-sub {
  color: #9aa0a6;
  font-size: 14px;
  margin-bottom: 22px;
}
.google-signin-wrap {
  display: flex;
  justify-content: center;
}
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.google-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(60,64,67,0.3);
}
.google-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}
.auth-deny {
  color: #dc2626;
  font-size: 13px;
  margin-top: 16px;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .container {
    padding: 0 12px;
  }

  .site-header {
    padding: 10px 0;
    margin-bottom: 16px;
  }

  .site-title {
    font-size: 17px;
  }

  .topnav {
    gap: 6px;
  }

  .topnav button,
  .topnav a.btn {
    flex: 1 1 auto;
    min-height: 40px;
    font-size: 13px;
    padding: 6px 8px;
    text-align: center;
  }

  .tabs {
    flex-wrap: wrap;
    gap: 6px;
  }

  .tabs a,
  .tabs .tab,
  .tabs .btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
  }

  .inner-section {
    padding: 12px;
  }

  .inner-tabs .tab {
    min-height: 0;
    padding: 8px 12px;
  }

  .paper-card {
    padding: 14px;
  }

  .paper-card h2 {
    font-size: 15px;
  }

  .card-actions .card-action-btn,
  .card-actions .quiz-reset-btn {
    flex: 1;
    justify-content: center;
  }

  .q-text {
    font-size: 16px;
  }

  .options {
    gap: 10px;
  }

  .option {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 15px;
  }

  .jump-grid button {
    min-width: 40px;
    min-height: 40px;
  }

  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn + .btn {
    margin-left: 8px;
  }

  .verify-row .btn,
  .source-bar .btn {
    flex: 1 1 auto;
  }

  .pdf-dialog {
    inset: 0;
    max-height: 100vh;
  }

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.pdf-info {
    max-width: 42%;
    padding: 6px 12px;
  }

  .pdf-actions {
    gap: 4px;
    padding: 4px 6px;
  }

  .pdf-toolbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }

  .pdf-toolbar .pdf-pageno {
    order: -1;
    margin-right: auto;
  }

  .pdf-toolbar .pdf-nav,
  .pdf-toolbar #md-close {
    flex: 1 1 auto;
  }

  .pdf-toolbar .pdf-title {
    width: 100%;
    order: -2;
  }

  .pdf-canvas-wrap {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .md-page {
    padding: 24px 18px 32px;
  }

  .auth-card {
    margin: 16px;
    width: auto;
  }

  .landing-count {
    gap: 8px;
  }

  .landing-num {
    min-width: 68px;
    padding: 12px 6px;
  }

  .landing-num span:first-child {
    font-size: 30px;
  }

  .landing-title {
    font-size: 24px;
  }

  .weak-name {
    align-items: flex-start;
  }
}

/* ---- Flashcards (HKIA Conditions of Engagement) ---- */
.flash-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.flash-title {
  font-size: 18px;
  font-weight: 700;
}
.flash-paper-groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.flash-paper-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 10px;
}
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.deck-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s;
}
.deck-card:hover {
  border-color: var(--primary);
}
.deck-title {
  font-size: 16px;
  font-weight: 700;
}
.deck-blurb {
  font-size: 13px;
  margin-top: 2px;
}
.deck-count {
  font-size: 13px;
  margin-top: 6px;
}
.flash-backlink {
  margin-bottom: 12px;
}
.flash-backlink a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}
.flash-backlink a:hover {
  text-decoration: underline;
}
.flash-scene {
  perspective: 1400px;
  margin-bottom: 14px;
}
.flash-inner {
  position: relative;
  width: 100%;
  min-height: 300px;
  display: grid;
  transform-style: preserve-3d;
  transition: transform .5s;
  cursor: pointer;
}
.flash-inner.flipped {
  transform: rotateY(180deg);
}
.flash-face {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 28px;
  background: #1f2933;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: var(--radius);
}
.flash-back {
  transform: rotateY(180deg);
}
.flash-prompt {
  font-size: 13px;
  font-style: italic;
}
.flash-clause {
  font-size: 40px;
  font-weight: 800;
  color: var(--primary);
}
.flash-part {
  font-size: 14px;
  color: var(--muted);
}
.flash-title-big {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: #f1f5f9;
}
.flash-source-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.flash-source-block .kicker-source { margin-bottom: 2px; }
.flash-source {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
}
.flash-answer {
  font-size: 15px;
  line-height: 1.55;
  max-width: 620px;
  white-space: pre-line;
  text-align: left;
}
.flash-box-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  background: #334155;
  border-radius: 999px;
  padding: 2px 10px;
}
.box-dist {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.box-dist-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  min-width: 44px;
}
.box-dist-num {
  font-size: 16px;
  font-weight: 700;
}
.box-dist-label {
  font-size: 11px;
  color: var(--muted);
}
.flash-scenario {
  font-size: 15px;
  line-height: 1.5;
  max-width: 520px;
}
.flash-front-scenario {
  font-size: 17px;
}
.flash-grade {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.flash-browse {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 600px) {
  .flash-browse { grid-template-columns: 1fr; }
}
.flash-browse-item {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 120px;
  width: 100%;
  font: inherit;
  text-align: left;
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}
.flash-browse-item:hover {
  border-color: var(--primary);
  background: var(--bg);
}
.flash-tick {
  position: absolute;
  top: 8px;
  right: 10px;
  color: #4ade80;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.flash-browse-q {
  padding-right: 20px;
  font-size: 16px;
  line-height: 1.45;
}
.flash-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}
.flash-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #1f2933;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: 24px 28px;
  text-align: left;
}
.flash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.flash-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #9aa0a6);
}
.flash-kicker.kicker-answer {
  margin-top: 2px;
  margin-bottom: 2px;
}
.flash-question {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.45;
  color: #f1f5f9;
}
.flash-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash-card-divider {
  height: 1px;
  background: #334155;
}
.flash-card-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.flash-ref {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}
/* Internal card id chip — visible, copyable reference. */
.flash-card-id {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted, #9aa0a6);
  background: var(--surface-2, #22262b);
  border: 1px solid var(--border, #2f3439);
  border-radius: 999px;
  padding: 1px 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.flash-card-id:hover { color: var(--primary); border-color: var(--primary); }
.flash-id-row { margin: 6px 0 10px; }
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover {
  background: var(--bg);
}
.flash-btn-remember,
.flash-btn-forgot {
  min-width: 150px;
}
.flash-btn-remember {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.flash-btn-remember:hover {
  background: #15803d;
  border-color: #15803d;
}
.flash-btn-forgot {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.flash-btn-forgot:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* Global search */
.search-wrap {
  position: relative;
  margin-top: 10px;
}
.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px 4px 12px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: var(--card);
}
.search-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 16px;
  color: var(--text);
}
.search-input:focus {
  outline: none;
  border: none;
  background: transparent;
}
.search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.search-btn:hover {
  background: var(--primary-dark);
}
.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  z-index: 60;
  font-size: 14px;
}
.search-status {
  padding: 8px 14px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.search-empty {
  padding: 14px;
  color: var(--muted);
}
.search-corrected {
  padding: 8px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
}
.w-corrected-note {
  margin: 0 0 8px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-soft, rgba(127, 127, 127, 0.08));
  border-radius: 6px;
}
.search-corrected-text {
  color: var(--muted);
}
.search-corrected-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-decoration: underline;
}
.search-corrected-link:hover {
  text-decoration: none;
}
.search-group {
  padding: 6px 0;
}
.search-group + .search-group {
  border-top: 1px solid var(--border);
}
.search-group-title {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.search-result {
  padding: 8px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.search-result:hover {
  background: var(--bg);
  border-left-color: var(--primary);
}
.search-result-title {
  font-weight: 600;
  line-height: 1.4;
}
.search-result-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}
.search-snippet {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  line-height: 1.45;
  word-break: break-word;
}
.search-panel mark {
  background: #fde68a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.search-target {
  box-shadow: 0 0 0 3px var(--primary);
}

/* Per-document search (PDF / markdown viewers) */
.doc-search {
  position: relative;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#pdf-modal .doc-search {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: min(420px, calc(100% - 100px));
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.doc-search-input {
  width: 100%;
}
.doc-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 5;
  font-size: 13px;
}
.doc-search-status {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}
.doc-search-hit {
  padding: 8px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.doc-search-hit:hover {
  background: var(--bg);
  border-left-color: var(--primary);
}
.doc-search-hit-title {
  font-weight: 700;
  font-size: 13px;
}
.doc-search-hit-snippet {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.45;
  word-break: break-word;
}
.doc-search-hit mark {
  background: #fde68a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* PDF text-layer highlight */
.pdf-page-wrap {
  position: relative;
  width: fit-content;
  margin: 0 auto;
}
.pdf-textlayer {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
.pdf-tl {
  position: absolute;
  color: transparent;
  white-space: pre;
}
.pdf-tl-hl {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(253, 230, 138, 0.6);
  border-radius: 2px;
  pointer-events: none;
}

/* In-document search highlight (markdown) */
.md-content mark.search-hit {
  background: #fde68a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* Cmd+F-style find bar */
.doc-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-search-input {
  flex: 1;
}
.doc-search-count {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 40px;
  text-align: center;
}
.doc-search-nav {
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.2;
}

/* Current match distinct from others */
.pdf-tl.current .pdf-tl-hl {
  background: rgba(249, 115, 22, 0.75);
  outline: 2px solid rgba(249, 115, 22, 0.9);
}
.md-content mark.search-current {
  background: #fb923c;
  outline: 2px solid #f97316;
}

/* PNAP compact list — one card, divider rows */
.pnap-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.pnap-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.pnap-row:last-child {
  border-bottom: none;
}
.pnap-row:hover {
  background: rgba(37, 99, 235, 0.04);
}
.pnap-badge {
  flex-shrink: 0;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
  font-family: monospace;
}
.pnap-title {
  flex: 1;
  font-size: 14px;
  line-height: 1.3;
  min-width: 0;
}
.pnap-title.resource-btn:hover {
  color: var(--primary);
  text-decoration: underline;
}
.paper-card h2.resource-btn:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ===== Work Mode — dark Gemini-style layout (from reference) ===== */
/* Scoped to body.theme-work so Study mode keeps light theme */
/* Hide Study header in Work; #app becomes full viewport */
body.theme-work {
  background-color: #131314;
  color: #e3e3e3;
  overflow: hidden;
}
body.theme-work .site-header {
  display: none;
}
body.theme-work #app.container {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh);
  height: calc(100dvh);
  overflow: hidden;
}
body.theme-work #app .inner-section,
body.theme-work #app .paper-list,
body.theme-work #app .tabs {
  /* prevent leak if Study content briefly flashes */
}

/* Layout */
body.theme-work #app-layout {
  display: flex;
  width: 100vw;
  height: calc(100vh);
  height: calc(100dvh);
  position: relative;
  background-color: #131314;
  color: #e3e3e3;
  overflow: hidden;
}

/* ---- Database Mode — same dark shell as Study, with sidebar ---- */
body.theme-database .site-header { display: none; }
body.theme-database #app.container {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh);
  height: calc(100dvh);
  overflow: hidden;
}
body.theme-database #app-layout {
  display: flex;
  width: 100vw;
  height: calc(100vh);
  height: calc(100dvh);
  position: relative;
  background-color: #131314;
  color: #e3e3e3;
  overflow: hidden;
}
body.theme-database #mode-bar {
  background: transparent;
  border-bottom: none;
}
body.theme-database .mode-label { color: #e3e3e3; }
body.theme-database .mode-label:hover { background: #282a2c; }
body.theme-database .mode-menu {
  background: #1e1f20;
  border-color: #2f3032;
}
body.theme-database .mode-item { color: #e3e3e3; }
body.theme-database .mode-item:hover { background: #282a2c; }
body.theme-database .mode-item.active { color: #a8c7fa; }
.s-mode-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #1a1a1c;
  color: #e3e3e3;
  border: 1px solid #333537;
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  font-family: 'Google Sans', sans-serif;
  width: 100%;
  justify-content: space-between;
}
.s-mode-btn-content {
  display: flex;
  align-items: center;
  gap: 10px;
}
.s-dropdown-arrow {
  font-size: 20px;
}
.s-mode-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 90;
  background: #1e1f20;
  border: 1px solid #333537;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.s-mode-menu[hidden] { display: none; }
.s-mode-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #c4c7c5;
  font-family: 'Google Sans', sans-serif;
}
.s-mode-item:hover { background: #28292a; color: #e3e3e3; }
.s-mode-item.active { color: #a8c7fa; }
body.theme-database .s-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
body.theme-database .s-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 20px;
  color: #c4c7c5;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
body.theme-database .s-nav-item:hover,
body.theme-database .s-nav-item.active {
  background-color: #28292a;
  color: #e3e3e3;
}
.s-sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.s-profile {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.s-profile:hover {
  opacity: 0.9;
}
body.theme-database .s-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 88px 40px 48px 40px;
  background-color: #131314;
  font-family: 'Google Sans', sans-serif;
}
body.theme-database .s-main .db-topbar {
  margin-bottom: 24px;
}
body.theme-database .s-main .db-page-title {
  font-size: 28px;
  font-weight: 500;
  color: #e3e3e3;
}

/* Material Symbols icon font (Gemini-style) */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* Left sidebar — off-canvas drawer (Gemini-style) at every size.
   Hidden by default; slides in from the left when the drawer is open.
   Collapsed = closed (translateX off-canvas). Shared by Work/Study/Database. */
.w-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background-color: #1e1f20;
  border-right: 1px solid #2f3032;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 500;
}
.w-sidebar:not(.collapsed) {
  transform: translateX(0);
}
.w-sidebar .w-nav-text {
  display: inline;
}
.w-sidebar .s-mode-btn,
.w-sidebar .s-mode-menu {
  display: none;
}
.w-sidebar-top {
  position: relative;
}
.w-menu-btn {
  background: none;
  border: none;
  color: #c4c7c5;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}
.w-menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.w-menu-btn .material-symbols-outlined {
  font-size: 24px;
}
.w-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  margin: 0;
}
.w-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 20px;
  color: #c4c7c5;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.w-nav-item:hover {
  background-color: #28292a;
  color: #e3e3e3;
}
.w-nav-item .material-symbols-outlined {
  font-size: 20px;
}
.w-sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.theme-work .w-profile {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
 body.theme-work .w-profile:hover {
  opacity: 0.9;
}
body.theme-work .w-profile.is-google {
  background: #fff;
  padding: 0;
}
body.theme-work .w-profile.is-google .google-g {
  display: block;
}
body.theme-work .w-profile.is-user {
  background: #fff;
  padding: 0;
  overflow: hidden;
}
body.theme-work .w-profile.is-user .w-profile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Placeholder toast */
.w-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1e1f20;
  color: #e3e3e3;
  border: 1px solid #3c4043;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 4000;
  max-width: 90vw;
}
.w-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Main workspace */
body.theme-work .w-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-width: 0;
  position: relative;
  overflow: hidden;
  padding-bottom: 32px;
}
body.theme-work #chat-container.w-chat {
  flex: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 12px 20px;
  box-sizing: border-box;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Hero landing state */
body.theme-work .w-hero {
  width: 100%;
  max-width: 900px;
  margin: auto 0;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
body.theme-work .w-hero.chat-active {
  margin: 0;
}
body.theme-work .w-hero.chat-active .w-input-wrap {
  margin-top: 16px;
}
body.theme-work .w-hero .w-input-wrap {
  padding: 0;
}
body.theme-work .w-greeting {
  font-size: 56px;
  font-weight: 500;
  letter-spacing: -1px;
}
body.theme-work .w-greeting .gradient-text {
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body.theme-work .w-sub-text {
  color: #8e918f;
}
body.theme-work .w-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
}
@media (min-width: 600px) {
  body.theme-work .w-cards-grid.grid-shortcuts {
    grid-template-columns: repeat(2, 1fr);
  }
}
body.theme-work .w-signin-banner {
  margin-bottom: 4px;
  display: flex;
  justify-content: center;
}
body.theme-work .w-signin-banner .google-btn {
  width: auto;
  min-width: 280px;
}
body.theme-work .w-card.locked {
  opacity: 0.55;
}
body.theme-work .input-container .locked,
body.theme-work textarea.locked {
  color: #9aa0a6;
}
body.theme-work .w-card {
  background-color: #1e1f20;
  border-radius: 16px;
  padding: 14px 16px;
  height: 176px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
body.theme-work .w-card:hover {
  background-color: #28292a;
}
body.theme-work .w-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
body.theme-work .w-card-title {
  flex: 1 1 auto;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  color: #c4c7c5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
body.theme-work .w-card-download {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #2b2c2e;
  color: #c4c7c5;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}
body.theme-work .w-card-download:hover {
  background: #343638;
  color: #fff;
}
body.theme-work .w-card-download .material-symbols-outlined {
  font-size: 18px;
}
body.theme-work .w-card-icon {
  align-self: flex-end;
  margin-top: auto;
  background: #131314;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c4c7c5;
}
body.theme-work .w-card-icon .material-symbols-outlined {
  font-size: 20px;
}
body.theme-work .w-card-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 8px;
  width: fit-content;
  background: rgba(168, 199, 250, 0.18);
  color: #a8c7fa;
}
body.theme-work .w-card-tag.badge-pnap { background: rgba(168, 199, 250, 0.18); color: #a8c7fa; }
body.theme-work .w-card-tag.badge-code { background: rgba(129, 201, 149, 0.18); color: #81c995; }
body.theme-work .w-card-tag.badge-cap { background: rgba(242, 139, 130, 0.18); color: #f28b82; }
body.theme-work .w-card-page {
  margin-top: 8px;
  font-size: 12px;
  color: #9aa0a6;
}
body.theme-work .w-card-empty {
  cursor: default;
  opacity: 0.75;
  justify-content: space-between;
}
body.theme-work .w-card-empty:hover {
  background-color: #1e1f20;
}
body.theme-work .message {
  line-height: 1.6;
  font-size: 15px;
  animation: workFadeIn 0.3s ease;
}
body.theme-work .user-message {
  background-color: #1e1f20;
  padding: 12px 20px;
  border-radius: 20px;
  border-bottom-right-radius: 4px;
  width: fit-content;
  max-width: 80%;
  align-self: flex-end;
  color: #e3e3e3;
}
body.theme-work .ai-message {
  background-color: transparent;
  padding: 8px 0;
  width: 100%;
  align-self: flex-start;
  color: #e3e3e3;
}
body.theme-work .ai-message-header {
  font-weight: 600;
  color: #a8c7fa;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
body.theme-work .ai-message-header.general { color: #a8c7fa; }
body.theme-work .ai-message-header.definition { color: #81c995; }
body.theme-work .ai-message-header .ai-conf-in-header {
  font-size: 11px;
  font-weight: 600;
  color: #7fd88f;
  background: rgba(127, 216, 143, 0.10);
  border: 1px solid rgba(127, 216, 143, 0.25);
  border-radius: 8px;
  padding: 1px 7px;
}
body.theme-work .typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #a8c7fa;
  border-radius: 50%;
  margin-right: 3px;
  animation: workTyping 1.4s infinite ease-in-out both;
}
body.theme-work .typing-dots span:nth-child(1) { animation-delay: -0.32s; }
body.theme-work .typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes workTyping {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
@keyframes workFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bottom input box (Gemini-style) */
body.theme-work .w-input-wrap {
  width: 100%;
  max-width: 900px;
  padding: 0 20px 12px 20px;
  box-sizing: border-box;
}
body.theme-work .input-container {
  width: 100%;
  background-color: #1e1f20;
  border-radius: 28px;
  padding: 12px 16px 12px 22px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  position: relative;
}

body.theme-work #search-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #e3e3e3;
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  resize: none;
  height: 24px;
  max-height: 150px;
  overflow-y: auto;
}
body.theme-work #search-input::placeholder {
  color: #9aa0a6;
}
body.theme-work #tools-search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #e3e3e3;
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  height: 24px;
}
body.theme-work #tools-search-input::placeholder {
  color: #9aa0a6;
}
/* Tools listing — let the page scroll when cards overflow the viewport. */
body.theme-work .w-main.tools-listing {
  overflow-y: auto;
}
body.theme-work .input-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
body.theme-work .action-pills {
  display: flex;
  gap: 8px;
}
body.theme-work .pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: #c4c7c5;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}
body.theme-work .pill-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
body.theme-work .send-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mode chip (Open / Relevance) */
body.theme-work .mode-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(168, 199, 250, 0.1);
  border: 1px solid rgba(168, 199, 250, 0.2);
  color: #a8c7fa;
  border-radius: 16px;
  padding: 4px 10px 4px 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}
body.theme-work .mode-chip:hover {
  background: rgba(168, 199, 250, 0.18);
  border-color: rgba(168, 199, 250, 0.35);
}
body.theme-work .mode-chip:active {
  background: rgba(168, 199, 250, 0.25);
}
body.theme-work .mode-chip.open {
  background: rgba(168, 199, 250, 0.12);
  border-color: rgba(168, 199, 250, 0.25);
  color: #a8c7fa;
}
body.theme-work .mode-chip.open:hover {
  background: rgba(168, 199, 250, 0.2);
}
body.theme-work .mode-chip.open .mode-chip-hint {
  color: rgba(168, 199, 250, 0.5);
  border-color: rgba(168, 199, 250, 0.25);
}
body.theme-work .mode-chip.definition {
  background: rgba(129, 201, 149, 0.12);
  border-color: rgba(129, 201, 149, 0.3);
  color: #81c995;
}
body.theme-work .mode-chip.definition:hover {
  background: rgba(129, 201, 149, 0.2);
}
body.theme-work .mode-chip.definition .mode-chip-hint {
  color: rgba(129, 201, 149, 0.5);
  border-color: rgba(129, 201, 149, 0.3);
}
body.theme-work .mode-chip-icon {
  font-size: 16px;
  line-height: 1;
}
body.theme-work .mode-chip-label {
  font-weight: 500;
}
body.theme-work .mode-chip-hint {
  font-size: 10px;
  color: rgba(168, 199, 250, 0.45);
  border: 1px solid rgba(168, 199, 250, 0.2);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 2px;
  line-height: 16px;
  letter-spacing: 0.02em;
}

/* Definition mode — live results list (fills the hero space) */
@keyframes defStaggerIn {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}
.def-stagger-in {
  animation: defStaggerIn 0.35s ease both;
}
body.theme-work .w-cards-grid.def-results-wrap {
  grid-template-columns: 1fr;
  align-content: start;
}
.def-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.def-results .def-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.def-results .def-result-item:hover,
.def-results .def-result-item.active {
  background: rgba(129, 201, 149, 0.12);
  border-color: rgba(129, 201, 149, 0.25);
}
.def-results .def-result-item.top {
  background: rgba(129, 201, 149, 0.16);
  border-color: rgba(129, 201, 149, 0.4);
}
.def-results .def-result-item.top .def-result-term {
  color: #81c995;
}
.def-results .def-result-term {
  color: #e3e3e3;
  font-size: 17px;
  font-weight: 500;
}
.def-results .def-result-meta {
  color: rgba(160, 165, 170, 0.85);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Definition mode — term popup */
.def-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.def-modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: min(80vh, 720px);
  overflow-y: auto;
  background: #1e1f20;
  border: 1px solid rgba(129, 201, 149, 0.25);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  padding: 28px 28px 24px;
  box-sizing: border-box;
}
.def-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #9aa0a6;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
}
.def-modal-close:hover { color: #e3e3e3; background: rgba(255, 255, 255, 0.06); }
.def-modal-doc {
  color: rgba(129, 201, 149, 0.7);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  padding-right: 32px;
}
.def-modal-term {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 500;
  color: #81c995;
}
.def-modal-def {
  margin: 0 0 18px;
  color: #dadce0;
  font-size: 15px;
  line-height: 1.65;
}
.def-modal-loc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #81c995;
  background: rgba(129, 201, 149, 0.1);
  border: 1px solid rgba(129, 201, 149, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.def-modal-loc:hover {
  background: rgba(129, 201, 149, 0.18);
}
.def-modal-loc-icon {
  font-size: 15px !important;
}
.sources-modal {
  max-width: 600px;
}
.sources-intro {
  margin: 0 0 16px;
  color: #dadce0;
  font-size: 14px;
  line-height: 1.6;
}
.sources-group {
  margin-bottom: 6px;
}
.sources-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: #e3e3e3;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 8px;
  border-radius: 10px;
  text-align: left;
}
.sources-group-head:hover {
  background: rgba(255, 255, 255, 0.05);
}
.sources-group-caret {
  font-size: 20px;
  color: #9aa0a6;
  transition: transform 0.2s ease;
}
.sources-group-head.open .sources-group-caret {
  transform: rotate(180deg);
}
.sources-group-title {
  color: rgba(129, 201, 149, 0.85);
}
.sources-group-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 400;
  color: #9aa0a6;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 2px 8px;
}
.sources-list {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0 0 0 8px;
  border-left: 2px solid rgba(129, 201, 149, 0.2);
  display: none;
}
.sources-list.open {
  display: block;
}
.sources-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  color: #dadce0;
  text-decoration: none;
  font-size: 14px;
}
.sources-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #e3e3e3;
}
.sources-item-code {
  color: #a8c7fa;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 84px;
}
.sources-item-name {
  line-height: 1.4;
}
body.theme-work .icon-btn {
  background: none;
  border: none;
  color: #c4c7c5;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.theme-work .icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e3e3e3;
}
body.theme-work .icon-btn .material-symbols-outlined {
  font-size: 22px;
}
body.theme-work .w-disclaimer {
  font-size: 12px;
  color: #8e918f;
  text-align: center;
  margin-top: 8px;
}

body.theme-work .ai-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}
body.theme-work .ai-body .ai-file-link {
  color: #8ab4f8;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
  transition: color 0.15s;
}
body.theme-work .ai-body .ai-file-link:hover {
  color: #aecbfa;
  text-decoration-style: solid;
}
body.theme-work .ai-source-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.theme-work .ai-source-block .src-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.theme-work .ai-source-block .src-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  color: #8ab4f8;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}
body.theme-work .ai-source-block .src-item:hover {
  color: #aecbfa;
}
body.theme-work .ai-source-block .src-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  color: #8ab4f8;
  background: rgba(138, 180, 248, 0.12);
  border: 1px solid rgba(138, 180, 248, 0.35);
  flex: none;
}
body.theme-work .ai-source-block .src-conf {
  color: #7fd88f;
  background: rgba(127, 216, 143, 0.12);
  border-radius: 8px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
}
body.theme-work .ai-source-block .src-page {
  color: #9aa0a6;
  font-size: 12px;
}
/* Inline circled citation dots (dark theme) */
body.theme-work .ai-body .src-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin: 0 2px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: #8ab4f8;
  background: rgba(138, 180, 248, 0.12);
  border: 1px solid rgba(138, 180, 248, 0.35);
  vertical-align: middle;
  text-decoration: none;
  position: relative;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
body.theme-work .ai-body .src-dot:hover {
  background: rgba(138, 180, 248, 0.28);
  color: #aecbfa;
  transform: scale(1.05);
}
body.theme-work .ai-body .src-dot::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #202124;
  color: #e3e3e3;
  border: 1px solid #3c4043;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
body.theme-work .ai-body .src-dot::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #3c4043;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 30;
}
body.theme-work .ai-body .src-dot:hover::after,
body.theme-work .ai-body .src-dot:hover::before {
  opacity: 1;
  visibility: visible;
}
body.theme-work .ai-error .ai-body {
  color: #f6c9b8;
}
body.theme-work .ai-error-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #9aa0a6;
  border-left: 2px solid #5f6368;
  padding-left: 8px;
}
.ai-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1e1f20;
  color: #e3e3e3;
  border: 1px solid #3c4043;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 4000;
  max-width: 90vw;
}
.ai-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive: work-mode typography and spacing on narrow screens.
   (The sidebar is a drawer at every size now — see the top bar block.) */
@media (max-width: 760px) {
  body.theme-work .w-hero .w-greeting {
    font-size: 40px;
  }
  body.theme-work .w-input-wrap {
    padding: 0 12px 12px 12px;
  }
}

/* ============================================================
   App-shell top bar — Gemini-style (no permanent sidebar)
   Mirrors the Gemini app: [menu] [mode ▾] across the top at
   every screen size; the sidebar becomes an off-canvas drawer
   opened by the menu button. Shared by Work/Study/Database.
   ============================================================ */
.w-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  box-sizing: border-box;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  /* No bar background/border — floating icon row like the Gemini app. */
  background: transparent;
}
.w-top-menu-btn,
.w-top-newchat {
  background: none;
  border: 1px solid #3c4043;
  color: #e3e3e3;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.w-top-menu-btn:hover,
.w-top-newchat:hover { background-color: rgba(255,255,255,0.08); }
.w-top-newchat { margin-left: auto; }

/* Mode selector: plain label + chevron, no pill/border. */
.w-topbar .s-mode-btn {
  background: none;
  border: none;
  color: #e3e3e3;
  font-family: 'Google Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  padding: 4px 8px;
  width: auto;
  height: auto;
}
.w-topbar .s-mode-btn:hover { background: rgba(255,255,255,0.08); }
.w-topbar .s-mode-menu {
  position: absolute;
  top: 52px;
  left: 60px;
  right: auto;
  min-width: 200px;
  background: #1e1f20;
  border: 1px solid #333537;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  padding: 6px;
  z-index: 350;
}

.w-drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 400; }

/* Hero greeting centers in remaining space like the Gemini app */
body.theme-work .w-hero {
  padding: 0 20px;
  gap: 28px;
  min-height: 0;
}
body.theme-work .w-greeting {
  text-align: center;
}
body.theme-work .w-sub-text { text-align: center; }

/* Leave room for the fixed top bar, so content isn't hidden behind it. */
body.theme-work .w-main { padding-top: 64px; }

/* ===== Database view (Work mode resource browser) ===== */
.db-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Google Sans', sans-serif;
}
.db-topbar {
  margin-bottom: 24px;
}
.db-page-title {
  font-size: 28px;
  font-weight: 500;
  color: #e3e3e3;
}
/* ---- Gemini pill search bar ---- */
.db-search {
  width: 100%;
  background: #1e1f20;
  border: 1px solid #333537;
  border-radius: 28px;
  padding: 8px 12px 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.db-search-icon {
  color: #8e918f;
  font-size: 20px;
  flex-shrink: 0;
}
.db-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e3e3e3;
  font-family: 'Google Sans', sans-serif;
  font-size: 15px;
}
.db-search-input::placeholder {
  color: #8e918f;
}
.db-search-btn {
  background: #004a77;
  color: #c2e7ff;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-family: 'Google Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.db-search-btn:hover {
  background: #005c93;
}
/* ---- Category filter pills ---- */
.db-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 2px;
  margin-bottom: 24px;
  border-bottom: 1px solid #333537;
  scrollbar-width: thin;
  scrollbar-color: #333537 transparent;
}
.db-tabs::-webkit-scrollbar {
  height: 4px;
}
.db-tabs::-webkit-scrollbar-thumb {
  background: #333537;
  border-radius: 4px;
}
.db-tab {
  background: rgba(255,255,255,0.05);
  border: 1px solid #333537;
  color: #c4c7c5;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-family: 'Google Sans', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.db-tab:hover:not(.active) {
  background: #28292a;
  color: #e3e3e3;
}
.db-tab.active {
  background: #004a77;
  color: #c2e7ff;
  border-color: #004a77;
  font-weight: 500;
}
.db-count {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
}
.db-tab.active .db-count {
  background: rgba(194,231,255,0.2);
  color: #c2e7ff;
}
/* ---- Card grid ---- */
.db-grid {
  flex: 1;
  min-height: 0;
  padding-bottom: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-content: start;
}
.db-card {
  background: #1e1f20;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
  gap: 6px;
  transition: all 0.2s ease;
}
.db-card:hover {
  background: #28292a;
  border-color: #333537;
}
.db-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.db-doc-num {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #a8c7fa;
  background: rgba(168,199,250,0.1);
  border: 1px solid rgba(168,199,250,0.3);
  border-radius: 12px;
  padding: 3px 10px;
  white-space: nowrap;
}
.db-card-title {
  font-size: 15px;
  font-weight: 500;
  color: #e3e3e3;
  line-height: 1.4;
}
.db-card-meta {
  font-size: 13px;
  color: #8e918f;
  line-height: 1.4;
}
.db-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.db-view-btn,
.db-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: 'Google Sans', sans-serif;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.db-view-btn {
  background: #004a77;
  color: #c2e7ff;
  border: none;
}
.db-view-btn:hover {
  background: #005c93;
}
.db-dl-btn {
  background: rgba(255,255,255,0.05);
  color: #c4c7c5;
  border: 1px solid #333537;
}
.db-dl-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #e3e3e3;
}
.db-view-btn svg,
.db-dl-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.db-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #8e918f;
  padding: 40px 20px;
  font-size: 14px;
}

@media (max-width: 640px) {
  .db-grid {
    grid-template-columns: 1fr;
    padding: 0;
  }
}

/* ===== Hamburger toggle (study mode) ===== */
.rail-toggle {
  display: none;
}
body:not(.theme-work) .rail-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  position: fixed;
  top: 14px;
  left: 14px;
  width: 42px;
  height: 38px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  z-index: 60;
}
body:not(.theme-work) .rail-toggle .menu-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
}
body.theme-work .rail-toggle { display: none; }

.rail-backdrop {
  display: none;
}
body:not(.theme-work) .rail-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 45;
}

/* ===== Study-mode left rail (slide-in drawer) ===== */
.study-rail { display: none; }

body:not(.theme-work) .study-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 64px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding-top: 64px;
  box-sizing: border-box;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
body:not(.theme-work) .study-rail.open {
  transform: translateX(0);
}
body.theme-work .study-rail { display: none; }

.rail-btn {
  width: 52px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0;
  border-radius: 10px;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.rail-btn:hover {
  background: var(--bg);
  color: var(--accent);
}
.rail-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  flex-shrink: 0;
}
.rail-label {
  font-size: 9px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

@media (max-width: 560px) {
  body:not(.theme-work) .study-rail { width: 52px; padding-top: 60px; }
  .rail-btn { width: 44px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .rail-label { font-size: 8px; }
}

/* ===== Database drawer overlay (shared) ===== */
.db-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
}
.db-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.db-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(560px, 94vw);
  background: #131314;
  color: #e3e3e3;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
  animation: db-slide-in 0.22s ease;
}
@keyframes db-slide-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.db-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #333537;
  flex-shrink: 0;
}
.db-drawer-header h3 {
  margin: 0;
  font-size: 16px;
  color: #e3e3e3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.db-drawer .db-view {
  flex: 1;
  min-height: 0;
  height: auto;
}
.db-drawer .db-grid {
  flex: 1;
  overflow-y: auto;
  align-content: start;
}
.db-drawer .db-tabs {
  background: #131314;
  padding: 12px 16px;
}

/* ============================================================
   Study Mode — dark Gemini-style layout (mirrors Work Mode)
   Scoped to body.theme-study. Global .site-header is hidden
   (the shell provides its own top bar + search + sidebar); the
   global #mode-bar dropdown stays for Work/Study/Database switching.
   ============================================================ */
body.theme-study {
  background-color: #131314;
  color: #e3e3e3;
  overflow: hidden;
}
body.theme-study .site-header {
  display: none;
}
body.theme-study #app.container {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh);
  height: calc(100dvh);
  overflow: hidden;
}
body.theme-study #app-layout {
  display: flex;
  width: 100vw;
  height: calc(100vh);
  height: calc(100dvh);
  position: relative;
  background-color: #131314;
  color: #e3e3e3;
  overflow: hidden;
}

/* Keep the global mode-bar (dropdown only) in Study Mode — no grey bar */
body.theme-study #mode-bar {
  background: transparent;
  border-bottom: none;
}
body.theme-study .mode-label {
  color: #e3e3e3;
}
body.theme-study .mode-label:hover {
  background: #282a2c;
}
body.theme-study .mode-menu {
  background: #1e1f20;
  border-color: #2f3032;
}
body.theme-study .mode-item {
  color: #e3e3e3;
}
body.theme-study .mode-item:hover {
  background: #282a2c;
}
body.theme-study .mode-item.active {
  color: #a8c7fa;
}

/* ---- Study sidebar (follows Work Mode .w-sidebar style) ---- */
body.theme-study .s-mode-btn {
  font-family: 'Google Sans', sans-serif;
}
body.theme-study .s-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
body.theme-study .s-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 20px;
  color: #c4c7c5;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
body.theme-study .s-nav-item:hover,
body.theme-study .s-nav-item.active {
  background-color: #28292a;
  color: #e3e3e3;
}

/* ---- Study main content ---- */
body.theme-study .s-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 88px 40px 24px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}
body.theme-study .top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-shrink: 0;
}
body.theme-study .page-title {
  font-size: 28px;
  font-weight: 500;
  color: #e3e3e3;
}
body.theme-study .profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 14px;
  cursor: default;
}

/* ---- Gemini pill-style search bar ---- */
body.theme-study .search-container {
  width: 100%;
  background-color: #1e1f20;
  border-radius: 28px;
  padding: 8px 12px 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #333537;
  margin-bottom: 24px;
  box-sizing: border-box;
  flex-shrink: 0;
}
body.theme-study .search-container .search-icon {
  color: #8e918f;
}
body.theme-study .search-container input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e3e3e3;
  font-family: var(--font-family, 'Google Sans', sans-serif);
  font-size: 15px;
}
body.theme-study .search-btn {
  background-color: #004a77;
  color: #c2e7ff;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-family: var(--font-family, 'Google Sans', sans-serif);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
body.theme-study .search-btn:hover {
  background-color: #005c93;
}

/* ---- Primary navigation tabs (pill row) ---- */
body.theme-study .primary-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
body.theme-study .tab-pill {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid #333537;
  color: #c4c7c5;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--font-family, 'Google Sans', sans-serif);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}
body.theme-study .tab-pill.active {
  background-color: #004a77;
  color: #c2e7ff;
  border-color: #004a77;
  font-weight: 500;
}
body.theme-study .tab-pill:hover:not(.active) {
  background-color: #28292a;
  color: #e3e3e3;
}

/* ---- Sub-tabs (paper filters) as underline pills ---- */
body.theme-study .inner-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid #333537;
  flex-shrink: 0;
}
body.theme-study .inner-tabs .tab {
  background: transparent;
  border: none;
  color: #8e918f;
  padding: 8px 16px;
  font-size: 14px;
  font-family: var(--font-family, 'Google Sans', sans-serif);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
}
body.theme-study .inner-tabs .tab.active {
  color: #a8c7fa;
  font-weight: 500;
}
body.theme-study .inner-tabs .tab.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #a8c7fa;
  border-radius: 2px;
}
body.theme-study .inner-tabs .tab:hover:not(.active) {
  color: #e3e3e3;
}

/* ---- Resource / paper card grid (matches new Gemini UI) ---- */
body.theme-study .paper-list,
body.theme-study .resource-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.theme-study .paper-card,
body.theme-study .resource-card {
  background-color: #1e1f20;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
  border: 1px solid transparent;
  gap: 16px;
}
body.theme-study .paper-card:hover,
body.theme-study .resource-card:hover {
  background-color: #28292a;
  border-color: #333537;
}
body.theme-study .paper-card h2,
body.theme-study .card-title {
  font-size: 16px;
  font-weight: 500;
  color: #e3e3e3;
  margin: 0;
}
body.theme-study .paper-card .subject,
body.theme-study .card-subtitle {
  font-size: 13px;
  color: #8e918f;
  margin-top: 6px;
}
body.theme-study .card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
body.theme-study .card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
body.theme-study .rl-tag,
body.theme-study .badge {
  background-color: rgba(168, 199, 250, 0.1);
  color: #a8c7fa;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(168, 199, 250, 0.3);
  white-space: nowrap;
}
body.theme-study .paper-card .btn,
body.theme-study .card-action-btn {
  background-color: #004a77;
  color: #c2e7ff;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-family: var(--font-family, 'Google Sans', sans-serif);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}
body.theme-study .paper-card .btn:hover,
body.theme-study .card-action-btn:hover {
  background-color: #005c93;
}
/* progress bar inside practice cards */
body.theme-study .paper-card .progress-bar {
  height: 6px;
  background: #333537;
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
  width: 200px;
  max-width: 100%;
}
body.theme-study .paper-card .progress-bar span {
  display: block;
  height: 100%;
  background: #a8c7fa;
}
body.theme-study .paper-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.theme-study .card-actions .quiz-reset-btn {
  margin-left: auto;
}

/* Misc study-content spacing */
body.theme-study #study-content {
  flex: 1;
  min-height: 0;
}
body.theme-study .empty,
body.theme-study .muted {
  color: #8e918f;
}
body.theme-study .inner-section {
  background: transparent;
  border-color: transparent;
}

/* ---- Flashcards (deck list + Leitner boxes) dark theme ---- */
body.theme-study .deck-card {
  background: #1e1f20;
  border-color: #2f3032;
  color: #e3e3e3;
}
body.theme-study .deck-card:hover {
  border-color: #a8c7fa;
}
body.theme-study .deck-title {
  color: #e3e3e3;
}
body.theme-study .deck-blurb,
body.theme-study .deck-count {
  color: #8e918f;
}
body.theme-study .box-dist-cell {
  background: #1e1f20;
  border-color: #2f3032;
}
body.theme-study .box-dist-num {
  color: #e3e3e3;
}
body.theme-study .box-dist-label {
  color: #8e918f;
}
body.theme-study .flash-browse-item {
  background: #1e1f20;
  border-color: #2f3032;
  color: #e3e3e3;
}
body.theme-study .flash-browse-item:hover {
  border-color: #a8c7fa;
}

/* ============================================================
   Mobile hardening for the app-shell (Work / Study / Database)
   The default Home view is handled by the @media (max-width:640px)
   block above. These rules fix the full-screen dark shells, which
   keep desktop 40px padding and a 260px sidebar on phones.
   ============================================================ */
@media (max-width: 760px) {
  /* Trim desktop-grade content padding so text isn't cramped */
  body.theme-work #chat-container.w-chat { padding: 16px 14px 12px; }
  body.theme-work .w-hero { padding: 0 14px; gap: 24px; }
  body.theme-database .s-main { padding: 80px 16px 32px; }
  body.theme-study .s-main { padding: 80px 16px 16px; }
  body.theme-study .top-bar { gap: 10px; }
}

@media (max-width: 560px) {
  /* Even tighter content padding on small phones */
  body.theme-database .s-main { padding: 76px 12px 28px; }
  body.theme-study .s-main { padding: 76px 12px 12px; }
  body.theme-work .w-greeting { font-size: 32px; letter-spacing: -0.5px; }

  /* Stack chat hero search + controls that sit side-by-side on desktop */
  body.theme-work #chat-container.w-chat { padding: 12px 10px 10px; }
}

/* Study mode gate — hide study entry points when the session is not allowlisted. */
.study-auth-locked [data-mode="study"],
.study-auth-locked a.s-nav-item[href="#/study"] {
  display: none !important;
}

/* ---- Tools wizard (body.theme-work, route #/tools/<id>) ---- */
body.theme-work .w-main .tool-wizard {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 48px 20px;
  box-sizing: border-box;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}
body.theme-work .tool-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
body.theme-work .tool-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #9aa0a6;
  text-decoration: none;
  font-size: 13px;
  width: fit-content;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
body.theme-work .tool-back-link:hover {
  background: #28292a;
  color: #e3e3e3;
}
body.theme-work .tool-back-link .material-symbols-outlined { font-size: 18px; }
body.theme-work .tool-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
body.theme-work .tool-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: linear-gradient(135deg, #4285f4, #9b72cb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
body.theme-work .tool-icon .material-symbols-outlined { font-size: 26px; }
body.theme-work .tool-title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.3px;
  color: #e3e3e3;
}
body.theme-work .tool-progress { display: flex; }
body.theme-work .tool-pill {
  font-size: 12px;
  font-weight: 600;
  color: #a8c7fa;
  background: rgba(168, 199, 250, 0.12);
  border: 1px solid rgba(168, 199, 250, 0.25);
  border-radius: 999px;
  padding: 4px 12px;
}
body.theme-work .tool-card {
  background-color: #1e1f20;
  border: 1px solid #2a2b2d;
  border-radius: 16px;
  padding: 22px 22px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body.theme-work .tool-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
body.theme-work .tool-card-top .tool-restart {
  background: none;
  border: none;
  color: #9aa0a6;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
body.theme-work .tool-card-top .tool-restart:hover { background: #28292a; color: #e3e3e3; }
body.theme-work .tool-question {
  font-size: 18px;
  line-height: 1.5;
  font-weight: 500;
  color: #e3e3e3;
}
body.theme-work .tool-quote {
  margin: 0;
  padding: 12px 16px;
  border-left: 3px solid #a8c7fa;
  background: #161719;
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  line-height: 1.55;
  color: #c4c7c5;
  font-style: italic;
}
body.theme-work .tool-srcs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #c4c7c5;
  background: #2b2c2e;
  border: 1px solid #3a3c3e;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
body.theme-work .tool-srcs-toggle:hover { background: #343638; color: #fff; }
body.theme-work .tool-srcs-toggle .material-symbols-outlined { font-size: 15px; }
body.theme-work .tool-srcs-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body.theme-work .tool-srcs-modal[hidden] { display: none; }
body.theme-work .tool-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px 0;
}
body.theme-work .tool-step-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  flex: 0 0 auto;
}
body.theme-work .tool-step-cell .material-symbols-outlined { font-size: 18px; }
body.theme-work .tool-step-yes { background: rgba(129, 201, 149, 0.18); color: #81c995; }
body.theme-work .tool-step-no { background: rgba(242, 139, 130, 0.18); color: #f28b82; }
body.theme-work .tool-step-pending { background: #2b2c2e; color: #9aa0a6; }
body.theme-work .tool-step-num { font-size: 12px; }
body.theme-work .tool-step-current {
  outline: 2px solid #a8c7fa;
  outline-offset: 1px;
}
body.theme-work .tool-srcs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
body.theme-work .tool-srcs-pop {
  position: relative;
  background: #1e1f20;
  border: 1px solid #2a2b2d;
  border-radius: 16px;
  width: min(420px, 100%);
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
body.theme-work .tool-srcs-pop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #e3e3e3;
  margin-bottom: 14px;
}
body.theme-work .tool-srcs-pop-head .material-symbols-outlined { font-size: 20px; }
body.theme-work .tool-srcs-pop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.theme-work .tool-source-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  color: #c4c7c5;
  background: #2b2c2e;
  border: 1px solid #3a3c3e;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
body.theme-work .tool-source-row:hover { background: #343638; color: #fff; }
body.theme-work .tool-source-row .material-symbols-outlined { font-size: 18px; }
body.theme-work .tool-source-study { color: #9dd3ac; }
body.theme-work .tool-source-guideline { color: #a8c7fa; }
body.theme-work .tool-source-law { color: #f2b8b5; }
body.theme-work .tool-src {
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
body.theme-work .tool-src .material-symbols-outlined { font-size: 15px; }
body.theme-work .tool-src:hover { background: #343638; color: #fff; }
body.theme-work .tool-src-law { color: #f2b8b5; border-color: rgba(242, 139, 130, 0.35); }
body.theme-work .tool-src-guideline { color: #a8c7fa; border-color: rgba(168, 199, 250, 0.35); }
body.theme-work .tool-src-study { color: #9dd3ac; border-color: rgba(129, 201, 149, 0.35); }
body.theme-work .tool-actions {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}
body.theme-work .tool-actions .btn { min-width: 96px; }
body.theme-work .tool-answer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
}
body.theme-work .tool-answer .material-symbols-outlined { font-size: 16px; }
body.theme-work .tool-answer-yes { color: #81c995; background: rgba(129, 201, 149, 0.12); border: 1px solid rgba(129, 201, 149, 0.3); }
body.theme-work .tool-answer-no { color: #f28b82; background: rgba(242, 139, 130, 0.12); border: 1px solid rgba(242, 139, 130, 0.3); }
body.theme-work .tool-feedback {
  font-size: 14px;
  line-height: 1.55;
  color: #c4c7c5;
  background: #161719;
  border-radius: 10px;
  padding: 12px 14px;
}
body.theme-work .tool-verdict {
  border-radius: 16px;
  padding: 28px 24px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body.theme-work .tool-verdict-yes {
  background: rgba(129, 201, 149, 0.08);
  border: 1px solid rgba(129, 201, 149, 0.4);
}
body.theme-work .tool-verdict-no {
  background: rgba(242, 139, 130, 0.08);
  border: 1px solid rgba(242, 139, 130, 0.4);
}
body.theme-work .tool-verdict-icon { align-self: center; }
body.theme-work .tool-verdict-icon .material-symbols-outlined {
  font-size: 48px;
  color: #81c995;
}
body.theme-work .tool-verdict-no .tool-verdict-icon .material-symbols-outlined { color: #f28b82; }
body.theme-work .tool-verdict-title {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #e3e3e3;
}
body.theme-work .tool-verdict-why {
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  color: #c4c7c5;
  max-width: 560px;
  margin: 0 auto;
}
body.theme-work .tool-verdict-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  color: #9dd3ac;
  background: rgba(129, 201, 149, 0.12);
  border: 1px solid rgba(129, 201, 149, 0.3);
}
body.theme-work .tool-verdict-count .material-symbols-outlined { font-size: 16px; }
body.theme-work .tool-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
body.theme-work .tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
}
body.theme-work .tool-row-label {
  flex: 0 0 auto;
  font-weight: 600;
  color: #c4c7c5;
  min-width: 118px;
}
body.theme-work .tool-row-q { flex: 1 1 auto; color: #9aa0a6; line-height: 1.4; }
body.theme-work .tool-row-chip {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
body.theme-work .tool-row-match { border-color: rgba(129, 201, 149, 0.45); }
body.theme-work .tool-row-match .tool-row-chip { color: #81c995; background: rgba(129, 201, 149, 0.14); }
body.theme-work .tool-row-also .tool-row-chip { color: #9aa0a6; background: #2b2c2e; }
body.theme-work .tool-row-block { border-color: rgba(242, 139, 130, 0.45); }
body.theme-work .tool-row-block .tool-row-chip { color: #f28b82; background: rgba(242, 139, 130, 0.14); }
body.theme-work .tool-row-fail .tool-row-chip { color: #9aa0a6; background: #2b2c2e; }
body.theme-work .tool-sources-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
  padding: 14px;
}
body.theme-work .tool-sources-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #9aa0a6;
  margin-bottom: 2px;
}
body.theme-work .tool-source-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #e3e3e3;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease;
}
body.theme-work .tool-source-row:hover { background: #1e1f20; }
body.theme-work .tool-source-row .material-symbols-outlined { font-size: 20px; }
body.theme-work .tool-source-law .material-symbols-outlined { color: #f2b8b5; }
body.theme-work .tool-source-guideline .material-symbols-outlined { color: #a8c7fa; }
body.theme-work .tool-source-study .material-symbols-outlined { color: #9dd3ac; }
body.theme-work .tool-verdict-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}
body.theme-work .tool-verdict-actions .btn { text-decoration: none; }
body.theme-work .w-card-desc {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: #9aa0a6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Dark-shell button overrides for the tools wizard (light-theme vars leak here). */
body.theme-work .tool-wizard .btn {
  background: #2b2c2e;
  color: #e3e3e3;
  border: 1px solid #3a3c3e;
}
body.theme-work .tool-wizard .btn:hover { background: #343638; border-color: #4a4c4e; }
body.theme-work .tool-wizard .btn + .btn { margin-left: 0; }
body.theme-work .tool-verdict-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2b2c2e;
  color: #e3e3e3;
  border: 1px solid #3a3c3e;
}
body.theme-work .tool-verdict-actions .btn:hover { background: #343638; border-color: #4a4c4e; }
body.theme-work .tool-verdict-actions .btn.secondary { background: transparent; }
body.theme-work .tool-wizard .tool-yes {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
}
body.theme-work .tool-wizard .tool-yes:hover { background: #c2410c; border-color: #c2410c; }
body.theme-work .tool-wizard .tool-next .material-symbols-outlined,
body.theme-work .tool-wizard .tool-next { vertical-align: middle; }
body.theme-work .tool-wizard .tool-next .material-symbols-outlined { font-size: 16px; margin-left: 4px; }

body.theme-work .tool-wizard.prsc-wide .tool-sources-block {
  padding: 10px 12px;
  gap: 2px;
}
body.theme-work .tool-wizard.prsc-wide .tool-sources-title { margin-bottom: 0; }
body.theme-work .tool-wizard.prsc-wide .tool-source-row {
  padding: 8px 8px;
  font-size: 12px;
  gap: 8px;
  align-items: center;
}
body.theme-work .tool-wizard.prsc-wide .tool-source-row .material-symbols-outlined { flex: 0 0 auto; }

/* PR & SC calculator (custom single-page First Schedule lookup). */
body.theme-work .w-main .tool-wizard.prsc-wide {
  max-width: 1080px;
  padding-top: 24px;
  gap: 16px;
}
/* Header: back button left, title centered with its icon on the same line. */
body.theme-work .prsc-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}
body.theme-work .prsc-header .tool-back-link {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}
body.theme-work .prsc-header .tool-title-row { margin: 0; }
/* The container is a column flex that fills the viewport height; children were
   squashing (the table collapsed to a sliver) because each defaulted to
   flex-shrink:1. Pin natural height so the long page scrolls instead. */
body.theme-work .tool-wizard > * {
  flex-shrink: 0;
}
body.theme-work .prsc-layout {
  display: flex;
  gap: 20px;
  align-items: stretch;
}
body.theme-work .prsc-controls {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body.theme-work .prsc-intro {
  font-size: 14px;
  line-height: 1.6;
  color: #c4c7c5;
  margin: 0;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
  padding: 14px 16px;
}
body.theme-work .prsc-card {
  background-color: #1e1f20;
  border: 1px solid #2a2b2d;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.theme-work .prsc-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #9aa0a6;
}
body.theme-work .prsc-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
body.theme-work .prsc-input {
  flex: 1;
  background: #161719;
  border: 1px solid #3a3c3e;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 16px;
  font-weight: 600;
  color: #e3e3e3;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
body.theme-work .prsc-input::placeholder { color: #5f6066; font-weight: 400; }
body.theme-work .prsc-input:focus { border-color: #a8c7fa; box-shadow: 0 0 0 3px rgba(168, 199, 250, 0.18); }
body.theme-work .prsc-unit { font-size: 16px; font-weight: 600; color: #9aa0a6; }
body.theme-work .prsc-result {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(168, 199, 250, 0.08);
  border: 1px solid rgba(168, 199, 250, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
}
body.theme-work .prsc-result[hidden] { display: none; }
body.theme-work .prsc-result-chip {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #a8c7fa;
  background: rgba(168, 199, 250, 0.14);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
body.theme-work .prsc-result-label { font-size: 14px; font-weight: 600; color: #e3e3e3; }
body.theme-work .prsc-table-side {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.theme-work .prsc-table-wrap {
  flex: 1;
  width: 100%;
  overflow: auto;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 16px;
  padding: 6px;
  box-sizing: border-box;
}
body.theme-work .prsc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  table-layout: fixed;
}
body.theme-work .prsc-col-band { width: 102px; }
body.theme-work .prsc-table th,
body.theme-work .prsc-table td {
  border: 1px solid #2a2b2d;
  padding: 3px 4px;
  text-align: center;
  line-height: 1.15;
}
body.theme-work .prsc-table thead th {
  background: #1e1f20;
  color: #c4c7c5;
  font-weight: 600;
  font-size: 10px;
}
body.theme-work .prsc-table thead .prsc-height { width: 102px; }
body.theme-work .prsc-table thead .prsc-sub th { font-size: 9px; color: #9aa0a6; font-weight: 500; }
body.theme-work .prsc-table tbody td { color: #c4c7c5; }
body.theme-work .prsc-table tbody .prsc-band {
  text-align: left;
  font-weight: 600;
  color: #9aa0a6;
}
body.theme-work .prsc-table tbody .prsc-val { font-variant-numeric: tabular-nums; }
body.theme-work .prsc-table tbody .prsc-gr { border-right: 2px solid #3a3c3e; }
body.theme-work .prsc-table tbody tr.is-hit {
  background: rgba(168, 199, 250, 0.10);
  box-shadow: inset 2px 0 0 #a8c7fa;
}
body.theme-work .prsc-table tbody tr.is-hit td { color: #e3e3e3; }
body.theme-work .prsc-table tbody tr.is-hit .prsc-band { color: #a8c7fa; }
body.theme-work .prsc-table tbody tr.is-hit .prsc-val { font-weight: 600; }

/* Table cells are the input: click one to pick a band + site class. */
body.theme-work .prsc-table tbody td[data-c] { cursor: pointer; }
body.theme-work .prsc-table tbody td[data-c]:hover {
  background: rgba(168, 199, 250, 0.10);
  color: #e3e3e3;
}
/* Reg 22 composite building card. */
body.theme-work .prsc-comp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
body.theme-work .prsc-info-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #3a3c3e;
  background: #1e1f20;
  color: #9aa0a6;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
body.theme-work .prsc-info-btn .material-symbols-outlined { font-size: 15px; }
body.theme-work .prsc-info-btn:hover { border-color: #a8c7fa; color: #a8c7fa; }
body.theme-work .prsc-info-btn[aria-expanded="true"] {
  border-color: #a8c7fa;
  color: #a8c7fa;
  background: rgba(168, 199, 250, 0.14);
}
body.theme-work .prsc-quote {
  font-size: 11.5px;
  line-height: 1.55;
  color: #9aa0a6;
  margin: 0;
  padding: 10px 12px;
  background: #141516;
  border: 1px dashed #2a2b2d;
  border-radius: 10px;
  font-style: italic;
}
body.theme-work .prsc-quote[hidden] { display: none; }
body.theme-work .prsc-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
body.theme-work .prsc-slider-end {
  flex: 0 0 auto;
  font-size: 10px;
  color: #9aa0a6;
  white-space: nowrap;
}
body.theme-work .prsc-slider {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #2a2b2d;
  outline: none;
  cursor: pointer;
}
body.theme-work .prsc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -3px;
  border-radius: 50%;
  background: #e3e3e3;
  border: 2px solid #161719;
  cursor: pointer;
}
body.theme-work .prsc-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e3e3e3;
  border: 2px solid #161719;
  cursor: pointer;
}
body.theme-work .prsc-comp-inputs {
  display: flex;
  gap: 10px;
}
body.theme-work .prsc-comp-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.theme-work .prsc-splitbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
body.theme-work .prsc-splitbar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: #2a2b2d;
}
body.theme-work .prsc-slider-value {
  font-size: 13px;
  font-weight: 600;
  color: #e3e3e3;
}
/* Tabs below the First Schedule: Domestic / Non-domestic / Composite. */
body.theme-work .prsc-tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
}
body.theme-work .prsc-tab {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #9aa0a6;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
body.theme-work .prsc-tab:hover { color: #c4c7c5; }
body.theme-work .prsc-tab.is-active {
  background: rgba(168, 199, 250, 0.14);
  color: #e3e3e3;
}
body.theme-work .prsc-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
}
body.theme-work .prsc-pane.is-active { display: flex; }
body.theme-work .prsc-statement p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #e3e3e3;
}
body.theme-work .prsc-statement p strong { color: #a8c7fa; }
body.theme-work .prsc-stmt-prompt {
  margin: 0;
  font-size: 13px;
  color: #9aa0a6;
}
body.theme-work .prsc-stmt-formula {
  font-size: 13px;
  font-weight: 600;
  color: #c4c7c5;
  font-variant-numeric: tabular-nums;
}
body.theme-work .prsc-math-block {
  margin: 10px 0 2px;
  font-weight: 400;
  font-size: 15px;
}
body.theme-work .prsc-math-block .katex-display {
  margin: 0;
}
body.theme-work .prsc-math-block .katex {
  font-size: 1.05em;
  color: #e3e3e3;
}
body.theme-work .prsc-stmt-warn {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #ffb4ab;
}
body.theme-work .prsc-stmt-warn strong { color: #ffb4ab; }
/* Highlighted site-class column inside the matched band. */
body.theme-work .prsc-table tbody td.is-col-c {
  background: rgba(168, 199, 250, 0.18);
  color: #e3e3e3;
  font-weight: 600;
}

/* On narrow screens the controls stack above the table instead of beside it. */
@media (max-width: 860px) {
  body.theme-work .w-main .tool-wizard.prsc-wide { max-width: 760px; }
  body.theme-work .prsc-layout { flex-direction: column; }
  body.theme-work .prsc-controls {
    flex: 1 1 auto;
    position: static;
    width: 100%;
  }
  body.theme-work .prsc-table-side { width: 100%; }
  body.theme-work .prsc-col-band { width: 96px; }
  body.theme-work .prsc-table thead .prsc-height { width: 96px; }
}

/* MOE checker (custom step wizard — Code of Practice for Means of Escape in
   Case of Fire 2011, Tables A1 / B1 / B2). Every step answers with a table row,
   not a yes/no; rows are the input, like the First Schedule in prsc. */
/* Fills the viewport: the card keeps the table scrolling inside it and the
   step buttons stay pinned, so the page itself never scrolls. */
body.theme-work .w-main .tool-wizard.moe-wide {
  max-width: 960px;
  padding: 16px 20px 14px 20px;
  gap: 12px;
  overflow: hidden;
}
body.theme-work .moe-tracker {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
}
body.theme-work .moe-track-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 11px;
  color: #9aa0a6;
  background: transparent;
}
body.theme-work .moe-track-cell .material-symbols-outlined { font-size: 16px; }
body.theme-work .moe-track-num { font-size: 12px; font-weight: 700; }
body.theme-work .moe-track-cell.is-current {
  background: rgba(168, 199, 250, 0.14);
  color: #e3e3e3;
}
body.theme-work .moe-track-cell.is-done { color: #81c995; }
body.theme-work .moe-track-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
body.theme-work .moe-card {
  gap: 12px;
  padding: 16px 18px 14px 18px;
  flex: 1;
  min-height: 0;
}
body.theme-work .moe-card > * { flex-shrink: 0; }
/* Two-column body: left = the step/instructions, right = the table, full height. */
body.theme-work .moe-cols {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex: 1 1 auto;
  flex-shrink: 1;
  min-height: 0;
}
body.theme-work .moe-left {
  flex: 0 0 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
/* Instructions scroll if they outgrow the card; the nav buttons stay pinned. */
body.theme-work .moe-left-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
}
body.theme-work .moe-left-scroll::-webkit-scrollbar { width: 8px; }
body.theme-work .moe-left-scroll::-webkit-scrollbar-thumb {
  background: #3a3c3e;
  border-radius: 999px;
}
body.theme-work .moe-left-scroll::-webkit-scrollbar-track { background: transparent; }
body.theme-work .moe-nav { flex: 0 0 auto; }
body.theme-work .moe-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Pinned content (chips, inputs) above the scrollable table. */
body.theme-work .moe-pinned {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Context chips sit on one wrapping row so the pinned area stays short. */
body.theme-work .moe-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* The table / answer region: the only thing that scrolls inside the card. */
body.theme-work .moe-scroll {
  flex: 1 1 auto;
  flex-shrink: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
}
body.theme-work .moe-scroll::-webkit-scrollbar { width: 8px; }
body.theme-work .moe-scroll::-webkit-scrollbar-thumb {
  background: #3a3c3e;
  border-radius: 999px;
}
body.theme-work .moe-scroll::-webkit-scrollbar-track { background: transparent; }
body.theme-work .moe-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #9aa0a6;
}
body.theme-work .moe-table-wrap {
  width: 100%;
  overflow: auto;
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 14px;
  padding: 6px;
  box-sizing: border-box;
}
body.theme-work .moe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}
body.theme-work .moe-table th,
body.theme-work .moe-table td {
  border: 1px solid #2a2b2d;
  padding: 6px 8px;
  text-align: left;
  line-height: 1.35;
  vertical-align: top;
}
body.theme-work .moe-table thead th {
  background: #1e1f20;
  color: #c4c7c5;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
body.theme-work .moe-table td.moe-code {
  width: 64px;
  font-weight: 700;
  color: #a8c7fa;
  text-align: center;
  vertical-align: middle;
}
/* Table A1 — use classification rows. */
body.theme-work .moe-usetable td.moe-name { width: 28%; font-weight: 600; color: #e3e3e3; }
body.theme-work .moe-usetable td.moe-desc { color: #c4c7c5; }
body.theme-work .moe-usetable tr.moe-group td {
  background: #141516;
  color: #9aa0a6;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
body.theme-work .moe-usetable tr.moe-use-row { cursor: pointer; transition: background 0.15s ease; }
body.theme-work .moe-usetable tr.moe-use-row:hover { background: rgba(168, 199, 250, 0.08); }
body.theme-work .moe-usetable tr.moe-use-row.is-hit {
  background: rgba(168, 199, 250, 0.12);
  box-shadow: inset 3px 0 0 #a8c7fa;
}
body.theme-work .moe-usetable tr.moe-use-row.is-hit td { color: #e3e3e3; }
/* Table B1 — occupancy factor rows (only the selected classification is active). */
body.theme-work .moe-factor-table td.moe-factext { color: #c4c7c5; }
body.theme-work .moe-factor-table td.moe-factor-val {
  width: 130px;
  text-align: right;
  font-weight: 600;
  color: #e3e3e3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
body.theme-work .moe-factor-table td.moe-factor-special {
  color: #f7c948;
  white-space: normal;
  font-size: 11.5px;
}
body.theme-work .moe-factor-table tr.moe-factor-group td {
  background: #141516;
  color: #9aa0a6;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
body.theme-work .moe-factor-table tr.moe-factor-group.is-active td { color: #a8c7fa; }
body.theme-work .moe-factor-table tr.moe-factor-row[data-code] { cursor: pointer; transition: background 0.15s ease; }
body.theme-work .moe-factor-table tr.moe-factor-row[data-code]:hover { background: rgba(168, 199, 250, 0.08); }
body.theme-work .moe-factor-table tr.moe-factor-row.is-hit {
  background: rgba(168, 199, 250, 0.12);
  box-shadow: inset 3px 0 0 #a8c7fa;
}
body.theme-work .moe-factor-table tr.moe-factor-off td { opacity: 0.38; }
body.theme-work .moe-factor-table tr.moe-factor-locked td { color: #9aa0a6; font-style: italic; }
/* Selected / context chips. */
body.theme-work .moe-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(168, 199, 250, 0.08);
  border: 1px solid rgba(168, 199, 250, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
}
body.theme-work .moe-selected-chip,
body.theme-work .moe-context-chip {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #a8c7fa;
  background: rgba(168, 199, 250, 0.14);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
body.theme-work .moe-selected-label,
body.theme-work .moe-context-label {
  font-size: 14px;
  font-weight: 600;
  color: #e3e3e3;
}
body.theme-work .moe-context { display: flex; align-items: center; gap: 10px; }
body.theme-work .moe-context-label { font-size: 13px; line-height: 1.45; }
/* Area / count input. */
body.theme-work .moe-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
body.theme-work .moe-input {
  flex: 1;
  background: #161719;
  border: 1px solid #3a3c3e;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 16px;
  font-weight: 600;
  color: #e3e3e3;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
body.theme-work .moe-input::placeholder { color: #5f6066; font-weight: 400; }
body.theme-work .moe-input:focus { border-color: #a8c7fa; box-shadow: 0 0 0 3px rgba(168, 199, 250, 0.18); }
body.theme-work .moe-unit {
  font-size: 16px;
  font-weight: 600;
  color: #9aa0a6;
  white-space: nowrap;
}
/* Table B2 — answer table. */
body.theme-work .moe-b2table th,
body.theme-work .moe-b2table td { text-align: center; vertical-align: middle; }
body.theme-work .moe-b2table td.moe-b2-cap { text-align: left; font-weight: 600; }
body.theme-work .moe-b2table tr.moe-b2-row.is-hit {
  background: rgba(168, 199, 250, 0.12);
  box-shadow: inset 3px 0 0 #a8c7fa;
}
body.theme-work .moe-b2table tr.moe-b2-row.is-hit td { color: #e3e3e3; font-weight: 600; }
/* Answer statements. */
body.theme-work .moe-stmt {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #e3e3e3;
}
body.theme-work .moe-stmt strong { color: #a8c7fa; }
body.theme-work .moe-stmt-prompt {
  margin: 0;
  font-size: 13px;
  color: #9aa0a6;
}
body.theme-work .moe-stmt-warn {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #ffb4ab;
}
body.theme-work .moe-stmt-warn strong { color: #ffb4ab; }
body.theme-work .moe-warn { color: #f7c948; }
body.theme-work .moe-warn strong { color: #f7c948; }
body.theme-work .moe-stmt-formula {
  font-size: 13px;
  font-weight: 600;
  color: #c4c7c5;
  font-variant-numeric: tabular-nums;
}
/* Wizard navigation. */
body.theme-work .moe-nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
body.theme-work .moe-nav .btn {
  min-width: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
body.theme-work .moe-nav .btn .material-symbols-outlined { font-size: 16px; }
body.theme-work .moe-nav .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
body.theme-work .moe-actual-row { margin-top: 2px; }
/* Step 1 helper card (keeps the area step from looking empty in the scroll
   region while still filling the viewport height). */
body.theme-work .moe-hint {
  background: #161719;
  border: 1px solid #2a2b2d;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #c4c7c5;
}
body.theme-work .moe-hint p { margin: 0 0 8px 0; }
body.theme-work .moe-hint p:last-child { margin-bottom: 0; }
body.theme-work .moe-hint strong { color: #a8c7fa; }
body.theme-work .moe-hint-dim { color: #9aa0a6; }
/* On narrow screens the step column stacks above the table instead of beside it. */
@media (max-width: 860px) {
  body.theme-work .w-main .tool-wizard.moe-wide { max-width: 760px; overflow-y: auto; }
  body.theme-work .moe-cols { flex-direction: column; }
  body.theme-work .moe-left { flex: 1 1 auto; width: 100%; }
  body.theme-work .moe-left-scroll { flex: none; overflow: visible; }
  body.theme-work .moe-right { width: 100%; }
}
@media (max-width: 640px) {
  body.theme-work .moe-track-label { display: none; }
}

/* MOA checker (custom step wizard — Code of Practice for Fire Safety in
   Buildings 2011, Subsection A7 / Table A1 + Part D / Table D1). Reuses the
   moe-* two-column card layout and the moe-usetable use-classification table;
   only the Table D1 answer table and notes are MOA-specific. */
body.theme-work .moa-empty { display: flex; flex-direction: column; gap: 12px; }
/* Table D1 — answer table. */
body.theme-work .moa-d1table td.moa-cond { font-weight: 600; color: #e3e3e3; }
body.theme-work .moa-d1table td { vertical-align: top; }
body.theme-work .moa-d1table th { text-align: left; }
body.theme-work .moa-d1table th.moa-cond-th { width: 46%; }
body.theme-work .moa-d1table tr.moe-factor-group.is-active td {
  background: #1b1d20;
  color: #a8c7fa;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
body.theme-work .moa-d1table tr.moa-d1-row.is-hit td { color: #e3e3e3; }
body.theme-work .moa-note1 { margin-top: 4px; font-size: 12px; color: #9aa0a6; }
body.theme-work .moa-highrisk {
  background: rgba(255, 180, 171, 0.08);
  border: 1px solid rgba(255, 180, 171, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
}
body.theme-work .moa-d1note { color: #f7c948; font-size: 13px; }

/* Reading List — interactive checklist (replaces the open-book reference PDF). */
.reading-list-wrap { max-width: 720px; margin: 0 auto; }
.rl-header { margin-bottom: 20px; }
.rl-title { font-size: 20px; font-weight: 600; margin: 0; color: #e3e3e3; }
.rl-subtitle { font-size: 13px; color: #8e918f; margin-top: 4px; }
.rl-hint { font-size: 13px; color: #8e918f; margin-top: 8px; }
.rl-progress { max-width: 320px; margin-top: 10px; height: 6px; background: #333537; border-radius: 4px; overflow: hidden; }
.rl-progress span { display: block; height: 100%; background: #a8c7fa; }
.rl-progress.complete span,
.rl-paper-card.complete .progress-bar span { background: #4caf50; }

/* Paper card grid */
.rl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.rl-paper-card { cursor: pointer; }
.rl-paper-card .progress-bar { height: 6px; background: #333537; border-radius: 4px; margin-top: 10px; overflow: hidden; width: 100%; }
.rl-paper-card .progress-bar span { display: block; height: 100%; background: #a8c7fa; }
.rl-paper-card.complete .progress-bar span { background: #4caf50; }
.rl-card-chevron { color: #8e918f; flex-shrink: 0; }

/* Back link */
a.rl-back { display: inline-flex; align-items: center; gap: 6px; color: #a8c7fa; text-decoration: none; font-size: 14px; margin-bottom: 18px; }
a.rl-back:hover { text-decoration: underline; }

/* Book list grouped by category */
.rl-cat { margin-bottom: 22px; }
.rl-cat-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #8e918f; margin-bottom: 10px; }
.rl-book-list { background-color: #1e1f20; border: 1px solid #2a2b2c; border-radius: 16px; padding: 16px; }
.rl-book { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 11px 10px; border-radius: 10px; cursor: pointer; }
.rl-book:hover { background-color: #28292a; }
/* Invisible full-size checkbox — keeps focus local so clicking a row never
   scroll-jumps the checklist out of view. */
.rl-book input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.rl-check { width: 22px; height: 22px; flex-shrink: 0; border-radius: 6px; border: 2px solid #4a4d4f; display: flex; align-items: center; justify-content: center; margin-top: 1px; transition: background 0.15s, border-color 0.15s; background: transparent; }
.rl-check .material-symbols-outlined { font-size: 16px; color: transparent; transition: color 0.15s; }
.rl-book.checked .rl-check { background: #004a77; border-color: #004a77; }
.rl-book.checked .rl-check .material-symbols-outlined { color: #c2e7ff; }
.rl-book-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rl-book-num { font-size: 11px; font-weight: 700; color: #a8c7fa; }
.rl-book-name { font-size: 14px; color: #e3e3e3; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }
.rl-book-note { font-size: 12px; color: #8e918f; }
.rl-book.checked .rl-book-name { color: #8e918f; text-decoration: line-through; }

/* Save action */
.rl-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.rl-save-btn { background-color: #004a77; color: #c2e7ff; border: none; padding: 10px 26px; border-radius: 20px; font-size: 14px; font-weight: 600; font-family: var(--font-family, 'Google Sans', sans-serif); cursor: pointer; text-decoration: none; }
.rl-save-btn:hover { background-color: #005c93; }

@media (max-width: 640px) {
  .rl-grid { grid-template-columns: 1fr; }
}
