:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #f1f5f4;
  --line: #d8dfda;
  --text: #1d2522;
  --muted: #66736f;
  --primary: #1d6f63;
  --primary-strong: #14564d;
  --indigo: #4757b8;
  --amber: #ac6a1b;
  --rose: #b84b5d;
  --shadow: 0 18px 50px rgba(31, 45, 42, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Noto Sans Thai", "Sarabun", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #eef3ef;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.muted,
.eyebrow {
  color: var(--muted);
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.25;
}

.bot-status {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: 8px;
  min-width: 220px;
  text-align: right;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: minmax(460px, 1.25fr) minmax(360px, .75fr);
  gap: 18px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h3 {
  font-size: 20px;
}

.field-label,
label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #36413d;
}

.input,
.compact-select,
.style-search {
  width: 100%;
  border: 1px solid #cbd5cf;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.input:focus,
.compact-select:focus,
.style-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 111, 99, .12);
}

.title-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.add-story-btn {
  height: 42px;
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.story-create-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}

.compact-select {
  width: 180px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.span-2 {
  grid-column: 1 / -1;
}

.textarea {
  resize: vertical;
  min-height: 96px;
}

.upload-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1.5px dashed #b9c7c0;
  border-radius: 8px;
  background: #f5faf7;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.upload-box:hover,
.upload-box.drag-over,
.upload-box:focus-visible {
  border-color: var(--primary);
  background: #edf7f2;
  outline: none;
}

.upload-box.drag-over {
  transform: translateY(-1px);
}

.quick-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.quick-run[hidden] {
  display: none;
}

.quick-run strong,
.quick-run span {
  display: block;
}

.quick-run span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.upload-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e5eeeb;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.05;
}

.upload-copy {
  min-width: 0;
}

.upload-copy strong,
.upload-copy span,
.upload-copy small {
  display: block;
}

.upload-copy strong {
  font-size: 16px;
}

.upload-copy span,
.upload-copy small {
  color: var(--muted);
}

.upload-copy span {
  margin-top: 2px;
  font-size: 13px;
}

.upload-copy small {
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.upload-native {
  display: block;
  width: 100%;
  max-width: 360px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.upload-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -2px 0 16px;
}

.upload-actions .compact-select {
  min-width: 190px;
}

.advanced-paths {
  margin: -2px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.advanced-paths summary {
  cursor: pointer;
  padding: 11px 12px;
  color: var(--muted);
  font-weight: 800;
  list-style-position: inside;
}

.advanced-paths p {
  margin: 0;
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 13px;
}

.advanced-paths .form-grid {
  padding: 0 12px 12px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
}

.toggle span {
  margin: 0;
  font-weight: 600;
}

.btn,
.icon-btn,
.select-face {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
}

.icon-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  align-self: flex-start;
}

.btn:hover,
.icon-btn:hover,
.select-face:hover {
  border-color: var(--primary);
}

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

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

.btn.danger,
.icon-btn.danger {
  border-color: rgba(220, 38, 38, .42);
  color: #b42318;
  background: #fff1f1;
}

.btn.danger:hover,
.icon-btn.danger:hover {
  border-color: #dc2626;
  background: #ffe4e4;
}

.btn.large {
  min-width: 150px;
  font-weight: 800;
}

.btn.compact {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.compact-input {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 13px;
}

.sidebar-actions,
.submit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-actions {
  margin-top: auto;
}

.result-text {
  color: var(--muted);
  min-height: 24px;
}

.qc-report-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.qc-report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.qc-report-text {
  margin: 10px 0 0;
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  font-size: 13px;
  line-height: 1.65;
}

.status-stack {
  display: grid;
  gap: 10px;
}

.cost-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  padding: 10px;
}

.cost-card span,
.cost-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.cost-card strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.btn.danger-lite {
  border-color: rgba(185, 28, 28, .32);
  color: #991b1b;
  background: rgba(254, 226, 226, .72);
}

.btn.danger-lite:hover {
  border-color: rgba(185, 28, 28, .54);
  background: rgba(254, 202, 202, .82);
}

.api-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.56);
}

.api-card .field-label {
  margin-bottom: -2px;
}

.api-mode {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.sidebar-actions.tight {
  margin-top: 0;
}

.stat-line,
.activity-item,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  padding: 10px;
}

.stat-line strong,
.metric strong {
  display: block;
  font-size: 20px;
}

.stat-line span,
.metric span,
.activity-item span {
  color: var(--muted);
  font-size: 13px;
}

.activity-item div span {
  display: block;
  margin-top: 2px;
}

.style-picker {
  position: relative;
}

.select-face {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #edf2ff;
  border-color: #c9d1f6;
  color: #253aa4;
  font-weight: 800;
}

.style-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 440px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(25, 31, 29, .2);
}

.style-search {
  margin-bottom: 8px;
}

.style-list {
  max-height: 350px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
}

.style-option {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.style-option:hover,
.style-option.active {
  background: #eef3ef;
}

.style-option strong {
  display: block;
  font-size: 14px;
}

.style-option span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.prompt-preview {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.prompt-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.prompt-title strong {
  color: var(--amber);
}

.prompt-preview pre,
.log-tail {
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  line-height: 1.6;
}

.prompt-preview pre {
  max-height: 440px;
  padding: 14px;
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric.bad strong {
  color: var(--rose);
}

.activity-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.activity-item {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
}

button.activity-item {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  padding: 10px;
  font: inherit;
}

button.activity-item:hover {
  border-color: var(--accent);
}

.activity-item strong {
  overflow-wrap: anywhere;
}

.log-panel {
  margin-top: 18px;
}

.log-tail {
  max-height: 320px;
  padding: 14px;
  border-radius: 8px;
  background: #17211f;
  color: #dbe7df;
  font-size: 12px;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .bot-status,
  .compact-select {
    width: 100%;
    text-align: left;
  }
  .panel-head,
  .submit-row,
  .sidebar-actions,
  .upload-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .upload-box {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .upload-box .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
  .form-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .activity-item {
    grid-template-columns: 1fr;
  }
}

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #151f31;
  --surface-soft: #101827;
  --line: #2a3850;
  --text: #eef5ff;
  --muted: #9aacc4;
  --primary: #22c58b;
  --primary-strong: #16a274;
  --indigo: #7c8cff;
  --amber: #f0b35a;
  --rose: #fb7185;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
}

body {
  background:
    radial-gradient(circle at top left, rgba(34, 197, 139, .12), transparent 30%),
    linear-gradient(180deg, #0b1220 0%, #0e1626 48%, #0b1220 100%);
}

.sidebar {
  background: #111a2a;
}

.brand-mark,
.btn.primary {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.panel,
.bot-status,
.api-card,
.stat-line,
.activity-item,
.metric,
.quick-run,
.advanced-paths,
.toggle {
  background: var(--surface);
  border-color: var(--line);
}

.input,
.compact-select,
.style-search,
.btn,
.icon-btn,
.select-face {
  background: #0f1726;
  border-color: var(--line);
  color: var(--text);
}

.field-label,
label span {
  color: #c8d6e8;
}

.input::placeholder,
.style-search::placeholder {
  color: #778aa5;
}

.upload-box {
  background: #101d2b;
  border-color: rgba(34, 197, 139, .45);
}

.upload-box:hover,
.upload-box.drag-over,
.upload-box:focus-visible {
  background: #122538;
}

.upload-mark {
  background: #162b37;
  color: #7ee7bd;
}

.style-menu {
  background: #111a2a;
  border-color: var(--line);
}

.style-option:hover,
.style-option.active,
.select-face {
  background: #17233a;
}

.log-tail {
  background: #07111f;
  color: #dce8f8;
}

.library-panel {
  padding: 0;
  overflow: hidden;
}

.library-panel + .grid {
  margin-top: 18px;
}

.library-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #0d1626;
  overflow-x: auto;
}

.library-tab {
  min-width: 92px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, .04);
  background: transparent;
  color: var(--muted);
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 800;
}

.library-tab:hover,
.library-tab.active {
  color: #82f1c2;
  background: #142338;
}

.library-tab.active {
  box-shadow: inset 0 -2px 0 var(--primary);
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) minmax(0, 1fr);
  min-height: 640px;
}

.library-layout.source-collapsed {
  grid-template-columns: minmax(280px, 320px) minmax(0, 2fr);
}

.library-layout.source-collapsed .source-pane {
  display: none;
}

.library-side,
.reader-pane {
  min-width: 0;
  min-height: 0;
}

.library-side {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #121d2e;
}

.library-side-head,
.reader-head,
.editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-side-head {
  padding: 16px 14px 10px;
}

.library-side-head h3,
.reader-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.memory-tools,
.toc-tools {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--line);
}

.inline-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px;
}

.toc-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
}

.toc-nav-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.small-select {
  min-width: 0;
}

.full {
  width: 100%;
}

.sync-note {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.glossary-editor {
  display: grid;
  gap: 10px;
  margin: 0 12px 12px;
  padding: 12px;
  border: 1px solid rgba(34, 197, 139, .32);
  border-radius: 8px;
  background: #0e1829;
}

.glossary-editor[hidden] {
  display: none;
}

.compact-textarea {
  min-height: 74px;
}

.editor-toggle {
  justify-content: flex-start;
}

.chapter-list,
.glossary-list {
  min-height: 0;
  overflow: auto;
  padding: 10px 8px 14px;
}

.chapter-card,
.glossary-card {
  width: 100%;
  margin: 0 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #182438;
  color: var(--text);
}

.chapter-card {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.chapter-card:hover,
.chapter-card.active {
  border-color: rgba(34, 197, 139, .65);
  background: #1b2c42;
}

.chapter-card strong,
.chapter-card span,
.chapter-card small,
.glossary-main strong,
.glossary-main span,
.glossary-main small {
  display: block;
  overflow-wrap: anywhere;
}

.chapter-card span,
.chapter-card small,
.glossary-main small {
  color: var(--muted);
  font-size: 12px;
}

.glossary-card {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.glossary-main {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.glossary-main strong {
  font-size: 15px;
}

.glossary-arrow {
  margin-top: 2px;
  color: #54e7a7;
  font-weight: 800;
}

.glossary-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.relation-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.relation-rule-note {
  margin: 0;
  border: 1px solid rgba(34, 197, 139, .45);
  border-radius: 6px;
  padding: 8px 10px;
  color: #b7f8d8;
  background: rgba(34, 197, 139, .10);
  font-size: 12px;
  font-weight: 800;
}

.relation-card .glossary-main small {
  display: block;
}

.relation-card .warn-line {
  color: #f59e0b;
}

.relation-editor textarea {
  resize: vertical;
}

.term-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(124, 140, 255, .5);
  border-radius: 6px;
  padding: 3px 8px;
  color: #aeb8ff;
  background: rgba(124, 140, 255, .12);
  font-size: 12px;
  font-weight: 800;
}

.term-badge.locked {
  border-color: rgba(34, 197, 139, .5);
  color: #86efc4;
  background: rgba(34, 197, 139, .12);
}

.icon-btn.mini {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 7px;
  font-size: 15px;
}

.reader-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #0f1726;
}

.translated-pane {
  border-right: 0;
  background: #0d1524;
}

.reader-head {
  min-height: 58px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #111c2d;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.replace-tools {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 250, 247, .92);
}

.replace-note {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-toggle {
  padding: 7px 9px;
  font-size: 12px;
}

#toggleSourceBtn[aria-pressed="true"] {
  border-color: rgba(34, 197, 139, .65);
  color: #86efc4;
  background: rgba(34, 197, 139, .12);
}

.reader-text {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 24px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #f5f9ff;
  line-height: 2.05;
  font-family: "Noto Sans Thai", "Sarabun", "Malgun Gothic", system-ui, sans-serif;
  font-size: 17px;
}

textarea.reader-text {
  width: 100%;
  border: 0;
  resize: none;
  outline: none;
  background: transparent;
}

.reader-editable {
  caret-color: #82f1c2;
}

.reader-editable:focus {
  box-shadow: inset 0 0 0 1px rgba(34, 197, 139, .36);
}

.source-pane .reader-text {
  color: #d9e8ff;
}

.translated-pane .reader-text {
  color: #fff9ef;
  font-weight: 600;
}

.translation-save-note {
  min-height: 28px;
  margin: 0;
  padding: 6px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #111c2d;
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
}

@media (max-width: 1180px) {
  .library-layout {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }
  .library-layout.source-collapsed {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }
  .translated-pane {
    grid-column: 2 / 3;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .library-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .library-layout.source-collapsed {
    grid-template-columns: 1fr;
  }
  .library-side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: min(82dvh, 720px);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .memory-tools,
  .toc-tools {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #121d2e;
  }
  .glossary-editor {
    max-height: calc(100dvh - 150px);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .glossary-editor label,
  .relation-editor label {
    min-width: 0;
  }
  .glossary-list,
  .chapter-list {
    max-height: 62dvh;
  }
  .relation-tools {
    gap: 8px;
  }
  .reader-pane,
  .translated-pane {
    min-height: 420px;
    border-right: 0;
  }
  .translated-pane {
    grid-column: auto;
  }
  .reader-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .replace-tools {
    grid-template-columns: 1fr;
  }
  .inline-tools {
    grid-template-columns: 1fr;
  }
  .reader-text {
    padding: 18px;
    font-size: 16px;
  }
}

/* Modern command-center refresh. CSS-only so bot logic, IDs, and data flow stay untouched. */
:root {
  color-scheme: dark;
  --bg: #080d16;
  --surface: #111827;
  --surface-soft: #172033;
  --surface-raised: #1b2638;
  --line: #2d3a50;
  --line-strong: #3f526f;
  --text: #f4f8ff;
  --muted: #9fb0c8;
  --primary: #2dd4a0;
  --primary-strong: #12a97c;
  --indigo: #8fa2ff;
  --amber: #f4bd62;
  --rose: #fb7185;
  --danger: #f87171;
  --shadow: 0 18px 44px rgba(0, 0, 0, .28);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, .20);
  --focus: 0 0 0 3px rgba(45, 212, 160, .24);
}

html {
  background: var(--bg);
}

body {
  min-height: 100dvh;
  background:
    linear-gradient(145deg, #080d16 0%, #0b1320 46%, #101923 100%);
  font-size: 15px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input,
textarea,
.upload-box {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.upload-box:focus-visible,
.select-face:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.app-shell {
  grid-template-columns: minmax(280px, 316px) minmax(0, 1fr);
}

.sidebar {
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(20, 30, 48, .98), rgba(12, 18, 30, .98));
  border-right: 1px solid rgba(143, 162, 255, .18);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .03);
}

.brand {
  padding: 4px 0 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--primary), #4f8cff);
  box-shadow: 0 10px 24px rgba(45, 212, 160, .24);
}

.brand h1 {
  font-size: 20px;
  letter-spacing: 0;
}

.workspace {
  padding: 22px;
}

.topbar {
  min-height: 66px;
  margin-bottom: 16px;
}

.topbar h2 {
  font-size: clamp(24px, 2.1vw, 34px);
  letter-spacing: 0;
}

.auth-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(244, 189, 98, .38);
  border-radius: 10px;
  color: #ffe4b3;
  background: rgba(120, 73, 20, .20);
  box-shadow: var(--shadow-soft);
}

.auth-notice strong {
  flex: 0 0 auto;
  color: #ffd48a;
}

.auth-notice span {
  color: #ffeccd;
  overflow-wrap: anywhere;
}

.auth-notice[hidden] {
  display: none;
}

.eyebrow {
  color: #7ddfc0;
  font-size: 11px;
  letter-spacing: .04em;
}

.panel,
.bot-status,
.api-card,
.cost-card,
.stat-line,
.activity-item,
.metric,
.quick-run,
.advanced-paths,
.toggle,
.qc-report-box,
.glossary-editor {
  background: linear-gradient(180deg, rgba(27, 38, 56, .94), rgba(17, 24, 39, .96));
  border-color: rgba(143, 162, 255, .16);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 20px;
}

.library-panel {
  padding: 0;
  border-color: rgba(45, 212, 160, .20);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .32);
}

.library-tabs {
  background: #0b1320;
  scrollbar-width: thin;
}

.library-tab {
  min-height: 52px;
  color: #a8b8cf;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.library-tab:hover,
.library-tab.active {
  color: #dffdf1;
  background: rgba(45, 212, 160, .10);
}

.library-tab.active {
  box-shadow: inset 0 -3px 0 var(--primary);
}

.library-layout {
  min-height: min(76dvh, 780px);
}

.library-side,
.reader-head,
.translation-save-note {
  background: rgba(13, 20, 34, .92);
}

.reader-pane {
  background: #0c1422;
}

.translated-pane {
  background: #0a111d;
}

.reader-head {
  min-height: 62px;
}

.reader-text {
  padding: clamp(18px, 2.2vw, 32px);
  font-size: clamp(16px, 1.15vw, 18px);
  line-height: 2.05;
  scrollbar-width: thin;
}

.translated-pane .reader-text {
  color: #fff7e8;
  font-weight: 560;
}

.source-pane .reader-text {
  color: #dceaff;
}

.chapter-card,
.glossary-card {
  background: rgba(27, 38, 56, .88);
  border-color: rgba(143, 162, 255, .16);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.chapter-card:hover,
.chapter-card.active,
.glossary-card:hover {
  background: rgba(31, 48, 72, .96);
  border-color: rgba(45, 212, 160, .58);
}

.chapter-card.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.input,
.compact-select,
.style-search,
.btn,
.icon-btn,
.select-face {
  min-height: 44px;
  border-color: rgba(143, 162, 255, .20);
  background: rgba(8, 13, 22, .78);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.input:hover,
.compact-select:hover,
.style-search:hover {
  border-color: rgba(143, 162, 255, .36);
}

.input:focus,
.compact-select:focus,
.style-search:focus {
  border-color: rgba(45, 212, 160, .70);
  box-shadow: var(--focus);
}

.btn,
.icon-btn,
.select-face,
.upload-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.btn:hover,
.icon-btn:hover,
.select-face:hover {
  border-color: rgba(45, 212, 160, .70);
  background: rgba(23, 36, 58, .96);
}

.btn:active,
.icon-btn:active,
.select-face:active {
  transform: translateY(1px);
}

.btn.primary {
  color: #04110d;
  background: linear-gradient(180deg, #54e7b6, var(--primary));
  border-color: rgba(45, 212, 160, .88);
  box-shadow: 0 10px 24px rgba(45, 212, 160, .18);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #6af0c2, #23c493);
}

.btn.danger,
.btn.danger-lite,
.icon-btn.danger {
  color: #ffe5e5;
  background: rgba(127, 29, 29, .55);
  border-color: rgba(248, 113, 113, .45);
}

.btn.compact {
  min-height: 44px;
}

.icon-btn {
  border-radius: 10px;
}

.icon-btn.mini {
  width: 44px;
  height: 44px;
}

.toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.toggle {
  min-height: 44px;
}

.upload-native {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-box {
  border-color: rgba(45, 212, 160, .42);
  background: linear-gradient(180deg, rgba(16, 31, 47, .92), rgba(12, 22, 36, .92));
}

.upload-box:hover,
.upload-box.drag-over {
  border-color: rgba(45, 212, 160, .88);
  background: rgba(18, 39, 58, .96);
}

.upload-mark {
  border-radius: 12px;
  background: rgba(45, 212, 160, .14);
  color: #92f3cc;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 160, .24);
}

.style-menu {
  border-color: rgba(143, 162, 255, .22);
  background: #10192b;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .44);
}

.style-option {
  color: var(--text);
}

.style-option:hover,
.style-option.active {
  background: rgba(45, 212, 160, .10);
}

.prompt-preview {
  border-color: rgba(143, 162, 255, .18);
  background: rgba(8, 13, 22, .52);
}

.prompt-title {
  background: rgba(8, 13, 22, .72);
}

.replace-tools {
  background: rgba(13, 20, 34, .94);
}

.log-tail,
.qc-report-text {
  background: #070d18;
  border-color: rgba(143, 162, 255, .16);
}

.status-stack,
.activity-list,
.chapter-list,
.glossary-list,
.style-list,
.log-tail,
.reader-text {
  scrollbar-color: rgba(45, 212, 160, .50) rgba(255, 255, 255, .04);
}

/* Gradient polish layer: visual-only overrides, no data or bot behavior changes. */
:root {
  --bg: #060914;
  --surface: #121b2d;
  --surface-soft: #0d1728;
  --surface-raised: #1a2740;
  --line: rgba(141, 160, 207, .22);
  --line-strong: rgba(142, 168, 255, .42);
  --primary: #2fe0ad;
  --primary-strong: #12b886;
  --cyan: #38bdf8;
  --violet: #9b87f5;
  --amber: #f5bf5a;
  --rose: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, .28);
  --focus: 0 0 0 3px rgba(47, 224, 173, .24), 0 0 0 1px rgba(56, 189, 248, .18);
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    linear-gradient(118deg, rgba(24, 76, 93, .46) 0%, rgba(6, 9, 20, .98) 31%, rgba(35, 26, 72, .60) 64%, #080b16 100%),
    linear-gradient(180deg, #060914 0%, #09101e 52%, #080b16 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(100deg, transparent 0%, rgba(47, 224, 173, .11) 18%, transparent 36%),
    linear-gradient(285deg, transparent 10%, rgba(155, 135, 245, .12) 48%, transparent 72%),
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 28%);
  opacity: .95;
}

::selection {
  color: #03120e;
  background: rgba(47, 224, 173, .82);
}

.app-shell {
  position: relative;
  z-index: 1;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(20, 33, 56, .98), rgba(9, 15, 28, .98)),
    linear-gradient(135deg, rgba(47, 224, 173, .14), transparent 42%, rgba(155, 135, 245, .13));
  border-right-color: rgba(142, 168, 255, .24);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .05), 16px 0 50px rgba(0, 0, 0, .22);
}

.brand {
  margin-bottom: 4px;
}

.brand-mark {
  border-radius: 8px;
  background: linear-gradient(135deg, #2fe0ad 0%, #38bdf8 52%, #f5bf5a 100%);
  box-shadow: 0 16px 36px rgba(47, 224, 173, .26), inset 0 1px 0 rgba(255, 255, 255, .42);
}

.brand h1,
.topbar h2 {
  text-wrap: balance;
}

.topbar {
  padding: 2px 2px 10px;
}

.bot-status {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .025)),
    linear-gradient(135deg, rgba(47, 224, 173, .14), rgba(155, 135, 245, .10));
  border-color: rgba(142, 168, 255, .28);
}

.panel,
.api-card,
.cost-card,
.stat-line,
.activity-item,
.metric,
.quick-run,
.advanced-paths,
.toggle,
.qc-report-box,
.glossary-editor {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .025)),
    linear-gradient(135deg, rgba(20, 32, 54, .96), rgba(10, 16, 30, .98));
  border-color: rgba(142, 168, 255, .20);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.library-panel {
  border-color: rgba(47, 224, 173, .30);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .07);
}

.library-tabs {
  background:
    linear-gradient(90deg, rgba(47, 224, 173, .12), rgba(56, 189, 248, .07), rgba(155, 135, 245, .10)),
    #09111f;
}

.library-tab {
  border-right-color: rgba(255, 255, 255, .055);
}

.library-tab:hover,
.library-tab.active {
  color: #f3fff9;
  background:
    linear-gradient(180deg, rgba(47, 224, 173, .18), rgba(47, 224, 173, .07));
}

.library-tab.active {
  box-shadow: inset 0 -3px 0 #2fe0ad, inset 0 1px 0 rgba(255, 255, 255, .08);
}

.library-side,
.reader-head,
.translation-save-note {
  background:
    linear-gradient(180deg, rgba(16, 27, 47, .96), rgba(11, 18, 33, .96));
}

.reader-pane {
  background:
    linear-gradient(180deg, rgba(14, 24, 42, .98), rgba(8, 14, 26, .98));
}

.translated-pane {
  background:
    linear-gradient(180deg, rgba(13, 18, 31, .98), rgba(7, 12, 23, .98));
}

.reader-head {
  border-color: rgba(142, 168, 255, .18);
}

.chapter-card,
.glossary-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018)),
    linear-gradient(135deg, rgba(26, 40, 65, .94), rgba(14, 23, 40, .96));
  border-color: rgba(142, 168, 255, .18);
}

.chapter-card:hover,
.chapter-card.active,
.glossary-card:hover {
  background:
    linear-gradient(180deg, rgba(47, 224, 173, .13), rgba(56, 189, 248, .04)),
    linear-gradient(135deg, rgba(31, 48, 78, .98), rgba(17, 28, 49, .98));
  border-color: rgba(47, 224, 173, .58);
  transform: translateY(-1px);
}

.chapter-card.active {
  box-shadow: inset 3px 0 0 #2fe0ad, 0 12px 28px rgba(47, 224, 173, .09);
}

.input,
.compact-select,
.style-search,
.btn,
.icon-btn,
.select-face,
textarea {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015)),
    rgba(5, 10, 20, .72);
  border-color: rgba(142, 168, 255, .22);
}

.input:focus,
.compact-select:focus,
.style-search:focus,
textarea:focus {
  border-color: rgba(47, 224, 173, .78);
}

.btn.primary {
  color: #03120e;
  background: linear-gradient(135deg, #74f4c8 0%, #2fe0ad 48%, #38bdf8 100%);
  border-color: rgba(116, 244, 200, .82);
  box-shadow: 0 14px 30px rgba(47, 224, 173, .24), inset 0 1px 0 rgba(255, 255, 255, .38);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #9af7d6 0%, #35e7b4 46%, #60cdfb 100%);
}

.btn.danger-lite {
  background:
    linear-gradient(180deg, rgba(251, 113, 133, .17), rgba(127, 29, 29, .38));
}

.upload-box {
  background:
    linear-gradient(180deg, rgba(47, 224, 173, .11), rgba(47, 224, 173, .035)),
    linear-gradient(135deg, rgba(16, 31, 47, .95), rgba(10, 18, 32, .96));
}

.upload-mark {
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(47, 224, 173, .20), rgba(56, 189, 248, .16));
}

.style-menu,
.prompt-preview,
.replace-tools,
.log-tail,
.qc-report-text {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015)),
    #09111f;
  border-color: rgba(142, 168, 255, .20);
}

.prompt-title {
  background: linear-gradient(90deg, rgba(47, 224, 173, .10), rgba(155, 135, 245, .08));
}

@media (max-width: 760px) {
  body::before {
    opacity: .68;
  }

  .topbar {
    padding-bottom: 6px;
  }

  .sidebar,
  .workspace {
    padding: 14px;
  }
}

.prescan-card { display:flex; align-items:flex-start; gap:12px; margin:12px 0; padding:14px; border:1px solid #b9ddd3; border-radius:14px; background:linear-gradient(135deg,#effaf6,#f8fbfa); color:var(--primary-strong); }
.prescan-card p { margin:4px 0 0; color:var(--muted); font-size:13px; line-height:1.5; }
.prescan-icon { width:30px; height:30px; display:grid; place-items:center; border-radius:10px; background:var(--primary); color:#fff; flex:0 0 auto; }
.prescan-tools { margin: 12px 0; }
.prescan-item { align-items: flex-start; }
.prescan-item > span:last-child { min-width: 0; }
.prescan-item small { overflow-wrap: anywhere; }
.prescan-modal-panel { max-width: 680px; margin: 8vh auto; padding: 20px; background: #151f31; color: #eef5ff; border: 1px solid #2a3850; border-radius: 16px; box-shadow: 0 20px 60px #0005; }
.prescan-modal-panel .sync-note { color: #9aacc4; }
.prescan-modal-panel label > span { color: #eef5ff; }
.prescan-modal-panel .input, .prescan-modal-panel textarea { background: #101827; color: #eef5ff; border: 1px solid #2a3850; }
.prescan-modal-panel .input::placeholder { color: #6b7f9a; }
.prescan-adjudication-modal[hidden] { display: none; }
.prescan-adjudication-modal { position: fixed; inset: 0; z-index: 50; padding: 12px; background: #0008; overflow: auto; }
.prescan-modal-warning { color: #b91c1c; font-weight: 700; }
.prescan-modal-evidence { white-space: pre-wrap; max-height: 220px; overflow: auto; padding: 10px; background: #2a1218; color: #ffd9de; border-left: 3px solid #fb7185; border-radius: 6px; }
.prescan-alternate-btn { margin: 4px 4px 4px 0; }
.prescan-conflict { border: 2px solid #fb7185 !important; background: linear-gradient(135deg, rgba(159, 18, 57, .55), rgba(69, 10, 10, .55)) !important; box-shadow: 0 0 0 2px rgba(251, 113, 133, .18); color: #fff5f6 !important; }
.prescan-conflict .glossary-main strong { color: #fff5f6 !important; }
.prescan-conflict .glossary-main small, .prescan-conflict .glossary-main span { color: #ffd9de !important; }
.prescan-conflict .prescan-conflict-label { margin: 0 0 4px; color: #ffb3bd !important; font-weight: 800; }
.prescan-conflict .prescan-conflict-options { margin: 0 0 8px; color: #ffd0d7 !important; font-size: 13px; overflow-wrap: anywhere; }
.prescan-conflict .btn { color: #7f1d1d !important; background: #fecdd3; border-color: #fecdd3; }
.prescan-approve-bar { position: sticky; bottom: 10px; z-index: 3; margin: 10px 0; box-shadow: 0 8px 24px rgba(0,0,0,.28); }

@media (max-width: 640px) {
  .workspace { padding-bottom:88px; }
  .panel { border-radius:16px; }
  .btn, .input, select { min-height:44px; }
  .toggle { min-height:40px; padding:8px 10px; border:1px solid var(--line); border-radius:10px; background:var(--surface-soft); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 1380px) {
  .library-layout {
    min-height: 0;
  }

  .library-layout {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  }

  .library-layout.source-collapsed {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  }

  .translated-pane {
    grid-column: 2 / 3;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 1020px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
  }

  .workspace {
    padding: 16px;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .topbar {
    gap: 12px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .auth-notice {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 16px;
  }

  .library-panel {
    padding: 0;
  }

  .library-side {
    max-height: 74dvh;
  }

  .library-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .reader-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .reader-actions .btn,
  .reader-actions .toggle {
    flex: 1 1 130px;
  }

  .upload-box {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .upload-mark {
    width: 48px;
    height: 48px;
  }

  .upload-actions,
  .submit-row {
    gap: 8px;
  }

  .btn,
  .icon-btn,
  .select-face,
  .input,
  .compact-select {
    min-height: 46px;
  }

  .chapter-list,
  .glossary-list {
    max-height: 58dvh;
  }

  .reader-text {
    line-height: 1.9;
  }
}

/* Mobile hard stop: keep this last so wider breakpoint overrides cannot split the reader again. */
@media (max-width: 760px) {
  body {
    padding-top: env(safe-area-inset-top);
  }

  .app-shell,
  .workspace,
  .panel,
  .library-panel,
  .library-layout,
  .library-side,
  .reader-pane,
  .source-pane,
  .translated-pane {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .workspace {
    padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 22px;
    line-height: 1.25;
  }

  .bot-status {
    width: 100%;
    min-height: 52px;
  }

  .library-layout,
  .library-layout.source-collapsed {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .library-side,
  .reader-pane,
  .source-pane,
  .translated-pane {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .library-side {
    max-height: none;
    border-bottom: 1px solid var(--line);
  }

  .source-pane {
    border-top: 1px solid var(--line);
  }

  .translated-pane {
    border-top: 1px solid var(--line);
  }

  .reader-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .reader-actions .btn,
  .reader-actions .toggle {
    width: 100%;
  }

  .toc-tools,
  .replace-tools,
  .inline-tools {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .reader-text {
    min-height: 300px;
    max-height: 70dvh;
    padding: 16px;
    font-size: 16px;
    line-height: 1.9;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .source-collapsed .translated-pane {
    grid-column: 1 / -1;
  }
}
