:root {
  color-scheme: light;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --ink: #181818;
  --muted: #676a70;
  --rule: #dedede;
  --button: #f1f3f5;
  --button-active: #101316;
  --button-active-text: #ffffff;
  --accent: #0c6b58;
  --accent-2: #3258a8;
  --mark: #fff8cf;
  --select-mark: #fff7c7;
  --hover-blue: #e4f3ff;
  --shadow: 0 12px 40px rgba(15, 20, 25, 0.12);
  --ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body-serif: Merriweather, Georgia, "Times New Roman", Times, serif;
  --title-serif: Merriweather, Georgia, "Times New Roman", Times, serif;
  --serif: var(--body-serif);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-serif);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

body.auth-pending .app-shell,
body.login-required .app-shell {
  visibility: hidden;
}

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

.source-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
  background: #f6f7f8;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--ui);
}

.rail-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.ui-kicker {
  color: var(--accent);
  font: 700 11px/1.2 var(--ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.settings-button {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 1px solid #d3d8dd;
  border-radius: 8px;
  background: #fff;
  color: #3f454b;
  cursor: pointer;
}

.settings-button:hover {
  border-color: #9ca7b0;
  color: #20252a;
}

.settings-button.active {
  border-color: #25292e;
  background: #25292e;
  color: #fff;
}

.settings-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-controls {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--ui);
}

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

.control-row:last-child {
  margin-bottom: 0;
}

.source-search-input {
  width: 100%;
  border: 1px solid #cfd4d8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 9px 10px;
  font: 600 12px/1.2 var(--ui);
}

.source-search-input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(50, 88, 168, 0.12);
}

.rail-control {
  min-height: 29px;
  border: 1px solid #d3d8dd;
  border-radius: 8px;
  background: #fff;
  color: #3f454b;
  padding: 5px 9px;
  cursor: pointer;
  font: 700 11px/1 var(--ui);
}

.rail-control.active {
  border-color: #25292e;
  background: #25292e;
  color: #fff;
}

.icon-filter {
  width: 32px;
  padding: 4px;
  display: grid;
  place-items: center;
}

.icon-filter .source-icon {
  background: transparent;
}

.icon-filter.active .source-icon {
  color: #fff;
}

.source-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.source-summary {
  border-top: 1px solid var(--rule);
  padding: 10px 14px;
  color: var(--muted);
  font: 700 11px/1.3 var(--ui);
}

.source-button {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 10px;
  margin: 0 0 7px;
  cursor: pointer;
  font-family: var(--ui);
}

.source-button:hover {
  background: #ffffff;
  border-color: var(--rule);
}

.source-button.active {
  background: var(--button-active);
  color: var(--button-active-text);
}

.source-icons {
  display: flex;
  gap: 4px;
}

.source-icon {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #e5eaef;
  color: #26313a;
  font: 13px/1 var(--ui);
}

.source-icon svg {
  width: 14px;
  height: 14px;
}

.mode-icon {
  position: relative;
}

.mode-icon span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.mode-solo span {
  left: 6.5px;
  top: 6.5px;
}

.mode-interview span:first-child {
  left: 4px;
  top: 6.5px;
}

.mode-interview span:nth-child(2) {
  left: 9px;
  top: 6.5px;
}

.mode-multi span:first-child {
  left: 6.5px;
  top: 3.5px;
}

.mode-multi span:nth-child(2) {
  left: 4px;
  top: 9px;
}

.mode-multi span:nth-child(3) {
  left: 9px;
  top: 9px;
}

.source-button.active .source-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.source-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.source-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.source-button.active .source-subtitle {
  color: rgba(255, 255, 255, 0.68);
}

.reader {
  min-width: 0;
}

.utility-rail {
  position: relative;
  top: 0;
  min-height: 100vh;
  padding: 20px clamp(18px, 2.3vw, 34px) 20px 0;
  align-self: stretch;
}

.reader-top {
  padding: 30px clamp(24px, 5vw, 70px) 18px;
}

.reader-top.empty {
  padding: 0;
}

.source-header {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.source-header h2 {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  font: 800 clamp(28px, 3.6vw, 48px) / 1.08 var(--ui);
  letter-spacing: 0;
  overflow-wrap: break-word;
}

.title-icon-button {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #d4d9dd;
  border-radius: 8px;
  background: #fff;
  color: #30363d;
  text-decoration: none;
  cursor: pointer;
  font: 800 14px/1 var(--ui);
}

.title-icon-button:hover {
  border-color: #9ca7b0;
}

.source-header .subtitle {
  margin-top: 8px;
  max-width: 900px;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 13px;
}

.people-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  font-family: var(--ui);
}

.people-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.people-pill {
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #30363d;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  font-family: var(--ui);
}

.meta-pill {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.7);
  color: #3f454b;
  font-size: 11px;
}

.utility-sticky {
  position: sticky;
  top: 20px;
  z-index: 5;
  padding-bottom: 14px;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper) calc(100% - 12px), rgba(251, 251, 248, 0) 100%);
  font-family: var(--ui);
}

.search-form {
  margin-top: 8px;
  font-family: var(--ui);
}

.search-form input {
  width: 100%;
  border: 1px solid #cfd4d8;
  border-radius: 8px;
  background: #ffffff;
  padding: 11px 12px;
  color: var(--ink);
  outline: none;
  font: 500 14px/1.2 var(--ui);
}

.search-form input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(50, 88, 168, 0.14);
}

.margin-notes {
  position: absolute;
  top: 0;
  left: 0;
  right: clamp(18px, 2.3vw, 34px);
  font-family: var(--ui);
}

.margin-note {
  position: absolute;
  left: 0;
  right: 0;
  border-left: 2px solid #d7dcdf;
  padding: 0 0 0 10px;
  color: #4a5057;
}

.margin-note button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.margin-note button:hover .margin-note-title {
  color: #1d4380;
}

.margin-note-title {
  display: block;
  color: #22272d;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.margin-note-score {
  display: block;
  margin-top: 3px;
  color: #65707a;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.margin-note-preview {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
}

.reader-section.xref-hover {
  background: var(--hover-blue);
}

.content {
  max-width: 980px;
  padding: 12px clamp(24px, 5vw, 70px) 132px;
}

.reader-section {
  scroll-margin-top: 130px;
}

.reader-section-block,
.reader-turn {
  margin: 0 0 17px;
}

.reader-section-inline {
  border-radius: 4px;
  padding: 1px 2px;
  margin: 0 -2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.reader-section.selected {
  background: var(--select-mark);
  border-radius: 8px;
}

.speaker-name {
  display: block;
  margin: 24px 0 6px;
  color: #20252a;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 800;
}

.label-edit-button {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 7px;
  border: 1px solid #d8dee2;
  border-radius: 999px;
  background: #f7f8f8;
  color: #555d64;
  cursor: pointer;
  font: 800 11px/1 var(--ui);
  vertical-align: middle;
}

.label-edit-button:hover {
  border-color: #b9c0c6;
  background: #edf0f1;
  color: #25292e;
}

.section-text {
  margin: 0;
  max-width: 820px;
  font-size: 18px;
  line-height: 1.65;
}

.section-text a {
  color: #315f7c;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.section-text a:hover {
  color: #19384c;
}

.rich-section {
  display: grid;
  gap: 13px;
}

.rich-heading {
  margin: 13px 0 0;
  color: #20252a;
  font: 800 22px/1.16 var(--ui);
  letter-spacing: 0;
}

.rich-heading:first-child {
  margin-top: 0;
}

.rich-paragraph {
  margin: 0;
}

.rich-quote {
  margin: 2px 0 2px 22px;
  padding: 0 0 0 16px;
  border-left: 2px solid #d8dedf;
  color: #3f454b;
  font-style: italic;
}

.rich-quote p {
  margin: 0;
  white-space: pre-line;
}

.rich-quote footer,
.rich-attribution {
  margin: 7px 0 0;
  color: var(--muted);
  font: 700 12px/1.4 var(--ui);
  font-style: normal;
}

.rich-attribution {
  text-align: right;
}

.rich-speaker-name {
  margin-top: 0;
}

.reader-section[data-word-timed="true"]:hover {
  background: transparent;
}

.reader-word {
  border-radius: 3px;
  cursor: pointer;
  padding: 0 1px;
  margin: 0 -1px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.reader-word:hover,
.reader-word.playing {
  background: var(--hover-blue);
}

.reader-word.selected {
  background: var(--select-mark);
}

.reader-word[data-timing-status="text_mismatch"] {
  text-decoration: underline dotted rgba(120, 102, 38, 0.5);
  text-underline-offset: 3px;
}

.section-text.transcript {
  padding-left: 22px;
  border-left: 2px solid #d8dedf;
}

.audio-dock {
  position: fixed;
  left: max(300px, 26vw);
  right: 0;
  bottom: 0;
  width: auto;
  border: 1px solid var(--rule);
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: 0 -8px 28px rgba(15, 20, 25, 0.1);
  padding: 10px clamp(24px, 5vw, 70px);
  z-index: 20;
  font-family: var(--ui);
}

.audio-dock audio {
  width: 100%;
  height: 36px;
}

.hidden {
  display: none !important;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
  font-family: var(--ui);
}

.result-head h2 {
  margin: 0;
  font: 800 24px/1.1 var(--ui);
}

.result-count {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.ask-button {
  position: relative;
  border: 0;
  border-radius: 8px;
  padding: 2px;
  background: linear-gradient(135deg, #ff7a59, #ffcf33, #46c87a, #37a8ff, #9c6bff);
  background-size: 220% 220%;
  background-position: 0% 0%;
  cursor: pointer;
  font-family: var(--ui);
  transition:
    background-position 180ms ease,
    transform 180ms ease;
}

.ask-button:hover {
  background-position: 100% 100%;
}

.ask-button.thinking {
  background-size: 280% 280%;
  animation: ask-gradient 1.1s linear infinite;
}

.ask-button span {
  display: block;
  border-radius: 6px;
  background: #fff;
  padding: 10px 15px;
  color: #171717;
  font-weight: 800;
}

.ask-button.icon-only span {
  width: 44px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.ask-button svg {
  width: 18px;
  height: 18px;
}

.ask-button:disabled {
  cursor: wait;
}

@keyframes ask-gradient {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 200%;
  }
}

.ask-response {
  position: relative;
  margin: 0 0 28px;
  max-width: 840px;
  border-left: 3px solid #9c6bff;
  padding: 4px 0 4px 18px;
  font-size: 20px;
  line-height: 1.62;
}

.ask-response-pending {
  color: var(--muted);
}

.ask-error {
  border-left-color: #b91c1c;
  color: #8b1a1a;
  font-family: var(--ui);
  font-size: 15px;
}

.ask-audio {
  display: block;
  margin: -8px 0 30px 21px;
  width: min(520px, 100%);
  height: 34px;
}

.citation-ref {
  position: relative;
  vertical-align: super;
  border: 0;
  background: transparent;
  color: #315aa6;
  cursor: pointer;
  font: 800 0.68em/1 var(--ui);
  padding: 0 1px;
}

.citation-ref sup {
  font-size: inherit;
  line-height: 0;
}

.citation-ref:hover {
  color: #173d7d;
}

.citation-ref::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: max-content;
  max-width: 280px;
  transform: translateX(-50%);
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: #20252a;
  padding: 9px 11px;
  text-align: left;
  font: 700 12px/1.35 var(--ui);
}

.citation-ref:hover::after {
  opacity: 1;
}

.result-item {
  max-width: 860px;
  border-top: 1px solid var(--rule);
  padding: 18px 0 20px;
  cursor: pointer;
}

.result-source {
  margin-bottom: 8px;
  font-family: var(--ui);
}

.result-source strong {
  display: block;
  font-size: 13px;
}

.result-source span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.result-text {
  margin: 0;
  font-size: 17px;
  line-height: 1.62;
}

.issues-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font: 800 12px/1.2 var(--ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.issue-item {
  max-width: 820px;
  border-top: 1px solid var(--rule);
  padding: 18px 0 20px;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 5px;
  font-family: var(--ui);
}

.issue-source {
  border: 0;
  background: transparent;
  color: #20252a;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: 800 14px/1.25 var(--ui);
}

.issue-source:hover {
  text-decoration: underline;
}

.issue-meta span,
.issue-subtitle {
  color: var(--muted);
  font: 700 11px/1.35 var(--ui);
}

.issue-status-group {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font: 800 10px/1 var(--ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.issue-status-caption {
  color: var(--muted);
}

.issue-status-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.issue-status-button {
  border: 0;
  border-left: 1px solid var(--rule);
  background: transparent;
  color: #20252a;
  cursor: pointer;
  padding: 7px 9px;
  font: 800 10px/1 var(--ui);
  letter-spacing: 0;
  text-transform: none;
}

.issue-status-button:first-child {
  border-left: 0;
}

.issue-status-button:hover {
  background: #f7f8f6;
}

.issue-status-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.issue-status-button.active {
  color: #20252a;
  box-shadow: inset 0 0 0 1px rgba(32, 37, 42, 0.04);
}

.issue-status-button.status-open.active {
  background-color: #f7ecd9;
}

.issue-status-button.status-needs-review.active {
  background-color: #fff2a8;
}

.issue-status-button.status-closed.active {
  background-color: #dff3e8;
}

.issue-item p {
  margin: 10px 0 0;
  font-size: 17px;
  line-height: 1.62;
}

.empty-state {
  color: var(--muted);
  font: 700 14px/1.4 var(--ui);
}

.source-editor-mode {
  grid-template-columns: minmax(300px, 26vw) minmax(0, 1fr);
  background: #f9faf7;
}

.source-editor-mode .utility-rail,
.source-editor-mode .reader-top,
.source-editor-mode .audio-dock {
  display: none;
}

.source-editor-mode .reader {
  min-height: 100vh;
  background: #fff;
}

.source-editor-mode .content {
  max-width: none;
  padding: 0;
}

.source-editor-view {
  min-height: 100vh;
  padding: 24px clamp(24px, 3.8vw, 54px) 48px;
  font-family: var(--ui);
}

.source-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}

.source-editor-head h2,
.source-editor-panel h3 {
  margin: 5px 0 0;
  color: #20252a;
  font: 800 24px/1.12 var(--ui);
  letter-spacing: 0;
}

.source-editor-head h2 {
  font-size: 32px;
}

.source-editor-head-actions,
.source-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.source-editor-state {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 10px;
  background: #f8faf9;
  color: #3f454b;
  font: 800 11px/1 var(--ui);
}

.source-editor-state.enabled {
  border-color: #b7dccf;
  background: #e6f5ee;
  color: #0c5d4d;
}

.source-editor-state.disabled {
  border-color: #ead0ce;
  background: #fff0ee;
  color: #9f3028;
}

.compact-button {
  width: auto;
  min-height: 32px;
  padding: 8px 12px;
  font: 800 12px/1 var(--ui);
}

.primary-button.compact-button,
.secondary-button.compact-button {
  width: auto;
}

.source-editor-warning {
  margin: 14px 0 0;
  border: 1px solid #ead0ce;
  border-radius: 8px;
  background: #fff8f6;
  color: #8e2b24;
  padding: 10px 12px;
  font: 700 12px/1.4 var(--ui);
}

.source-editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  align-items: start;
  padding-top: 18px;
}

.source-editor-panel {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.source-editor-jobs-panel {
  grid-column: 1 / -1;
}

.selected-source-panel {
  grid-column: 1 / -1;
}

.source-editor-add-panel {
  margin-top: 18px;
}

.source-editor-panel-head {
  margin-bottom: 14px;
}

.source-editor-panel h3 {
  font-size: 19px;
  overflow-wrap: anywhere;
}

.source-editor-meta {
  display: grid;
  gap: 9px;
  margin: 0 0 16px;
}

.source-editor-meta div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.source-editor-meta dt {
  color: var(--muted);
  font: 800 10px/1.2 var(--ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.source-editor-meta dd {
  margin: 0;
  color: #25292e;
  font: 700 12px/1.35 var(--ui);
  overflow-wrap: anywhere;
}

.source-editor-meta a {
  color: #315f7c;
}

.source-editor-form {
  display: grid;
  gap: 12px;
}

.source-editor-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.source-editor-segmented {
  display: inline-flex;
  width: fit-content;
  border: 1px solid #d3d8dd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.source-editor-segmented label {
  min-width: 92px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #3f454b;
  font: 800 12px/1 var(--ui);
}

.source-editor-segmented label.active {
  background: #25292e;
  color: #fff;
}

.source-editor-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.source-editor-segmented span {
  padding: 10px 14px;
}

.source-editor-form label {
  display: grid;
  gap: 5px;
  color: #30363d;
  font: 800 11px/1.2 var(--ui);
}

.source-editor-form input,
.source-editor-form select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cfd4d8;
  border-radius: 8px;
  background: #fff;
  color: #20252a;
  padding: 8px 9px;
  outline: none;
  font: 700 13px/1.25 var(--ui);
}

.source-editor-form input:focus,
.source-editor-form select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(50, 88, 168, 0.12);
}

.source-editor-form .source-editor-segmented input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.source-editor-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 3px 0;
}

.source-editor-options label {
  display: inline-flex;
  grid-template-columns: none;
  gap: 6px;
  align-items: center;
  font-size: 11px;
}

.source-editor-options input {
  width: 15px;
  min-height: 15px;
  height: 15px;
  accent-color: #25292e;
}

.source-editor-form .source-file-input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.source-file-picker {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  border: 1px solid #cfd4d8;
  border-radius: 8px;
  background: #fff;
  padding: 5px;
}

.file-picker-button {
  width: auto;
  min-height: 28px;
  padding: 6px 10px;
  font: 800 11px/1 var(--ui);
}

.source-file-name {
  min-width: 0;
  color: var(--muted);
  font: 700 12px/1.25 var(--ui);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-status {
  min-height: 17px;
  color: var(--muted);
  font: 800 11px/1.3 var(--ui);
}

.form-status.error,
.job-error {
  color: #a62f24;
}

.danger-button {
  border: 1px solid #d79c97;
  border-radius: 8px;
  background: #fff8f6;
  color: #9f3028;
  cursor: pointer;
  padding: 12px;
  font-weight: 800;
}

.danger-button:hover {
  border-color: #be6b63;
  color: #81221c;
}

.danger-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.source-editor-job {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: start;
  border-top: 1px solid var(--rule);
  padding: 12px 0;
}

.source-editor-job:first-child {
  border-top: 0;
  padding-top: 0;
}

.source-editor-job strong,
.source-editor-job span,
.source-editor-job b,
.source-editor-job p {
  display: block;
}

.source-editor-job strong {
  color: #20252a;
  font-size: 13px;
  line-height: 1.25;
}

.source-editor-job span,
.source-editor-job p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.source-editor-job b {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 8px;
  color: #3f454b;
  background: #f8f9f8;
  font: 800 10px/1 var(--ui);
}

.source-editor-job.running b,
.source-editor-job.queued b {
  border-color: #c8d8ef;
  background: #eff5ff;
  color: #315aa6;
}

.source-editor-job.complete b {
  border-color: #b7dccf;
  background: #e6f5ee;
  color: #0c5d4d;
}

.source-editor-job.error b {
  border-color: #ead0ce;
  background: #fff0ee;
  color: #9f3028;
}

mark {
  border-radius: 3px;
  background: var(--mark);
  padding: 0 2px;
}

.loading {
  color: var(--muted);
  font-family: var(--ui);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(246, 247, 248, 0.96);
}

body.authenticated .login-overlay {
  display: none;
}

.login-panel,
.modal-panel {
  width: min(380px, calc(100vw - 40px));
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 24px;
  font-family: var(--ui);
}

.login-panel h2,
.modal-panel h2 {
  margin: 8px 0 16px;
  font: 800 24px/1.1 var(--ui);
}

.login-panel input,
.modal-panel input,
.modal-panel textarea {
  width: 100%;
  border: 1px solid #cfd4d8;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.modal-panel input {
  font: 700 15px/1.3 var(--ui);
}

.settings-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto;
  gap: 12px;
  align-items: center;
  color: #30363d;
  font: 700 13px/1.25 var(--ui);
}

.setting-row span {
  white-space: nowrap;
}

.setting-row input[type="checkbox"] {
  justify-self: end;
  width: 18px;
  height: 18px;
  margin-bottom: 0;
  accent-color: #25292e;
}

.setting-row .setting-number {
  justify-self: end;
  width: 76px;
  margin-bottom: 0;
  padding: 8px 9px;
  text-align: right;
}

.modal-panel textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.4;
}

.login-panel button,
.primary-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--button-active);
  color: #fff;
  padding: 12px;
  cursor: pointer;
  font-weight: 800;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(18, 23, 28, 0.28);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.secondary-button {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  color: #30363d;
  padding: 12px;
  cursor: pointer;
  font-weight: 800;
}

.login-error {
  min-height: 18px;
  margin-top: 10px;
  color: #a62f24;
  font-size: 12px;
}

@media (max-width: 850px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }

  .app-shell.source-editor-mode {
    display: flex;
    flex-direction: column;
  }

  .source-rail {
    order: 2;
    position: relative;
    height: min(52vh, 440px);
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

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

  .rail-controls {
    padding: 8px 10px;
  }

  .rail-controls #filterControls,
  .rail-controls #modeFilterControls {
    display: none;
  }

  .source-list {
    padding: 8px 10px;
  }

  .source-button {
    grid-template-columns: 40px minmax(0, 1fr);
    padding: 8px;
    margin-bottom: 6px;
  }

  .source-summary {
    padding: 8px 12px;
  }

  .utility-rail {
    order: 1;
    position: sticky;
    top: 0;
    z-index: 12;
    height: auto;
    min-height: 0;
    padding: 10px clamp(18px, 5vw, 24px);
    border-bottom: 1px solid rgba(222, 222, 222, 0.86);
    background: var(--paper);
    backdrop-filter: none;
  }

  .utility-sticky {
    position: static;
    padding-bottom: 0;
    background: transparent;
  }

  .margin-notes {
    display: none;
  }

  .reader {
    order: 3;
  }

  .source-editor-mode .source-rail {
    order: 1;
    height: min(46vh, 420px);
  }

  .source-editor-mode .reader {
    order: 2;
  }

  .source-editor-view {
    min-height: auto;
    padding: 18px clamp(18px, 5vw, 24px) 36px;
  }

  .source-editor-head {
    display: grid;
    gap: 12px;
  }

  .source-editor-head h2 {
    font-size: 25px;
  }

  .source-editor-head-actions {
    justify-content: flex-start;
  }

  .source-editor-grid {
    grid-template-columns: 1fr;
  }

  .source-editor-jobs-panel {
    grid-column: auto;
  }

  .source-editor-form-grid {
    grid-template-columns: 1fr;
  }

  .source-editor-meta div {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .reader-top {
    min-height: auto;
  }

  .content {
    padding: 14px clamp(20px, 6vw, 28px) 150px;
  }

  .section-text {
    font-size: 16px;
    line-height: 1.62;
  }

  .audio-dock {
    left: 0;
  }
}
