:root {
  color-scheme: light;
  --user-scale: 1;
  --control-height: 2.55rem;
  --panel-padding: 1rem;
  --content-gap: 1rem;
  --cell-gap: 0.86rem;
  --rail-width: 19.25rem;
  --radius: 8px;
  --bg: #efe3c9;
  --page: #f7eedb;
  --surface: #fff8e9;
  --surface-soft: #efe2c6;
  --surface-panel: rgba(255, 248, 233, 0.95);
  --rail-bg: #091622;
  --rail-panel: rgba(12, 27, 41, 0.94);
  --input-bg: #fffaf0;
  --output-bg: #f7ecd6;
  --active-row: rgba(151, 34, 28, 0.18);
  --ink: #1d1711;
  --muted: #735f42;
  --rail-ink: #fff3d8;
  --rail-muted: #d9b978;
  --line: rgba(105, 73, 35, 0.24);
  --line-strong: rgba(105, 73, 35, 0.45);
  --gold: #c28a2d;
  --gold-soft: rgba(194, 138, 45, 0.18);
  --oxblood: #8f251f;
  --lapis: #254c92;
  --verdigris: #2f7169;
  --green: #2f7d46;
  --accent: #254c92;
  --accent-soft: rgba(37, 76, 146, 0.16);
  --accent-hover: rgba(37, 76, 146, 0.52);
  --accent-row: rgba(37, 76, 146, 0.42);
  --accent-ink: #fff8e9;
  --shadow: 0 18px 46px rgba(45, 28, 12, 0.14);
  --rail-shadow: inset 0 0 0 1px rgba(194, 138, 45, 0.28), 10px 0 36px rgba(5, 10, 16, 0.22);
}

:root[data-theme="regal"] {
  color-scheme: light;
  --bg: #eadbbd;
  --page: #fbefd8;
  --surface: #fff8e8;
  --surface-soft: #ead9b4;
  --surface-panel: rgba(255, 248, 232, 0.97);
  --rail-bg: #06111b;
  --rail-panel: rgba(7, 20, 31, 0.96);
  --input-bg: #fff9ed;
  --output-bg: #f9efd9;
  --active-row: rgba(128, 35, 25, 0.2);
  --ink: #17100b;
  --muted: #715535;
  --rail-ink: #fff2cf;
  --rail-muted: #ddb968;
  --line: rgba(117, 76, 32, 0.28);
  --line-strong: rgba(117, 76, 32, 0.52);
  --gold: #c99338;
  --gold-soft: rgba(201, 147, 56, 0.2);
  --oxblood: #84241d;
  --lapis: #173a69;
  --verdigris: #2d655f;
  --green: #2f7d46;
  --accent: #173a69;
  --accent-soft: rgba(23, 58, 105, 0.13);
  --accent-hover: rgba(23, 58, 105, 0.56);
  --accent-row: rgba(23, 58, 105, 0.42);
  --accent-ink: #fff8e8;
  --shadow: 0 18px 48px rgba(47, 31, 13, 0.16);
  --rail-shadow: inset 0 0 0 1px rgba(201, 147, 56, 0.34), 10px 0 36px rgba(4, 9, 14, 0.26);
}

:root[data-theme="scholarly"] {
  color-scheme: light;
  --bg: #e8ecec;
  --page: #f7f7f0;
  --surface: #fffefa;
  --surface-soft: #e4e9e7;
  --surface-panel: rgba(255, 254, 250, 0.98);
  --rail-bg: #24313a;
  --rail-panel: rgba(36, 49, 58, 0.96);
  --input-bg: #fffefa;
  --output-bg: #f3f5f2;
  --active-row: rgba(47, 94, 122, 0.14);
  --ink: #182129;
  --muted: #52616c;
  --rail-ink: #f7f5ea;
  --rail-muted: #c9d4d2;
  --line: rgba(62, 78, 88, 0.22);
  --line-strong: rgba(62, 78, 88, 0.42);
  --gold: #a67a35;
  --gold-soft: rgba(166, 122, 53, 0.13);
  --oxblood: #7a3330;
  --lapis: #2f5d7c;
  --verdigris: #476f67;
  --green: #2f7450;
  --accent: #2f5d7c;
  --accent-soft: rgba(47, 93, 124, 0.12);
  --accent-hover: rgba(47, 93, 124, 0.46);
  --accent-row: rgba(47, 93, 124, 0.34);
  --accent-ink: #fffefa;
  --shadow: 0 12px 30px rgba(35, 47, 54, 0.1);
  --rail-shadow: inset 0 0 0 1px rgba(226, 231, 226, 0.16), 8px 0 28px rgba(35, 47, 54, 0.14);
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #07111b;
  --page: #0d1823;
  --surface: #111f2c;
  --surface-soft: #142638;
  --surface-panel: rgba(17, 31, 44, 0.96);
  --rail-bg: #050b12;
  --rail-panel: rgba(8, 19, 30, 0.96);
  --input-bg: #0b1622;
  --output-bg: #0f1e2d;
  --active-row: rgba(194, 138, 45, 0.16);
  --ink: #f8efd8;
  --muted: #d1b981;
  --line: rgba(229, 197, 132, 0.22);
  --line-strong: rgba(229, 197, 132, 0.4);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.36);
}

:root[data-theme="ember"] {
  --bg: #2b1712;
  --page: #f2ddbc;
  --surface: #fff2da;
  --surface-soft: #ead0a5;
  --surface-panel: rgba(255, 242, 218, 0.94);
  --rail-bg: #170b0a;
  --rail-panel: rgba(43, 20, 15, 0.95);
  --input-bg: #fff6e5;
  --output-bg: #f4dfbd;
  --active-row: rgba(143, 37, 31, 0.18);
  --ink: #23120d;
  --muted: #7c4e31;
  --line: rgba(103, 47, 28, 0.24);
  --line-strong: rgba(103, 47, 28, 0.42);
}

:root[data-theme="verdant"] {
  --bg: #e5ead8;
  --page: #f3f0dc;
  --surface: #fff8e8;
  --surface-soft: #dce7d2;
  --surface-panel: rgba(255, 248, 232, 0.95);
  --rail-bg: #081813;
  --rail-panel: rgba(10, 34, 27, 0.95);
  --input-bg: #fffaf0;
  --output-bg: #eef3df;
  --active-row: rgba(47, 113, 105, 0.16);
  --ink: #171d13;
  --muted: #5f6b47;
  --line: rgba(55, 83, 51, 0.22);
  --line-strong: rgba(55, 83, 51, 0.42);
}

:root[data-accent="lapis"] {
  --accent: #254c92;
  --accent-soft: rgba(37, 76, 146, 0.16);
  --accent-hover: rgba(37, 76, 146, 0.52);
  --accent-row: rgba(37, 76, 146, 0.42);
}

:root[data-accent="verdigris"] {
  --accent: #2f7169;
  --accent-soft: rgba(47, 113, 105, 0.16);
  --accent-hover: rgba(47, 113, 105, 0.5);
  --accent-row: rgba(47, 113, 105, 0.38);
}

:root[data-accent="oxblood"] {
  --accent: #8f251f;
  --accent-soft: rgba(143, 37, 31, 0.15);
  --accent-hover: rgba(143, 37, 31, 0.5);
  --accent-row: rgba(143, 37, 31, 0.38);
}

:root[data-accent="gold"] {
  --accent: #b8791d;
  --accent-soft: rgba(184, 121, 29, 0.18);
  --accent-hover: rgba(184, 121, 29, 0.5);
  --accent-row: rgba(184, 121, 29, 0.38);
}

:root[data-density="compact"] {
  --control-height: 2.3rem;
  --panel-padding: 0.8rem;
  --content-gap: 0.76rem;
  --cell-gap: 0.64rem;
}

:root[data-density="spacious"] {
  --control-height: 2.82rem;
  --panel-padding: 1.22rem;
  --content-gap: 1.25rem;
  --cell-gap: 1.06rem;
}

:root[data-contrast="high"] {
  --line: rgba(40, 28, 16, 0.42);
  --line-strong: rgba(40, 28, 16, 0.68);
  --muted: #463821;
  --shadow: 0 0 0 1px var(--line-strong);
}

:root[data-theme="midnight"][data-contrast="high"] {
  --line: rgba(255, 235, 190, 0.42);
  --line-strong: rgba(255, 235, 190, 0.68);
  --muted: #ead29b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  font-size: calc(16px * var(--user-scale));
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  background:
    linear-gradient(90deg, rgba(79, 52, 20, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(79, 52, 20, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(194, 138, 45, 0.16), transparent 22rem),
    var(--bg);
  background-size: 38px 38px, 38px 38px, auto, auto;
}

:root[data-theme="regal"] body {
  background:
    linear-gradient(90deg, rgba(83, 52, 18, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(83, 52, 18, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(201, 147, 56, 0.2), transparent 23rem),
    var(--bg);
  background-size: 38px 38px, 38px 38px, auto, auto;
}

:root[data-theme="scholarly"] body {
  background:
    linear-gradient(90deg, rgba(62, 78, 88, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(62, 78, 88, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(47, 93, 124, 0.08), transparent 20rem),
    var(--bg);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

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

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.landing-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
}

.notebook-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(7rem, 0.72fr) minmax(8rem, 1fr) auto;
  gap: 1rem;
  padding: 1rem;
  color: var(--rail-ink);
  background:
    linear-gradient(180deg, rgba(194, 138, 45, 0.12), transparent 12rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px),
    var(--rail-bg);
  border-right: 1px solid rgba(194, 138, 45, 0.38);
  box-shadow: var(--rail-shadow);
}

.notebook-rail::before,
.notebook-rail::after {
  content: "";
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  height: 2.6rem;
  pointer-events: none;
  border-inline: 1px solid rgba(194, 138, 45, 0.34);
}

.notebook-rail::before {
  top: 0.7rem;
  border-top: 1px solid rgba(194, 138, 45, 0.34);
}

.notebook-rail::after {
  bottom: 0.7rem;
  border-bottom: 1px solid rgba(194, 138, 45, 0.34);
}

.brand {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.7rem;
  padding: 1.1rem 0.8rem 0.8rem;
  color: var(--rail-ink);
  text-align: center;
  text-decoration: none;
}

.brand-mark {
  width: 4.9rem;
  height: 4.9rem;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid rgba(194, 138, 45, 0.68);
  background: #0b1420;
  box-shadow: 0 0 0 6px rgba(194, 138, 45, 0.08), 0 16px 30px rgba(0, 0, 0, 0.26);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.82rem;
  line-height: 1;
  color: #f1c56c;
  font-weight: 500;
}

.brand small,
.context-label,
.field-label,
.cell-kind,
.panel-header p,
.rail-status span,
.detail-row span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand small,
.notebook-rail .rail-status span,
.notebook-rail .notebook-row span {
  color: var(--rail-muted);
}

.rail-actions,
.topbar-actions,
.form-actions,
.cell-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.rail-actions {
  position: relative;
  z-index: 1;
  display: grid;
}

.button,
.version-link {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.88rem;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12)), var(--surface);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.notebook-rail .button {
  color: var(--rail-ink);
  border-color: rgba(194, 138, 45, 0.46);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.12)), var(--rail-panel);
}

.button:hover,
.button:focus-visible,
.version-link:hover,
.version-link:focus-visible {
  border-color: var(--accent-hover);
  outline: none;
}

.button.primary {
  color: var(--accent-ink);
  border-color: rgba(255, 232, 168, 0.34);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.16)), var(--oxblood);
  box-shadow: inset 0 0 0 1px rgba(255, 232, 168, 0.22), 0 10px 20px rgba(143, 37, 31, 0.18);
}

:root[data-theme="scholarly"] .button.primary {
  border-color: rgba(255, 255, 255, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.12)), var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 8px 18px rgba(47, 93, 124, 0.14);
}

.button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.version-link {
  color: var(--ink);
  background: transparent;
}

.notebook-list {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 0.48rem;
  overflow-y: auto;
  padding-right: 0.12rem;
}

.source-scope {
  position: relative;
  z-index: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.55rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(194, 138, 45, 0.2);
}

.source-scope .panel-header.compact {
  align-items: center;
}

.scope-actions,
.studio-controls,
.podcast-controls,
.podcast-player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.source-scope-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 0.45rem;
  overflow-y: auto;
}

.source-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.58rem;
  color: var(--rail-ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 243, 216, 0.16);
  border-radius: var(--radius);
}

.source-check input {
  margin-top: 0.2rem;
}

.source-check span,
.source-check strong,
.source-check small {
  min-width: 0;
  display: block;
}

.source-check small {
  color: var(--rail-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.notebook-row {
  position: relative;
  width: 100%;
  display: grid;
  gap: 0.24rem;
  padding: 0.76rem 0.8rem 0.76rem 2.35rem;
  text-align: left;
  color: var(--rail-ink);
  background: transparent;
  border: 1px solid rgba(194, 138, 45, 0.16);
  border-radius: var(--radius);
  cursor: pointer;
}

.notebook-row::before {
  content: "";
  width: 1.1rem;
  height: 1.35rem;
  position: absolute;
  margin-left: -1.65rem;
  border: 1px solid var(--rail-muted);
  border-left-width: 3px;
  border-radius: 2px;
}

.notebook-row strong,
.notebook-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.notebook-row span {
  font-size: 0.8rem;
}

.notebook-row.is-active {
  border-color: rgba(194, 138, 45, 0.44);
  background: rgba(143, 37, 31, 0.34);
}

.rail-status,
.topbar,
.composer,
.studio-panel,
.cell,
.inspector,
.customization-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rail-status {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.34rem;
  padding: 0.9rem;
  color: var(--rail-ink);
  background: rgba(8, 18, 30, 0.72);
  border-color: rgba(194, 138, 45, 0.28);
}

.rail-status strong {
  font-size: 0.98rem;
}

#api-status.is-live {
  color: #9bd08a;
}

#api-status.is-offline {
  color: #f1a098;
}

.workspace {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--content-gap);
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.68), transparent 26rem),
    repeating-linear-gradient(90deg, rgba(128, 86, 34, 0.035) 0 1px, transparent 1px 34px),
    var(--page);
}

:root[data-theme="scholarly"] .workspace {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), transparent 22rem),
    repeating-linear-gradient(90deg, rgba(62, 78, 88, 0.035) 0 1px, transparent 1px 40px),
    var(--page);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 6.1rem;
  padding: 1rem 1.25rem;
  background: var(--surface-panel);
  border-color: transparent;
  border-bottom-color: var(--line);
  box-shadow: none;
}

.topbar h1,
.panel-header h2,
.cell-title {
  margin: 0;
}

.topbar h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.15rem;
  line-height: 1.1;
  font-weight: 500;
}

.context-label,
.field-label,
.panel-header p,
.cell-kind {
  margin: 0;
}

.topbar .context-label::before,
.topbar .context-label::after,
.panel-header h2::before,
.panel-header h2::after {
  content: "";
  display: inline-block;
  width: 1.6rem;
  height: 1px;
  margin: 0 0.45rem 0.2rem;
  background: var(--gold);
}

.limit-control {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.34rem 0.62rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.limit-control span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.limit-control select {
  min-width: 4.1rem;
  color: var(--ink);
  border: 0;
  background: transparent;
}

.customization-panel[hidden] {
  display: none;
}

.customization-panel {
  position: relative;
  display: grid;
  gap: 0.9rem;
  padding: var(--panel-padding);
  color: var(--rail-ink);
  background:
    linear-gradient(90deg, rgba(194, 138, 45, 0.18), transparent 14rem, transparent calc(100% - 14rem), rgba(194, 138, 45, 0.14)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    #081723;
  border-color: rgba(194, 138, 45, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 230, 164, 0.08), var(--shadow);
}

:root[data-theme="scholarly"] .customization-panel {
  background:
    linear-gradient(90deg, rgba(166, 122, 53, 0.08), transparent 14rem, transparent calc(100% - 14rem), rgba(47, 93, 124, 0.08)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    #25343d;
  border-color: rgba(201, 212, 210, 0.3);
}

.customization-panel::before,
.composer::before,
.inspector::before {
  content: "";
  position: absolute;
  inset: 0.35rem;
  pointer-events: none;
  border: 1px solid rgba(194, 138, 45, 0.28);
  border-radius: calc(var(--radius) - 2px);
}

.customization-panel .panel-header,
.inspector .panel-header {
  position: relative;
  z-index: 1;
}

.customization-panel .panel-header h2,
.customization-panel .panel-header p {
  color: var(--rail-ink);
}

.customization-panel .panel-header p {
  color: #9bd08a;
}

.customization-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.25rem, 1fr));
  gap: 0.72rem;
}

.setting-field,
.toggle-field {
  min-width: 0;
  display: grid;
  gap: 0.46rem;
  padding: 0.72rem;
  color: var(--rail-ink);
  border: 1px solid rgba(194, 138, 45, 0.3);
  border-radius: var(--radius);
  background: rgba(2, 12, 20, 0.48);
}

.setting-field span,
.toggle-field span {
  color: var(--rail-muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.setting-field input,
.setting-field select,
.range-row input {
  width: 100%;
}

.setting-field input:not([type="range"]),
.setting-field select {
  min-height: var(--control-height);
  color: var(--rail-ink);
  border: 1px solid rgba(194, 138, 45, 0.34);
  border-radius: var(--radius);
  background: #0b1a29;
  padding: 0.35rem 0.5rem;
}

.setting-field input:disabled,
.setting-field select:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.setting-field input:not([type="range"])::placeholder {
  color: rgba(217, 185, 120, 0.72);
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 0.55rem;
}

.range-row output {
  color: var(--rail-ink);
  font-weight: 800;
  text-align: right;
}

.swatch-group {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  flex-wrap: wrap;
}

.swatch {
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 2px solid rgba(255, 237, 190, 0.42);
  border-radius: 999px;
  background: var(--accent);
  cursor: pointer;
}

.swatch[aria-checked="true"] {
  border-color: #ffe3a2;
  box-shadow: 0 0 0 3px rgba(194, 138, 45, 0.25);
}

.swatch.is-lapis {
  background: #254c92;
}

.swatch.is-verdigris {
  background: #2f7169;
}

.swatch.is-oxblood {
  background: #8f251f;
}

.swatch.is-gold {
  background: #b8791d;
}

.toggle-field {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  cursor: pointer;
}

.toggle-field > span:last-child {
  font-size: 0.68rem;
}

.toggle-field:hover,
.toggle-field:focus-visible {
  border-color: rgba(255, 226, 166, 0.68);
  outline: none;
}

.switch-track {
  width: 2.35rem;
  height: 1.26rem;
  display: inline-flex;
  align-items: center;
  padding: 0.12rem;
  border: 1px solid rgba(255, 237, 190, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
}

.switch-track span {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  background: #d6c49d;
  transition: transform 140ms ease, background 140ms ease;
}

.toggle-field[aria-checked="true"] .switch-track {
  border-color: #ffe3a2;
  background: rgba(194, 138, 45, 0.2);
}

.toggle-field[aria-checked="true"] .switch-track span {
  transform: translateX(1.05rem);
  background: var(--gold);
}

.native-select-hidden {
  position: absolute;
  width: 1px;
  min-width: 1px;
  height: 1px;
  min-height: 1px;
  overflow: hidden;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.setting-field select.native-select-hidden {
  width: 1px;
  min-width: 1px;
  min-height: 1px;
  padding: 0;
  border: 0;
}

.theme-card-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.6rem, 1fr));
  gap: 0.5rem;
}

.theme-card,
.density-choice,
.scale-step {
  color: var(--rail-ink);
  border: 1px solid rgba(194, 138, 45, 0.34);
  border-radius: var(--radius);
  background: rgba(2, 12, 20, 0.44);
  cursor: pointer;
}

.theme-card {
  min-height: 6.2rem;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.36rem;
  padding: 0.42rem;
}

.theme-preview {
  display: grid;
  place-items: center;
  min-height: 4rem;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.8rem;
  line-height: 1;
  border: 1px solid rgba(194, 138, 45, 0.26);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 248, 232, 0.14), transparent 3rem),
    #0a1a29;
}

.theme-card strong,
.density-choice strong,
.accent-name {
  color: var(--rail-ink);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
}

.theme-card.is-regal .theme-preview {
  color: #9a6b27;
  background:
    radial-gradient(circle at 50% 50%, rgba(201, 149, 56, 0.18), transparent 2.8rem),
    #fff7e5;
}

.theme-card.is-scholarly .theme-preview {
  color: #2f5d7c;
  background:
    linear-gradient(180deg, rgba(47, 93, 124, 0.08), rgba(255, 255, 255, 0)),
    #f8f8f1;
}

.theme-card.is-midnight .theme-preview {
  color: #d8b160;
  background: #081725;
}

.theme-card.is-ember .theme-preview {
  color: #f0bf70;
  background: #4b160f;
}

.theme-card.is-verdant .theme-preview {
  color: #e7c477;
  background: #0f3a31;
}

.theme-card[aria-checked="true"],
.density-choice[aria-checked="true"] {
  border-color: #ffe3a2;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 166, 0.25), 0 0 0 2px rgba(194, 138, 45, 0.18);
}

.density-choice-group {
  display: grid;
  gap: 0.38rem;
}

.density-choice {
  min-height: 2.28rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.48rem;
  padding: 0.42rem 0.56rem;
  text-align: left;
}

.density-choice strong {
  text-align: left;
}

.density-icon {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
  background:
    linear-gradient(currentColor, currentColor) 0 0.18rem / 1rem 1px no-repeat,
    linear-gradient(currentColor, currentColor) 0 0.52rem / 0.75rem 1px no-repeat,
    linear-gradient(currentColor, currentColor) 0 0.86rem / 1rem 1px no-repeat;
  color: var(--rail-muted);
}

.scale-setting .range-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.scale-setting output {
  grid-column: 1 / -1;
  color: var(--rail-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
}

.scale-step {
  width: 1.6rem;
  min-height: 1.6rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--rail-ink);
  border-radius: 999px;
}

.scale-ticks {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  padding-inline: 0.12rem;
}

.scale-ticks span {
  width: 1px;
  height: 0.36rem;
  background: rgba(217, 185, 120, 0.62);
}

.accent-name {
  text-align: left;
}

.composer {
  position: relative;
  padding: 1.55rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0)),
    var(--surface-panel);
}

.composer form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.7rem;
}

.prompt-editor {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  min-height: 8.35rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--input-bg);
}

.prompt-dropcap {
  display: grid;
  place-items: start center;
  padding-top: 0.8rem;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  line-height: 1;
  background:
    linear-gradient(180deg, rgba(194, 138, 45, 0.16), transparent),
    repeating-linear-gradient(135deg, rgba(194, 138, 45, 0.12) 0 1px, transparent 1px 6px);
  border-right: 1px solid var(--line);
}

textarea {
  width: 100%;
  resize: vertical;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--input-bg);
  padding: 0.8rem;
  line-height: 1.5;
}

.prompt-editor textarea {
  min-height: 8.25rem;
  border: 0;
  background: transparent;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.prompt-editor:focus-within {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.prompt-editor textarea:focus {
  outline: none;
}

.studio-panel {
  display: grid;
  gap: 0.78rem;
  padding: var(--panel-padding);
  background: var(--surface-panel);
}

.studio-controls,
.podcast-controls {
  justify-content: flex-start;
}

.podcast-focus {
  min-height: var(--control-height);
  min-width: min(22rem, 100%);
  flex: 1 1 18rem;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.58rem 0.7rem;
}

.podcast-focus:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent-hover);
}

.notebook-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 24rem);
  align-items: start;
  gap: var(--content-gap);
}

.cell-stack {
  display: grid;
  gap: var(--cell-gap);
}

.cell {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  background: var(--surface-panel);
}

.cell.is-active {
  border-color: var(--accent-row);
}

.cell.is-narrating {
  border-color: rgba(194, 138, 45, 0.72);
  box-shadow: var(--shadow), 0 0 0 3px rgba(194, 138, 45, 0.18);
}

.cell-index {
  display: flex;
  align-items: start;
  justify-content: center;
  padding-top: 1rem;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1;
  background: rgba(194, 138, 45, 0.12);
  border-right: 1px solid var(--line);
}

:root[data-theme="scholarly"] .cell-index {
  color: var(--accent);
  background: rgba(47, 93, 124, 0.08);
}

.cell-body {
  display: grid;
  gap: 0.72rem;
  padding: var(--panel-padding);
}

.cell-header,
.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
}

.cell-title {
  font-size: 1rem;
}

.cell-input {
  min-height: 5rem;
}

.cell-output {
  min-height: 4.4rem;
  padding: 0.82rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--output-bg);
}

.answer-text,
.note-output,
.source-output,
.artifact-output,
.source-row p {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.note-output,
.artifact-output {
  white-space: pre-wrap;
  font-family: inherit;
}

.podcast-output {
  display: grid;
  gap: 0.72rem;
}

.podcast-player audio {
  max-width: 100%;
}

.podcast-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.narrator-live-lines {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.8rem;
  padding: 0.75rem;
  background: rgba(255, 250, 239, 0.58);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.narration-line {
  margin: 0;
  padding: 0.45rem 0.55rem;
  color: var(--ink);
  border-left: 3px solid transparent;
  border-radius: calc(var(--radius) - 2px);
}

.narration-line.is-active {
  border-left-color: var(--accent);
  background: rgba(194, 138, 45, 0.16);
}

.compact-sources {
  margin: 0.7rem 0 0;
  padding-left: 1.2rem;
}

.compact-sources li {
  margin-top: 0.35rem;
}

.compact-sources strong,
.compact-sources span {
  display: block;
}

.compact-sources span {
  color: var(--muted);
  font-size: 0.84rem;
}

.status-pill {
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.6rem;
  color: var(--accent);
  border: 1px solid var(--accent-row);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill.is-live,
.status-pill.is-complete {
  color: var(--green);
  border-color: rgba(47, 125, 70, 0.32);
  background: rgba(47, 125, 70, 0.12);
}

.status-pill.is-offline,
.status-pill.is-failed {
  color: var(--oxblood);
  border-color: rgba(143, 37, 31, 0.32);
  background: rgba(143, 37, 31, 0.11);
}

.inspector {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.75rem;
  padding: 1.2rem;
  background: var(--surface-panel);
}

.detail-list,
.source-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.55rem;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, 0.7fr) minmax(0, 1fr);
  gap: 0.55rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.detail-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-row {
  display: grid;
  gap: 0.28rem;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
}

.source-row strong,
.source-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.notebook-rail .empty-state {
  color: var(--rail-muted);
}

.empty-state.is-large {
  padding: 1rem;
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.landing-nav {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.55rem;
}

.nav-button {
  justify-content: start;
}

.landing-workspace {
  gap: 1rem;
}

.landing-topbar .topbar-actions {
  justify-content: end;
}

.landing-hero {
  position: relative;
  min-height: 23rem;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(17rem, 0.95fr);
  align-items: stretch;
  gap: 1rem;
  padding: 1.2rem;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(194, 138, 45, 0.18), transparent 16rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.12)),
    var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.landing-hero::before,
.landing-band::before,
.library-catalog::before,
.reader-panel::before,
.theatre-panel::before {
  content: "";
  position: absolute;
  inset: 0.38rem;
  pointer-events: none;
  border: 1px solid rgba(194, 138, 45, 0.24);
  border-radius: calc(var(--radius) - 2px);
}

.landing-copy {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  gap: 0.9rem;
  padding: 1rem;
}

.landing-copy h2 {
  max-width: 12ch;
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.25rem;
  line-height: 1;
  font-weight: 500;
}

.landing-copy p {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

.hero-sigil {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: 1rem;
  padding: 1rem;
  color: var(--rail-ink);
  background:
    linear-gradient(180deg, rgba(194, 138, 45, 0.18), transparent 13rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px),
    var(--rail-bg);
  border: 1px solid rgba(194, 138, 45, 0.44);
  border-radius: var(--radius);
}

.hero-sigil img {
  width: 100%;
  max-height: 15.5rem;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid rgba(194, 138, 45, 0.64);
  border-radius: var(--radius);
  box-shadow: 0 0 0 7px rgba(194, 138, 45, 0.08), 0 18px 32px rgba(0, 0, 0, 0.28);
}

.landing-stat-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.landing-stat-grid div {
  min-width: 0;
  display: grid;
  gap: 0.26rem;
  padding: 0.72rem;
  border: 1px solid rgba(194, 138, 45, 0.3);
  border-radius: var(--radius);
  background: rgba(2, 12, 20, 0.38);
}

.landing-stat-grid span,
.work-meta,
.work-summary,
.reader-controls span {
  color: var(--muted);
  font-size: 0.78rem;
}

.landing-stat-grid span {
  color: var(--rail-muted);
  font-weight: 800;
  text-transform: uppercase;
}

.landing-stat-grid strong {
  color: var(--rail-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
}

.destination-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--content-gap);
}

.destination-card {
  min-height: 13rem;
  display: grid;
  align-content: space-between;
  gap: 0.85rem;
  padding: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.destination-card:hover,
.destination-card:focus-visible,
.library-work-row:hover,
.library-work-row:focus-visible {
  border-color: var(--accent-hover);
  outline: none;
}

.destination-index {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.destination-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  line-height: 1.08;
  font-weight: 500;
}

.destination-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.destination-card strong {
  color: var(--accent);
}

.landing-band,
.library-catalog,
.reader-panel,
.theatre-panel {
  position: relative;
  display: grid;
  gap: 0.85rem;
  padding: 1.1rem;
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.landing-band .panel-header,
.library-catalog .panel-header,
.reader-panel .panel-header,
.theatre-panel .panel-header,
.version-shelf,
.library-tools,
.library-shelf-modern,
.reader-controls,
.reader-body,
.voice-control-grid,
.reader-grid,
.theatre-layout {
  position: relative;
  z-index: 1;
}

.version-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.48fr) minmax(0, 1.52fr);
  align-items: start;
  gap: var(--content-gap);
}

.library-catalog,
.reader-panel {
  min-height: calc(100vh - 9.3rem);
}

.library-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.72rem;
}

.semantic-search-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.62rem;
}

.semantic-search-field textarea {
  min-height: 5.4rem;
  resize: vertical;
}

.semantic-search-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
}

.semantic-search-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.semantic-results {
  display: grid;
  gap: 0.55rem;
}

.semantic-answer {
  margin: 0;
  padding: 0.78rem 0.84rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--output-bg);
  line-height: 1.48;
}

.semantic-result-list {
  display: grid;
  gap: 0.5rem;
  max-height: 18rem;
  overflow-y: auto;
  padding-right: 0.12rem;
}

.semantic-result {
  width: 100%;
  display: grid;
  gap: 0.28rem;
  padding: 0.72rem 0.78rem;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  cursor: pointer;
}

.semantic-result:hover,
.semantic-result:focus-visible {
  border-color: var(--accent-hover);
  outline: none;
}

.semantic-result-title {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.18;
}

.semantic-result-meta,
.semantic-result-snippet {
  overflow-wrap: anywhere;
}

.semantic-result-action {
  justify-self: start;
  min-height: 1.55rem;
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  color: var(--accent);
  border: 1px solid var(--accent-row);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.canon-reference-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.66rem;
  padding: 0.78rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.canon-reference-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.canon-reference-heading-row h3,
.canon-reference-heading-row p {
  margin: 0;
}

.canon-reference-heading-row h3 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  line-height: 1.18;
}

.canon-reference-heading-row p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

.canon-reference-heading-row span {
  flex: 0 0 auto;
  min-height: 1.45rem;
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.46rem;
  color: var(--accent);
  border: 1px solid var(--accent-row);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.canon-passage-mode {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.42rem;
  padding: 0.22rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--output-bg);
}

.canon-passage-mode label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.canon-passage-mode input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.canon-passage-mode span {
  min-height: 2rem;
  display: grid;
  place-items: center;
  padding: 0.28rem 0.5rem;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
}

.canon-passage-mode input:checked + span {
  color: var(--accent);
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.canon-passage-mode input:focus-visible + span {
  border-color: var(--accent-hover);
  outline: 3px solid var(--accent-soft);
}

.canon-reference-grid {
  display: grid;
  grid-template-columns: minmax(8rem, 1.45fr) minmax(5.2rem, 0.62fr) minmax(5.4rem, 0.62fr) minmax(5.4rem, 0.62fr);
  gap: 0.56rem;
}

.canon-reference-actions {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.canon-reference-results {
  display: grid;
  gap: 0.55rem;
}

.canon-reference-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.78rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--output-bg);
}

.canon-reference-title {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.2;
}

.canon-reference-text {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  line-height: 1.58;
}

.canon-reference-source {
  margin: -0.2rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.35;
  text-transform: uppercase;
}

.book-view-button {
  color: var(--accent);
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.book-viewer[hidden] {
  display: none;
}

.book-view-open {
  overflow: hidden;
}

.book-viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: clamp(0.8rem, 3vw, 2rem);
}

.book-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 11, 0.72);
  backdrop-filter: blur(4px);
}

.book-viewer-shell {
  position: relative;
  width: min(72rem, 100%);
  max-height: min(48rem, calc(100vh - 2rem));
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 0.8rem;
  padding: clamp(0.8rem, 2vw, 1.2rem);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(66, 39, 18, 0.16), transparent 12%, transparent 88%, rgba(66, 39, 18, 0.16)),
    var(--surface);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.48);
}

.book-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0.25rem 0;
}

.book-viewer-header p,
.book-viewer-header h2 {
  margin: 0;
}

.book-viewer-header p {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.book-viewer-header h2 {
  margin-top: 0.16rem;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2.15rem);
  line-height: 1.08;
}

.book-view-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.book-view-navigation[hidden] {
  display: none;
}

.book-view-navigation {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) minmax(8rem, 0.5fr) auto;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 248, 232, 0.56);
}

.book-view-navigation .icon-button {
  width: 2.65rem;
  height: auto;
  min-height: 3.55rem;
  color: var(--accent);
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.book-view-navigation .icon-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.45;
}

.book-view-navigation .setting-field {
  min-width: 0;
  padding: 0.5rem 0.62rem;
}

.book-mark-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.book-mark-toolbar p {
  min-width: 0;
  flex: 1 1 11rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.book-mark-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex: 1 1 16rem;
}

.book-mark-actions .button {
  flex: 1 1 7.25rem;
  min-height: 2.15rem;
  padding-inline: 0.7rem;
}

.book-mark-actions .icon-button {
  width: 2.15rem;
  height: 2.15rem;
}

.book-narrator-button {
  width: 2.45rem;
  height: 2.45rem;
  flex: 0 0 auto;
  color: var(--accent);
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.book-narrator-button.is-reading {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.book-narrator-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.book-narrator-settings {
  position: relative;
  flex: 0 0 auto;
}

.book-narrator-settings-button {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-soft);
}

.book-narrator-settings-button[aria-expanded="true"] {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.book-narrator-settings-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.book-narrator-menu {
  position: absolute;
  z-index: 6;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(13.5rem, calc(100vw - 2rem));
  display: grid;
  gap: 0.55rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.book-narrator-menu[hidden] {
  display: none;
}

.book-narrator-toggle {
  min-height: var(--control-height);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.58rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.book-narrator-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.book-narrator-toggle span {
  line-height: 1.2;
}

.book-narrator-speed span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.book-narrator-speed output {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.book-narrator-speed input[type="range"] {
  width: 100%;
}

.book-spread {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(80, 49, 22, 0.34) 50%, transparent calc(50% + 1px)),
    var(--output-bg);
}

.book-spread.is-narrating .book-page {
  scroll-behavior: smooth;
}

.book-spread.is-reading-along .book-page {
  scroll-padding-block: clamp(7rem, 34vh, 22rem);
}

.book-page {
  min-width: 0;
  min-height: 32rem;
  max-height: calc(100vh - 11rem);
  overflow-y: auto;
  padding: clamp(1rem, 2.3vw, 2rem);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 28%),
    var(--output-bg);
}

.book-page.is-right {
  background:
    linear-gradient(270deg, rgba(255, 255, 255, 0.2), transparent 28%),
    var(--output-bg);
}

.book-scripture-line {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.6rem;
  margin: 0 0 0.7rem;
  padding: 0.2rem 0.25rem;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.56;
  user-select: text;
  cursor: pointer;
  scroll-margin-block: clamp(7rem, 38vh, 24rem);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.book-spread.has-narrator-cursor .book-scripture-line {
  opacity: 0.5;
}

.book-spread.has-narrator-cursor .book-scripture-line:hover,
.book-spread.has-narrator-cursor .book-scripture-line:focus-visible,
.book-spread.has-narrator-cursor .book-scripture-line.is-narrator-cursor {
  opacity: 1;
}

.book-scripture-line.no-marker {
  grid-template-columns: minmax(0, 1fr) auto;
}

.book-scripture-line.is-bookmarked::after {
  content: "";
  position: absolute;
  top: -0.08rem;
  right: 0.36rem;
  width: 0.42rem;
  height: 1.05rem;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  filter: drop-shadow(0 3px 6px rgba(72, 39, 16, 0.22));
}

.book-scripture-line.is-highlighted {
  opacity: 1;
}

.book-scripture-line.highlight-gold {
  border-color: rgba(194, 138, 45, 0.42);
  background:
    linear-gradient(90deg, rgba(255, 226, 129, 0.44), rgba(255, 248, 223, 0.52)),
    var(--surface);
}

.book-scripture-line.highlight-sky {
  border-color: rgba(72, 118, 180, 0.38);
  background:
    linear-gradient(90deg, rgba(163, 205, 246, 0.4), rgba(237, 248, 255, 0.5)),
    var(--surface);
}

.book-scripture-line.highlight-rose {
  border-color: rgba(168, 68, 96, 0.34);
  background:
    linear-gradient(90deg, rgba(244, 177, 195, 0.4), rgba(255, 241, 246, 0.52)),
    var(--surface);
}

.book-scripture-line.highlight-green {
  border-color: rgba(86, 130, 94, 0.36);
  background:
    linear-gradient(90deg, rgba(179, 224, 176, 0.4), rgba(241, 252, 239, 0.52)),
    var(--surface);
}

.book-line-tools {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.book-scripture-line.no-marker .book-line-tools {
  grid-column: 2;
}

.book-scripture-line:hover .book-line-tools,
.book-scripture-line:focus-within .book-line-tools,
.book-scripture-line.is-highlighted .book-line-tools,
.book-scripture-line.is-bookmarked .book-line-tools {
  opacity: 1;
  pointer-events: auto;
}

.book-line-tool,
.book-highlight-swatch {
  width: 1.45rem;
  height: 1.45rem;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.book-line-tool:hover,
.book-line-tool:focus-visible,
.book-highlight-swatch:hover,
.book-highlight-swatch:focus-visible,
.book-line-tool.is-active,
.book-highlight-swatch.is-active {
  color: var(--accent-ink);
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(194, 138, 45, 0.22);
}

.book-line-tool svg {
  width: 0.82rem;
  height: 0.82rem;
}

.book-line-tool.is-bookmark-action.is-active {
  background: var(--accent);
}

.book-highlight-palette {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.book-highlight-swatch {
  width: 1.14rem;
  height: 1.14rem;
  border-color: rgba(0, 0, 0, 0.18);
}

.book-highlight-swatch.is-gold {
  background: #ffe184;
}

.book-highlight-swatch.is-sky {
  background: #a9cff5;
}

.book-highlight-swatch.is-rose {
  background: #f2a9bd;
}

.book-highlight-swatch.is-green {
  background: #abdca6;
}

.book-scripture-line:hover,
.book-scripture-line:focus-visible {
  border-color: var(--accent-row);
  background: var(--accent-soft);
  outline: none;
}

.book-scripture-line.is-narrator-cursor {
  z-index: 1;
  border-color: var(--accent-row);
  outline: 3px solid rgba(194, 138, 45, 0.28);
  outline-offset: 0.12rem;
  background:
    linear-gradient(90deg, rgba(194, 138, 45, 0.22), transparent 86%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 248, 232, 0.64)),
    var(--surface);
  box-shadow:
    0 0 0 2px rgba(194, 138, 45, 0.3),
    0 14px 34px rgba(72, 39, 16, 0.18),
    inset 0.28rem 0 0 var(--accent);
  transform: translateX(0.08rem);
}

.book-spread.is-reading-along .book-scripture-line.is-narrator-cursor {
  opacity: 1;
  box-shadow:
    0 0 0 3px rgba(194, 138, 45, 0.22),
    0 18px 42px rgba(72, 39, 16, 0.22),
    inset 0.32rem 0 0 var(--accent);
}

.book-scripture-line.is-narrator-cursor::before {
  content: "";
  position: absolute;
  left: -0.22rem;
  top: 0.36rem;
  bottom: 0.36rem;
  width: 0.16rem;
  border-radius: 999px;
  background: var(--accent);
}

.book-scripture-line.is-narrator-cursor > span:not(.book-line-tools) {
  display: grid;
  place-items: center;
  width: 1.55rem;
  min-height: 1.55rem;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(72, 39, 16, 0.22);
}

.book-scripture-line > span:not(.book-line-tools) {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.4;
}

.book-scripture-line.is-narrator-cursor strong {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.44);
}

.book-scripture-line strong {
  color: var(--ink);
  font-size: clamp(1rem, 1.6vw, 1.18rem);
  font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
  .book-spread.is-narrating .book-page {
    scroll-behavior: auto;
  }

  .book-scripture-line {
    transition: none;
  }
}

@media (hover: none) {
  .book-line-tools {
    opacity: 1;
    pointer-events: auto;
  }
}

.book-page-empty {
  min-height: 12rem;
  margin: 0;
}

.canon-chapter-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.canon-chapter-header p {
  margin: 0;
}

.canon-chapter-header p:last-child {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.canon-verse-list {
  display: grid;
  gap: 0.36rem;
  max-height: 20rem;
  overflow-y: auto;
  padding-right: 0.1rem;
}

.canon-verse-line {
  width: 100%;
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.58rem;
  align-items: start;
  padding: 0.48rem 0.55rem;
  color: var(--ink);
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  user-select: text;
  cursor: pointer;
}

.canon-verse-line:hover,
.canon-verse-line:focus-visible {
  border-color: var(--accent-row);
  background: var(--accent-soft);
  outline: none;
}

.canon-verse-line span {
  min-height: 1.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  border: 1px solid var(--accent-row);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 900;
}

.canon-verse-line strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.48;
}

.library-filter {
  color: var(--rail-ink);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    #081723;
}

:root[data-theme="scholarly"] .library-filter {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

:root[data-theme="scholarly"] .library-filter span {
  color: var(--muted);
}

:root[data-theme="scholarly"] .library-filter input:not([type="range"]),
:root[data-theme="scholarly"] .library-filter select {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

:root[data-theme="scholarly"] .library-filter input:not([type="range"])::placeholder {
  color: var(--muted);
}

.library-shelf-modern {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  max-height: calc(100vh - 19rem);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.library-work-row {
  width: 100%;
  display: grid;
  gap: 0.34rem;
  padding: 0.85rem 0.9rem;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  cursor: pointer;
}

.library-work-row.is-active {
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.library-work-row:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.work-title {
  min-width: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.work-meta,
.work-summary {
  min-width: 0;
  overflow-wrap: anywhere;
}

.work-summary {
  line-height: 1.42;
}

.reader-controls {
  display: grid;
  grid-template-columns: auto minmax(7rem, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
}

.reader-controls span {
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
}

.reader-body {
  display: grid;
  gap: 0.75rem;
  max-height: calc(100vh - 17.5rem);
  overflow-y: auto;
  padding-right: 0.18rem;
}

.reader-page {
  display: grid;
  gap: 0.45rem;
  padding: 1rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--output-bg);
}

.reader-page p {
  margin: 0;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

:root[data-theme="scholarly"] .reader-page p,
:root[data-theme="scholarly"] .answer-text,
:root[data-theme="scholarly"] .note-output,
:root[data-theme="scholarly"] .source-output {
  line-height: 1.7;
}

.reader-page-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rail-category-list {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 0.38rem;
  overflow-y: auto;
  padding-right: 0.12rem;
}

.category-rail-item {
  min-width: 0;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  padding: 0.48rem 0.65rem;
  color: var(--rail-ink);
  text-align: left;
  border: 1px solid rgba(194, 138, 45, 0.18);
  border-radius: var(--radius);
  background: rgba(8, 18, 30, 0.36);
  cursor: pointer;
}

.category-rail-item:hover,
.category-rail-item:focus-visible,
.category-rail-item.is-active {
  border-color: rgba(194, 138, 45, 0.48);
  background: rgba(143, 37, 31, 0.32);
  outline: none;
}

.work-action {
  justify-self: start;
  min-height: 1.75rem;
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  color: var(--accent);
  border: 1px solid var(--accent-row);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.voice-control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.checkout-controls {
  grid-template-columns: minmax(0, 1fr) auto;
}

.reader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.2rem, 1fr));
  align-items: start;
  gap: 0.7rem;
  max-height: calc(100vh - 18rem);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.reader-empty {
  grid-column: 1 / -1;
}

.checkout-reader {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 0.65rem;
  min-height: 25rem;
  padding: 0.78rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
}

.checkout-reader.is-reading {
  border-color: var(--accent-hover);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.checkout-reader-header,
.reader-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
}

.checkout-reader-header > div {
  min-width: 0;
}

.reader-toolbar {
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.reader-book-title {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.reader-book-meta {
  margin: 0.22rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.reader-scope-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.reader-scope-grid label {
  min-width: 0;
  display: grid;
  gap: 0.24rem;
}

.reader-scope-grid span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.reader-scope-grid input,
.reader-scope-grid select,
.guardian-form input {
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.35rem 0.55rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.reader-scope-grid input:focus,
.reader-scope-grid select:focus,
.guardian-form input:focus {
  border-color: var(--accent-hover);
  outline: 3px solid var(--accent-soft);
}

.icon-button {
  width: 2.35rem;
  height: 2.35rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button:disabled,
.reader-voice:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button:hover,
.icon-button:focus-visible,
.reader-voice:hover,
.reader-voice:focus-visible {
  border-color: var(--accent-hover);
  outline: none;
}

.checkout-reader-body {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  max-height: 22rem;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.theatre-panel {
  margin-top: var(--content-gap);
}

.theatre-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(17rem, 0.65fr);
  gap: 0.85rem;
  align-items: start;
}

.theatre-player {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
}

.theatre-stage {
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #0f171b;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.theatre-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.theatre-playback-actions {
  display: flex;
  justify-content: flex-start;
}

.theatre-watch-link {
  width: fit-content;
  min-height: 2.25rem;
}

.theatre-watch-link:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.guardian-form {
  display: grid;
  gap: 0.55rem;
}

.guardian-result {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.theatre-search-results[hidden] {
  display: none;
}

.theatre-search-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 84%, var(--accent-soft));
}

.theatre-search-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.theatre-search-card p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.theatre-search-kicker {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.compact-sources {
  list-style-position: outside;
}

.compact-source-link {
  width: 100%;
  display: grid;
  gap: 0.18rem;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.compact-source-link:hover strong,
.compact-source-link:focus-visible strong {
  color: var(--accent);
  text-decoration: underline;
}

.compact-source-link:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.source-match-list {
  display: grid;
  gap: 0.55rem;
}

.source-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.source-button.is-selected {
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.selection-capture-panel {
  position: fixed;
  z-index: 10000;
  display: grid;
  gap: 0.45rem;
  min-width: 12rem;
  max-width: min(19rem, calc(100vw - 2rem));
  padding: 0.58rem;
  color: var(--rail-ink);
  background: var(--rail-panel);
  border: 1px solid rgba(194, 138, 45, 0.38);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.selection-capture-panel p {
  margin: 0;
  color: var(--rail-muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.selection-capture-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.selection-capture-option {
  min-height: 2.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.62rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.selection-capture-option:disabled {
  cursor: wait;
  opacity: 0.72;
}

.selection-capture-panel[hidden],
.selection-capture-status[hidden] {
  display: none !important;
}

.selection-capture-status {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10000;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.62rem 0.78rem;
  color: var(--rail-ink);
  background: var(--rail-panel);
  border: 1px solid rgba(194, 138, 45, 0.34);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.source-reader {
  margin-top: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--output-bg);
}

.reader-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--ink);
}

.reader-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.reader-chunks {
  display: grid;
  gap: 0.65rem;
  max-height: 33rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.reader-chunk {
  padding: 0.72rem;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.reader-chunk.is-selected {
  border-color: var(--accent-row);
  background: var(--accent-soft);
}

.reader-chunk p {
  margin: 0;
  color: var(--ink);
  line-height: 1.62;
  font-size: 0.92rem;
}

.reader-chunk-label {
  margin-bottom: 0.45rem !important;
  color: var(--muted) !important;
  font-size: 0.72rem !important;
  font-weight: 900;
  text-transform: uppercase;
}

:root[data-focus-mode="on"] .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

:root[data-focus-mode="on"] .landing-shell {
  grid-template-columns: minmax(0, 1fr);
}

:root[data-focus-mode="on"] .notebook-rail,
:root[data-focus-mode="on"] .inspector {
  display: none;
}

:root[data-focus-mode="on"] .notebook-layout {
  grid-template-columns: minmax(0, 1fr);
}

:root[data-focus-mode="on"] .library-layout {
  grid-template-columns: minmax(0, 1fr);
}

:root[data-theme="regal"] {
  --rail-width: 21.25rem;
  --radius: 4px;
  --bg: #ead7b6;
  --page: #f7ecd4;
  --surface: #fff7e5;
  --surface-soft: #ead7b2;
  --surface-panel: rgba(255, 247, 229, 0.94);
  --rail-bg: #061421;
  --rail-panel: rgba(8, 24, 38, 0.96);
  --input-bg: #fff8e8;
  --output-bg: #f8edd7;
  --active-row: rgba(128, 27, 22, 0.72);
  --ink: #19110b;
  --muted: #6b5231;
  --rail-ink: #fff0cc;
  --rail-muted: #e4bd68;
  --line: rgba(157, 105, 42, 0.3);
  --line-strong: rgba(146, 93, 34, 0.58);
  --gold: #c99538;
  --gold-soft: rgba(201, 149, 56, 0.2);
  --oxblood: #8b2119;
  --lapis: #123b78;
  --verdigris: #23625b;
  --green: #2f803e;
  --accent: #123b78;
  --accent-soft: rgba(18, 59, 120, 0.16);
  --accent-hover: rgba(18, 59, 120, 0.62);
  --accent-row: rgba(18, 59, 120, 0.46);
  --accent-ink: #fff8e8;
  --shadow: 0 12px 24px rgba(52, 33, 13, 0.13);
  --rail-shadow: inset 0 0 0 1px rgba(201, 149, 56, 0.34), 12px 0 30px rgba(2, 7, 12, 0.28);
}

:root[data-theme="regal"] body {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    linear-gradient(90deg, rgba(114, 73, 26, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(114, 73, 26, 0.048) 1px, transparent 1px),
    radial-gradient(circle at 52% 0, rgba(255, 247, 229, 0.92), transparent 31rem),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto;
}

:root[data-theme="regal"] .app-shell,
:root[data-theme="regal"] .landing-shell {
  background: var(--page);
}

:root[data-theme="regal"] .notebook-rail {
  gap: 0.8rem;
  padding: 1.35rem 1.65rem 1.5rem;
  background:
    radial-gradient(circle at 0.8rem 0.8rem, rgba(201, 149, 56, 0.26), transparent 3.8rem),
    radial-gradient(circle at calc(100% - 0.8rem) 0.8rem, rgba(201, 149, 56, 0.22), transparent 3.8rem),
    radial-gradient(circle at 0.8rem calc(100% - 0.8rem), rgba(201, 149, 56, 0.22), transparent 3.8rem),
    radial-gradient(circle at calc(100% - 0.8rem) calc(100% - 0.8rem), rgba(201, 149, 56, 0.2), transparent 3.8rem),
    linear-gradient(180deg, rgba(201, 149, 56, 0.11), transparent 10rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px),
    var(--rail-bg);
  border-right: 2px solid rgba(201, 149, 56, 0.72);
}

:root[data-theme="regal"] .notebook-rail::before {
  inset: 0.62rem;
  height: auto;
  border: 1px solid rgba(201, 149, 56, 0.5);
  border-radius: 2px;
}

:root[data-theme="regal"] .notebook-rail::after {
  inset: 1rem;
  height: auto;
  border: 0;
  background:
    linear-gradient(var(--gold), var(--gold)) left top / 2.8rem 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left top / 1px 2.8rem no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 2.8rem 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 1px 2.8rem no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 2.8rem 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 1px 2.8rem no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 2.8rem 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 1px 2.8rem no-repeat;
  opacity: 0.68;
}

:root[data-theme="regal"] .brand {
  gap: 0.78rem;
  padding: 1.35rem 0.4rem 0.6rem;
}

:root[data-theme="regal"] .brand-mark {
  width: 5.35rem;
  height: 5.35rem;
  border-radius: 7px;
  border-color: rgba(224, 169, 68, 0.82);
  box-shadow: 0 0 0 6px rgba(201, 149, 56, 0.09), 0 18px 30px rgba(0, 0, 0, 0.34);
}

:root[data-theme="regal"] .brand strong {
  color: #f1bf5d;
  font-size: 1.78rem;
  line-height: 0.98;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .brand small {
  margin-top: 0.32rem;
  color: var(--rail-muted);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
}

:root[data-theme="regal"] .brand small::before {
  content: "-- ";
}

:root[data-theme="regal"] .brand small::after {
  content: " --";
}

:root[data-theme="regal"] .rail-actions {
  gap: 0.55rem;
}

:root[data-theme="regal"] .button,
:root[data-theme="regal"] .version-link {
  border-radius: var(--radius);
  font-family: Georgia, "Times New Roman", serif;
  min-height: 2.6rem;
  color: var(--ink);
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.06)),
    var(--surface-panel);
  box-shadow: inset 0 0 0 1px rgba(255, 247, 220, 0.4);
}

:root[data-theme="regal"] .notebook-rail .button {
  color: var(--rail-ink);
  border-color: rgba(201, 149, 56, 0.62);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.16)),
    #0a1a2a;
}

:root[data-theme="regal"] .button.primary,
:root[data-theme="regal"] .notebook-rail .button.primary {
  color: #fff2d2;
  border-color: rgba(224, 169, 68, 0.76);
  background:
    linear-gradient(180deg, rgba(255, 218, 151, 0.15), rgba(58, 9, 6, 0.22)),
    var(--oxblood);
  box-shadow: inset 0 0 0 1px rgba(255, 227, 162, 0.28), 0 8px 18px rgba(74, 18, 13, 0.18);
}

:root[data-theme="regal"] .notebook-list {
  gap: 0;
  padding: 0.32rem 0 0;
}

:root[data-theme="regal"] .notebook-list::before {
  content: "Saved Notebooks";
  display: block;
  margin: 0.4rem 0 0.55rem;
  color: var(--rail-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .notebook-row {
  min-height: 3.58rem;
  padding: 0.72rem 1.55rem 0.68rem 2.55rem;
  border-color: transparent;
  border-bottom-color: rgba(201, 149, 56, 0.22);
  border-radius: 0;
  background: transparent;
}

:root[data-theme="regal"] .notebook-row::before {
  width: 1.15rem;
  height: 1.35rem;
  border-color: #f4d78b;
}

:root[data-theme="regal"] .notebook-row::after {
  content: "...";
  position: absolute;
  right: 0.35rem;
  top: 50%;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.05em;
  transform: translateY(-50%) rotate(90deg);
}

:root[data-theme="regal"] .notebook-row.is-active {
  border-color: rgba(201, 149, 56, 0.54);
  background: var(--active-row);
}

:root[data-theme="regal"] .rail-status {
  grid-template-columns: 1fr;
  gap: 0.45rem;
  padding: 1rem 1.1rem;
  background: rgba(7, 22, 35, 0.82);
  border-color: rgba(201, 149, 56, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 226, 166, 0.08);
}

:root[data-theme="regal"] .workspace {
  gap: 1rem;
  padding: 0 0 1.45rem;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.74), transparent 24rem),
    linear-gradient(90deg, rgba(146, 93, 34, 0.045) 1px, transparent 1px),
    var(--page);
  background-size: auto, 34px 34px, auto;
}

:root[data-theme="regal"] .topbar {
  min-height: 8rem;
  padding: 1.65rem 2.1rem 1.18rem;
  background:
    linear-gradient(180deg, rgba(255, 249, 236, 0.96), rgba(247, 236, 212, 0.96)),
    var(--page);
  border: 0;
  border-bottom: 1px solid rgba(146, 93, 34, 0.42);
  border-radius: 0;
}

:root[data-theme="regal"] .topbar h1 {
  color: #19110b;
  font-size: clamp(2.2rem, 4.2vw, 3.1rem);
  line-height: 0.98;
  letter-spacing: 0;
}

:root[data-theme="regal"] .context-label,
:root[data-theme="regal"] .field-label,
:root[data-theme="regal"] .cell-kind,
:root[data-theme="regal"] .panel-header p,
:root[data-theme="regal"] .rail-status span,
:root[data-theme="regal"] .detail-row span {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.2em;
}

:root[data-theme="regal"] .topbar .context-label::before,
:root[data-theme="regal"] .topbar .context-label::after,
:root[data-theme="regal"] .panel-header h2::before,
:root[data-theme="regal"] .panel-header h2::after {
  width: 2.2rem;
  background: var(--gold);
}

:root[data-theme="regal"] .topbar-actions {
  gap: 0.7rem;
}

:root[data-theme="regal"] .limit-control {
  min-height: 2.72rem;
  color: var(--ink);
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 248, 232, 0.78);
}

:root[data-theme="regal"] .customization-panel,
:root[data-theme="regal"] .composer,
:root[data-theme="regal"] .notebook-layout,
:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .destination-grid,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .library-layout,
:root[data-theme="regal"] .theatre-panel {
  margin-inline: 1.45rem;
}

:root[data-theme="regal"] .customization-panel {
  gap: 0.85rem;
  padding: 1.08rem 1.45rem 1.22rem;
  color: var(--rail-ink);
  background:
    radial-gradient(circle at 100% 0, rgba(201, 149, 56, 0.18), transparent 13rem),
    radial-gradient(circle at 0 100%, rgba(201, 149, 56, 0.12), transparent 12rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 8px),
    #071725;
  border: 1px solid rgba(201, 149, 56, 0.64);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 166, 0.09);
}

:root[data-theme="regal"] .customization-panel::before,
:root[data-theme="regal"] .composer::before,
:root[data-theme="regal"] .inspector::before,
:root[data-theme="regal"] .landing-hero::before,
:root[data-theme="regal"] .landing-band::before,
:root[data-theme="regal"] .library-catalog::before,
:root[data-theme="regal"] .reader-panel::before,
:root[data-theme="regal"] .theatre-panel::before {
  inset: 0.42rem;
  border-color: rgba(201, 149, 56, 0.32);
  border-radius: 0;
}

:root[data-theme="regal"] .customization-panel .panel-header h2 {
  color: #f0bd5c;
  font-size: 0.95rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .customization-panel .panel-header p {
  color: #8fcf73;
  letter-spacing: 0;
  text-transform: none;
}

:root[data-theme="regal"] .customization-grid {
  grid-template-columns: minmax(15rem, 2fr) minmax(10rem, 0.9fr) minmax(13rem, 1.1fr) minmax(11rem, 0.9fr) minmax(10rem, 0.75fr) minmax(10rem, 0.75fr);
  gap: 0.72rem;
}

:root[data-theme="regal"] .setting-field,
:root[data-theme="regal"] .toggle-field {
  padding: 0.78rem;
  color: var(--rail-ink);
  border-color: rgba(201, 149, 56, 0.36);
  border-radius: 0;
  background: rgba(4, 18, 29, 0.72);
}

:root[data-theme="regal"] .theme-setting {
  grid-column: span 2;
}

:root[data-theme="regal"] .setting-field span,
:root[data-theme="regal"] .toggle-field span {
  color: var(--rail-muted);
  letter-spacing: 0.14em;
}

:root[data-theme="regal"] .setting-field select,
:root[data-theme="regal"] .setting-field input:not([type="range"]) {
  border-radius: 0;
  color: var(--rail-ink);
  background: #0a1d2e;
}

:root[data-theme="regal"] .swatch {
  width: 2.05rem;
  height: 2.05rem;
}

:root[data-theme="regal"] .composer {
  padding: 1.55rem 1.7rem;
  background:
    linear-gradient(180deg, rgba(255, 251, 241, 0.68), rgba(255, 251, 241, 0)),
    var(--surface-panel);
  border-color: rgba(201, 149, 56, 0.42);
  border-radius: 0;
}

:root[data-theme="regal"] .field-label {
  display: inline-flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
}

:root[data-theme="regal"] .field-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(201, 149, 56, 0.42);
}

:root[data-theme="regal"] .prompt-editor {
  grid-template-columns: 3.8rem minmax(0, 1fr);
  min-height: 8.6rem;
  border-color: rgba(146, 93, 34, 0.55);
  border-radius: 0;
  background: rgba(255, 250, 238, 0.78);
}

:root[data-theme="regal"] .prompt-dropcap {
  color: var(--lapis);
  font-size: 3.25rem;
  background:
    linear-gradient(180deg, rgba(201, 149, 56, 0.22), transparent),
    repeating-linear-gradient(135deg, rgba(139, 33, 25, 0.16) 0 1px, transparent 1px 6px);
}

:root[data-theme="regal"] textarea {
  border-radius: 0;
}

:root[data-theme="regal"] .form-actions {
  justify-content: space-between;
}

:root[data-theme="regal"] .notebook-layout {
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 23rem);
  align-items: start;
}

:root[data-theme="regal"] .cell {
  grid-template-columns: 3.8rem minmax(0, 1fr);
  min-height: 5.25rem;
  border-color: rgba(201, 149, 56, 0.36);
  border-radius: 0;
  background: rgba(255, 248, 232, 0.82);
  box-shadow: none;
}

:root[data-theme="regal"] .cell-index {
  color: #6f4d23;
  font-size: 1.85rem;
  background: rgba(201, 149, 56, 0.18);
  border-right-color: rgba(201, 149, 56, 0.34);
}

:root[data-theme="regal"] .cell-body {
  gap: 0.72rem;
  padding: 0.85rem 1rem 0.65rem;
}

:root[data-theme="regal"] .cell-title {
  display: none;
}

:root[data-theme="regal"] .cell-input {
  min-height: 3.6rem;
  max-height: 8rem;
  padding: 0.62rem 0.72rem;
  overflow: auto;
  resize: none;
  border: 1px solid rgba(201, 149, 56, 0.22);
  background: rgba(255, 250, 238, 0.6);
}

:root[data-theme="regal"] .cell-output {
  display: block;
  min-height: 4rem;
  padding: 0.78rem;
  border-color: rgba(201, 149, 56, 0.28);
  background: rgba(248, 237, 215, 0.78);
}

:root[data-theme="regal"] .cell-actions {
  gap: 0.48rem;
  flex-wrap: nowrap;
}

:root[data-theme="regal"] .status-pill {
  min-height: 1.55rem;
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  font-size: 0.68rem;
}

:root[data-theme="regal"] .run-cell {
  width: 2.25rem;
  min-height: 2.1rem;
  padding: 0;
  font-size: 0;
}

:root[data-theme="regal"] .run-cell::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 0.38rem solid transparent;
  border-bottom: 0.38rem solid transparent;
  border-left: 0.58rem solid currentColor;
}

:root[data-theme="regal"] .inspector,
:root[data-theme="regal"] .library-catalog,
:root[data-theme="regal"] .reader-panel,
:root[data-theme="regal"] .theatre-panel,
:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .destination-card {
  border-color: rgba(201, 149, 56, 0.42);
  border-radius: 0;
  background: rgba(255, 248, 232, 0.84);
  box-shadow: none;
}

:root[data-theme="regal"] .inspector {
  padding: 1.25rem;
}

:root[data-theme="regal"] .inspector .panel-header,
:root[data-theme="regal"] .library-catalog .panel-header,
:root[data-theme="regal"] .reader-panel .panel-header,
:root[data-theme="regal"] .theatre-panel .panel-header {
  justify-content: center;
  text-align: center;
}

:root[data-theme="regal"] .panel-header h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

:root[data-theme="regal"] .detail-row {
  grid-template-columns: minmax(5rem, 0.8fr) minmax(0, 1fr);
  padding: 0.42rem 0.55rem;
  border: 1px solid rgba(201, 149, 56, 0.22);
  border-bottom: 0;
  background: rgba(255, 248, 232, 0.58);
}

:root[data-theme="regal"] .detail-row:last-child {
  border-bottom: 1px solid rgba(201, 149, 56, 0.22);
}

:root[data-theme="regal"] .source-row,
:root[data-theme="regal"] .library-work-row,
:root[data-theme="regal"] .reader-page,
:root[data-theme="regal"] .checkout-reader,
:root[data-theme="regal"] .reader-chunk {
  border-radius: 0;
  border-color: rgba(201, 149, 56, 0.32);
  background: rgba(255, 250, 238, 0.74);
}

:root[data-theme="regal"] .landing-hero {
  min-height: 22rem;
  margin-top: 0;
  background:
    linear-gradient(90deg, rgba(201, 149, 56, 0.17), transparent 17rem),
    linear-gradient(180deg, rgba(255, 251, 241, 0.66), rgba(255, 251, 241, 0.08)),
    var(--surface-panel);
}

:root[data-theme="regal"] .landing-copy h2 {
  color: var(--ink);
  letter-spacing: 0;
}

:root[data-theme="regal"] .hero-sigil,
:root[data-theme="regal"] .landing-stat-grid div {
  border-radius: 0;
}

:root[data-theme="regal"] .destination-card {
  min-height: 11.5rem;
}

/* Parsed Regal source lock: source image controls and proportions. */
:root[data-theme="regal"] {
  --rail-width: 320px;
  --radius: 3px;
  --gold: #d39a38;
  --oxblood: #8d241c;
  --lapis: #0f3b85;
  --accent: #0f3b85;
  --rail-bg: #061421;
  --rail-panel: #0a1b2b;
  --page: #f7ecd4;
  --surface-panel: rgba(255, 247, 229, 0.9);
}

:root[data-theme="regal"] .app-shell,
:root[data-theme="regal"] .landing-shell {
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
}

:root[data-theme="regal"] .topbar {
  min-height: 128px;
  align-items: center;
}

:root[data-theme="regal"] #customize-toggle[aria-expanded="true"] {
  position: relative;
  color: #f6cd79;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.18)),
    #0b1b2c;
  border-color: rgba(246, 198, 103, 0.8);
  box-shadow: inset 0 0 0 2px rgba(255, 232, 166, 0.28), 0 0 0 3px rgba(11, 27, 44, 0.28);
}

:root[data-theme="regal"] #customize-toggle[aria-expanded="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -26px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 18px solid #0b1b2c;
  transform: translateX(-50%);
}

:root[data-theme="regal"] .customization-panel {
  min-height: 222px;
  padding: 16px 20px;
  background:
    radial-gradient(circle at 0 0, rgba(211, 154, 56, 0.22), transparent 58px),
    radial-gradient(circle at 100% 0, rgba(211, 154, 56, 0.2), transparent 58px),
    radial-gradient(circle at 0 100%, rgba(211, 154, 56, 0.16), transparent 58px),
    radial-gradient(circle at 100% 100%, rgba(211, 154, 56, 0.16), transparent 58px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 8px),
    #071725;
}

:root[data-theme="regal"] .theme-card-group {
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 10px;
}

:root[data-theme="regal"] .theme-card {
  min-height: 104px;
  padding: 6px;
  border-color: rgba(211, 154, 56, 0.36);
  background: rgba(6, 20, 32, 0.82);
}

:root[data-theme="regal"] .theme-preview {
  min-height: 70px;
  font-size: 48px;
  border-color: rgba(211, 154, 56, 0.3);
}

:root[data-theme="regal"] .theme-card[aria-checked="true"]::after,
:root[data-theme="regal"] .density-choice[aria-checked="true"]::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle, #111 0 36%, transparent 38%), #d69c3e;
  border: 1px solid #ffe6a6;
}

:root[data-theme="regal"] .theme-card,
:root[data-theme="regal"] .density-choice {
  position: relative;
}

:root[data-theme="regal"] .cell-stack::before {
  content: "Notebook Cells";
  display: flex;
  border-bottom: 1px solid rgba(211, 154, 56, 0.34);
  padding: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .cell-output {
  display: block;
  border-color: rgba(211, 154, 56, 0.28);
  background: rgba(248, 237, 215, 0.78);
}

:root[data-theme="regal"] .cell-title {
  display: block;
}

:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .destination-card,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .library-catalog,
:root[data-theme="regal"] .reader-panel,
:root[data-theme="regal"] .theatre-panel,
:root[data-theme="regal"] .checkout-reader,
:root[data-theme="regal"] .reader-chunk,
:root[data-theme="regal"] .reader-page {
  border-color: rgba(211, 154, 56, 0.42);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.55), rgba(255, 252, 241, 0.05)),
    rgba(255, 247, 229, 0.86);
  box-shadow: none;
}

:root[data-theme="regal"] .theme-card-group {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 79px;
  justify-content: start;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

:root[data-theme="regal"] .theme-card-group::-webkit-scrollbar {
  display: none;
}

:root[data-theme="regal"] .theme-card.is-scholarly,
:root[data-theme="regal"] .theme-card.is-nature,
:root[data-theme="regal"] .theme-card.is-cosmic {
  display: grid;
}

/* Additional global themes requested after the Regal source lock. */
:root[data-theme="nature"] {
  color-scheme: light;
  --bg: #e7efdf;
  --page: #f5f4df;
  --surface: #fffbea;
  --surface-soft: #dce9cf;
  --surface-panel: rgba(255, 251, 234, 0.96);
  --rail-bg: #123221;
  --rail-panel: rgba(22, 61, 40, 0.96);
  --input-bg: #fffdf1;
  --output-bg: #eef4df;
  --active-row: rgba(82, 116, 49, 0.2);
  --ink: #172316;
  --muted: #5a6f46;
  --rail-ink: #f8f0c9;
  --rail-muted: #c9d68a;
  --line: rgba(83, 111, 50, 0.23);
  --line-strong: rgba(83, 111, 50, 0.42);
  --gold: #b98f2c;
  --gold-soft: rgba(185, 143, 44, 0.16);
  --oxblood: #7b322a;
  --lapis: #2f5f7d;
  --verdigris: #2f7258;
  --green: #2f7d46;
  --accent: #4d7d39;
  --accent-soft: rgba(77, 125, 57, 0.14);
  --accent-hover: rgba(77, 125, 57, 0.46);
  --accent-row: rgba(77, 125, 57, 0.38);
  --accent-ink: #fffbea;
  --shadow: 0 18px 42px rgba(34, 67, 40, 0.13);
  --rail-shadow: inset 0 0 0 1px rgba(201, 214, 138, 0.16), 10px 0 32px rgba(16, 38, 26, 0.16);
}

:root[data-theme="cosmic"] {
  color-scheme: dark;
  --bg: #06070e;
  --page: #0d1020;
  --surface: #15192c;
  --surface-soft: #10182b;
  --surface-panel: rgba(17, 22, 39, 0.96);
  --rail-bg: #050814;
  --rail-panel: rgba(12, 18, 35, 0.98);
  --input-bg: #090d1a;
  --output-bg: #11172a;
  --active-row: rgba(197, 153, 68, 0.17);
  --ink: #f8f0d8;
  --muted: #b7bfd8;
  --rail-ink: #f9eecf;
  --rail-muted: #c5cce8;
  --line: rgba(202, 211, 244, 0.18);
  --line-strong: rgba(202, 211, 244, 0.34);
  --gold: #c99a3d;
  --gold-soft: rgba(201, 154, 61, 0.18);
  --oxblood: #8a3342;
  --lapis: #5269d4;
  --verdigris: #3f9c9a;
  --green: #5ba870;
  --accent: #7b8ee8;
  --accent-soft: rgba(123, 142, 232, 0.17);
  --accent-hover: rgba(123, 142, 232, 0.52);
  --accent-row: rgba(123, 142, 232, 0.42);
  --accent-ink: #fff8e6;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.38);
  --rail-shadow: inset 0 0 0 1px rgba(201, 154, 61, 0.16), 12px 0 34px rgba(0, 0, 0, 0.35);
}

:root[data-theme="cosmic"] body {
  background:
    radial-gradient(circle at 18% 14%, rgba(123, 142, 232, 0.14), transparent 12rem),
    radial-gradient(circle at 78% 18%, rgba(63, 156, 154, 0.1), transparent 14rem),
    linear-gradient(90deg, rgba(201, 154, 61, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(123, 142, 232, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 36px 36px, 36px 36px, auto;
}

:root[data-theme="nature"] .workspace {
  background:
    linear-gradient(180deg, rgba(255, 253, 239, 0.78), transparent 22rem),
    repeating-linear-gradient(90deg, rgba(77, 125, 57, 0.04) 0 1px, transparent 1px 40px),
    var(--page);
}

:root[data-theme="cosmic"] .workspace {
  background:
    radial-gradient(circle at 84% 10%, rgba(123, 142, 232, 0.12), transparent 18rem),
    radial-gradient(circle at 20% 18%, rgba(201, 154, 61, 0.08), transparent 13rem),
    repeating-linear-gradient(90deg, rgba(202, 211, 244, 0.035) 0 1px, transparent 1px 40px),
    var(--page);
}

:root[data-theme="nature"] .customization-panel {
  background:
    linear-gradient(90deg, rgba(185, 143, 44, 0.12), transparent 14rem, transparent calc(100% - 14rem), rgba(77, 125, 57, 0.12)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    #153824;
  border-color: rgba(201, 214, 138, 0.34);
}

:root[data-theme="cosmic"] .customization-panel {
  background:
    radial-gradient(circle at 10% 0%, rgba(123, 142, 232, 0.16), transparent 11rem),
    radial-gradient(circle at 90% 10%, rgba(201, 154, 61, 0.12), transparent 10rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px),
    #080d1b;
  border-color: rgba(201, 154, 61, 0.3);
}

.theme-card.is-nature .theme-preview {
  color: #d8c678;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 251, 234, 0.22), transparent 2.6rem),
    linear-gradient(135deg, rgba(77, 125, 57, 0.64), rgba(18, 50, 33, 0.96));
}

.theme-card.is-cosmic .theme-preview {
  color: #f1d27b;
  background:
    radial-gradient(circle at 24% 26%, rgba(255, 244, 200, 0.95) 0 0.08rem, transparent 0.1rem),
    radial-gradient(circle at 72% 34%, rgba(123, 142, 232, 0.9) 0 0.08rem, transparent 0.1rem),
    radial-gradient(circle at 48% 70%, rgba(63, 156, 154, 0.78) 0 0.08rem, transparent 0.1rem),
    linear-gradient(135deg, #050814, #151b38 54%, #2a2344);
}

:root[data-theme="regal"] .theme-card-group {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 79px;
  justify-content: start;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

:root[data-theme="regal"] .theme-card-group::-webkit-scrollbar {
  display: none;
}

:root[data-theme="regal"] .theme-card.is-scholarly,
:root[data-theme="regal"] .theme-card.is-nature,
:root[data-theme="regal"] .theme-card.is-cosmic {
  display: grid;
}

:root[data-theme="regal"] .library-filter,
:root[data-theme="regal"] .category-rail-item,
:root[data-theme="regal"] .guardian-form input,
:root[data-theme="regal"] .reader-scope-grid input,
:root[data-theme="regal"] .reader-scope-grid select,
:root[data-theme="regal"] .library-work-row,
:root[data-theme="regal"] .source-row,
:root[data-theme="regal"] .icon-button {
  border-color: rgba(211, 154, 56, 0.34);
  border-radius: 0;
}

:root[data-theme="regal"] .library-filter,
:root[data-theme="regal"] .category-rail-item {
  color: var(--rail-ink);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.024) 0 1px, transparent 1px 8px),
    rgba(7, 21, 33, 0.72);
}

:root[data-theme="regal"] .library-work-row,
:root[data-theme="regal"] .reader-page,
:root[data-theme="regal"] .checkout-reader,
:root[data-theme="regal"] .reader-chunk {
  background: rgba(255, 250, 238, 0.76);
}

:root[data-theme="regal"] .theatre-stage {
  border: 1px solid rgba(211, 154, 56, 0.42);
  border-radius: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.024) 0 1px, transparent 1px 8px),
    #071725;
}

:root[data-theme="regal"] .theatre-stage iframe {
  border: 1px solid rgba(211, 154, 56, 0.34);
}

:root[data-theme="regal"] .panel-header h2,
:root[data-theme="regal"] .destination-card h2,
:root[data-theme="regal"] .work-title,
:root[data-theme="regal"] .reader-book-title,
:root[data-theme="regal"] .landing-copy h2 {
  font-family: Georgia, "Times New Roman", serif;
}

:root[data-theme="regal"] .status-pill,
:root[data-theme="regal"] .work-action {
  border-radius: 3px;
}

:root[data-theme="regal"] .button,
:root[data-theme="regal"] .version-link,
:root[data-theme="regal"] .limit-control,
:root[data-theme="regal"] .icon-button {
  border-color: rgba(145, 88, 28, 0.54);
}

:root[data-theme="regal"] .button:hover,
:root[data-theme="regal"] .button:focus-visible,
:root[data-theme="regal"] .version-link:hover,
:root[data-theme="regal"] .version-link:focus-visible,
:root[data-theme="regal"] .library-work-row:hover,
:root[data-theme="regal"] .library-work-row:focus-visible {
  border-color: rgba(211, 154, 56, 0.72);
  outline-color: rgba(211, 154, 56, 0.22);
}

@media (min-width: 1280px) {
  :root[data-theme="regal"] .customization-grid {
    grid-template-columns: minmax(310px, 2fr) minmax(140px, 0.8fr) minmax(220px, 1.15fr) minmax(170px, 0.9fr) minmax(190px, 0.95fr);
    grid-template-rows: minmax(70px, 1fr) minmax(70px, 1fr);
  }

  :root[data-theme="regal"] .theme-setting {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  :root[data-theme="regal"] .density-setting {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  :root[data-theme="regal"] .scale-setting {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  :root[data-theme="regal"] .accent-setting {
    grid-column: 4;
    grid-row: 1 / span 2;
  }

  :root[data-theme="regal"] .contrast-setting {
    grid-column: 5;
    grid-row: 1;
  }

  :root[data-theme="regal"] .focus-setting {
    grid-column: 5;
    grid-row: 2;
  }
}

@media (max-width: 1240px) {
  .customization-grid {
    grid-template-columns: repeat(3, minmax(12rem, 1fr));
  }
}

@media (max-width: 1040px) {
  .app-shell,
  .landing-shell {
    grid-template-columns: 1fr;
  }

  .notebook-rail {
    position: relative;
    height: auto;
    grid-template-rows: auto;
  }

  .notebook-list {
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    max-height: 16rem;
  }

  .brand {
    justify-items: start;
    grid-template-columns: auto minmax(0, 1fr);
    text-align: left;
  }

  .landing-hero,
  .library-layout {
    grid-template-columns: 1fr;
  }

  .library-catalog,
  .reader-panel,
  .theatre-panel {
    min-height: 0;
  }

  .library-shelf-modern,
  .reader-body,
  .reader-grid {
    max-height: none;
  }
}

@media (max-width: 860px) {
  .topbar,
  .cell-header,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .customization-grid {
    grid-template-columns: repeat(2, minmax(12rem, 1fr));
  }

  .destination-grid,
  .library-tools,
  .canon-reference-grid,
  .book-spread,
  .theatre-layout {
    grid-template-columns: 1fr;
  }

  .book-spread {
    background: var(--output-bg);
  }

  .landing-copy h2 {
    font-size: 2.45rem;
  }

  .inspector {
    position: relative;
    top: 0;
  }
}

@media (min-width: 861px) and (max-width: 1120px) {
  .destination-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workspace,
  .notebook-rail {
    padding: 0.75rem;
  }

  .rail-actions,
  .topbar-actions,
  .form-actions,
  .canon-reference-heading-row,
  .cell-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .version-link,
  .limit-control {
    width: 100%;
  }

  .hero-actions,
  .version-shelf {
    align-items: stretch;
    flex-direction: column;
  }

  .customization-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero,
  .landing-band,
  .library-catalog,
  .reader-panel,
  .theatre-panel {
    padding: 0.75rem;
  }

  .landing-copy {
    padding: 0.45rem;
  }

  .landing-copy h2 {
    font-size: 2.1rem;
  }

  .landing-stat-grid,
  .canon-passage-mode,
  .reader-controls,
  .voice-control-grid,
  .reader-scope-grid,
  .theatre-layout {
    grid-template-columns: 1fr;
  }

  .book-viewer {
    padding: 0.55rem;
  }

  .book-view-navigation {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .book-view-book-field,
  .book-view-chapter-field {
    grid-column: 2;
  }

  .book-view-navigation #book-view-next-chapter {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .book-view-navigation #book-view-prev-chapter {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .book-page {
    min-height: 18rem;
    max-height: 34vh;
    padding: 1rem;
  }

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

  .prompt-dropcap {
    display: none;
  }

  .cell {
    grid-template-columns: 2.6rem minmax(0, 1fr);
  }
}

@media (max-width: 1500px) {
  :root[data-theme="regal"] .customization-grid {
    grid-template-columns: repeat(3, minmax(11.5rem, 1fr));
  }
}

@media (max-width: 1120px) {
  :root[data-theme="regal"] .topbar-actions {
    justify-content: flex-start;
  }

  :root[data-theme="regal"] .customization-panel,
  :root[data-theme="regal"] .composer,
  :root[data-theme="regal"] .notebook-layout,
  :root[data-theme="regal"] .landing-hero,
  :root[data-theme="regal"] .destination-grid,
  :root[data-theme="regal"] .landing-band,
  :root[data-theme="regal"] .library-layout,
  :root[data-theme="regal"] .theatre-panel {
    margin-inline: 1rem;
  }
}

@media (max-width: 760px) {
  :root[data-theme="regal"] .customization-grid {
    grid-template-columns: 1fr;
  }

  :root[data-theme="regal"] .theme-setting {
    grid-column: auto;
  }

  :root[data-theme="regal"] .topbar {
    padding: 1.25rem 1rem 1rem;
  }

  :root[data-theme="regal"] .notebook-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Regal source lock: match the supplied reference image without simplifying it. */
:root[data-theme="regal"] {
  --rail-width: 320px;
  --radius: 3px;
  --bg: #e8d6b5;
  --page: #f7ecd4;
  --surface: #fff7e7;
  --surface-panel: rgba(255, 247, 229, 0.9);
  --rail-bg: #061421;
  --rail-panel: #0a1b2b;
  --ink: #17100b;
  --muted: #6e502f;
  --rail-ink: #fff1cc;
  --rail-muted: #dcae50;
  --line: rgba(156, 99, 35, 0.28);
  --line-strong: rgba(145, 88, 28, 0.54);
  --gold: #d39a38;
  --oxblood: #8d241c;
  --lapis: #0f3b85;
  --accent: #0f3b85;
  --accent-soft: rgba(15, 59, 133, 0.15);
  --accent-hover: rgba(15, 59, 133, 0.58);
  --accent-row: rgba(15, 59, 133, 0.42);
  --green: #2e7f38;
  --shadow: none;
}

:root[data-theme="regal"] body {
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 252, 240, 0.82), transparent 30rem),
    linear-gradient(90deg, rgba(118, 72, 22, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(118, 72, 22, 0.045) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 34px 34px, 34px 34px, auto;
}

:root[data-theme="regal"] .app-shell,
:root[data-theme="regal"] .landing-shell {
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  background: var(--page);
}

:root[data-theme="regal"] .notebook-rail {
  gap: 13px;
  padding: 12px 14px;
  background:
    radial-gradient(circle at 18px 18px, rgba(211, 154, 56, 0.28), transparent 44px),
    radial-gradient(circle at calc(100% - 18px) 18px, rgba(211, 154, 56, 0.22), transparent 44px),
    radial-gradient(circle at 18px calc(100% - 18px), rgba(211, 154, 56, 0.22), transparent 44px),
    radial-gradient(circle at calc(100% - 18px) calc(100% - 18px), rgba(211, 154, 56, 0.2), transparent 44px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, #071522, #03111d);
  border-right: 2px solid rgba(211, 154, 56, 0.62);
  box-shadow: inset 0 0 0 1px rgba(211, 154, 56, 0.24), 10px 0 30px rgba(7, 11, 15, 0.22);
}

:root[data-theme="regal"] .notebook-rail::before {
  inset: 8px;
  border: 1px solid rgba(211, 154, 56, 0.5);
  border-radius: 0;
}

:root[data-theme="regal"] .notebook-rail::after {
  inset: 14px;
  background:
    linear-gradient(var(--gold), var(--gold)) left top / 44px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left top / 1px 44px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 44px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 1px 44px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 44px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 1px 44px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 44px 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 1px 44px no-repeat;
  opacity: 0.78;
}

:root[data-theme="regal"] .brand {
  gap: 10px;
  padding: 38px 12px 10px;
}

:root[data-theme="regal"] .brand-mark {
  width: 82px;
  height: 82px;
  border-radius: 7px;
  border: 1px solid rgba(233, 178, 69, 0.86);
  box-shadow: 0 0 0 7px rgba(211, 154, 56, 0.08), 0 14px 26px rgba(0, 0, 0, 0.34);
}

:root[data-theme="regal"] .brand strong {
  color: #f0bd5c;
  font-size: 28px;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

:root[data-theme="regal"] .brand small {
  color: var(--rail-muted);
  font-size: 12px;
  letter-spacing: 0.2em;
}

:root[data-theme="regal"] .rail-actions {
  gap: 10px;
  padding-inline: 22px;
}

:root[data-theme="regal"] .notebook-rail .button {
  min-height: 38px;
  border-color: rgba(211, 154, 56, 0.52);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.13)),
    #0a1a2b;
}

:root[data-theme="regal"] .notebook-rail .button.primary,
:root[data-theme="regal"] .button.primary {
  background:
    linear-gradient(180deg, rgba(255, 218, 151, 0.16), rgba(52, 9, 5, 0.22)),
    #8d241c;
  border-color: rgba(211, 154, 56, 0.7);
  color: #fff3d5;
}

:root[data-theme="regal"] .notebook-list::before {
  margin: 7px 20px 10px;
  border-block: 1px solid rgba(211, 154, 56, 0.22);
  padding-block: 6px;
  color: var(--rail-muted);
  letter-spacing: 0.22em;
}

:root[data-theme="regal"] .notebook-row {
  min-height: 56px;
  padding: 9px 24px 9px 54px;
}

:root[data-theme="regal"] .notebook-row.is-active {
  background: rgba(132, 31, 25, 0.78);
}

:root[data-theme="regal"] .rail-status {
  margin: auto 16px 22px;
  min-height: 96px;
  padding: 14px 18px;
  border-color: rgba(211, 154, 56, 0.42);
  background: rgba(8, 22, 35, 0.84);
}

:root[data-theme="regal"] .workspace {
  gap: 14px;
  padding: 0 0 24px;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.68), transparent 25rem),
    linear-gradient(90deg, rgba(145, 88, 28, 0.042) 1px, transparent 1px),
    var(--page);
  background-size: auto, 34px 34px, auto;
}

:root[data-theme="regal"] .topbar {
  min-height: 128px;
  padding: 28px 34px 18px;
  align-items: center;
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.96), rgba(247, 236, 212, 0.96)),
    var(--page);
  border-bottom: 1px solid rgba(145, 88, 28, 0.42);
  border-radius: 0;
}

:root[data-theme="regal"] .topbar h1 {
  font-size: clamp(36px, 3vw, 42px);
  line-height: 1;
}

:root[data-theme="regal"] .topbar-actions {
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

:root[data-theme="regal"] .topbar .button,
:root[data-theme="regal"] .topbar .version-link,
:root[data-theme="regal"] .limit-control {
  min-height: 44px;
  padding-inline: 18px;
  border-radius: 6px;
  background: rgba(255, 247, 229, 0.72);
}

:root[data-theme="regal"] #customize-toggle[aria-expanded="true"] {
  position: relative;
  color: #f6cd79;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.18)),
    #0b1b2c;
  border-color: rgba(246, 198, 103, 0.8);
  box-shadow: inset 0 0 0 2px rgba(255, 232, 166, 0.28), 0 0 0 3px rgba(11, 27, 44, 0.28);
}

:root[data-theme="regal"] #customize-toggle[aria-expanded="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -26px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 18px solid #0b1b2c;
  transform: translateX(-50%);
}

:root[data-theme="regal"] .customization-panel,
:root[data-theme="regal"] .composer,
:root[data-theme="regal"] .notebook-layout,
:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .destination-grid,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .library-layout,
:root[data-theme="regal"] .theatre-panel {
  margin-inline: 20px;
}

:root[data-theme="regal"] .customization-panel {
  min-height: 222px;
  gap: 12px;
  padding: 16px 20px;
  background:
    radial-gradient(circle at 0 0, rgba(211, 154, 56, 0.22), transparent 58px),
    radial-gradient(circle at 100% 0, rgba(211, 154, 56, 0.2), transparent 58px),
    radial-gradient(circle at 0 100%, rgba(211, 154, 56, 0.16), transparent 58px),
    radial-gradient(circle at 100% 100%, rgba(211, 154, 56, 0.16), transparent 58px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 8px),
    #071725;
  border: 1px solid rgba(211, 154, 56, 0.68);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 166, 0.08);
}

:root[data-theme="regal"] .customization-panel::before {
  inset: 8px;
  border-color: rgba(211, 154, 56, 0.34);
}

:root[data-theme="regal"] .customization-panel .panel-header {
  align-items: center;
}

:root[data-theme="regal"] .customization-panel .panel-header h2 {
  color: #f2bd5e;
  font-size: 13px;
  letter-spacing: 0.28em;
}

:root[data-theme="regal"] .customization-panel .panel-header .button {
  min-height: 34px;
  color: #f2bd5e;
  border-color: rgba(211, 154, 56, 0.48);
  background: #0b1b2c;
}

:root[data-theme="regal"] .customization-grid {
  grid-template-columns: minmax(310px, 2fr) minmax(140px, 0.8fr) minmax(220px, 1.15fr) minmax(170px, 0.9fr) minmax(190px, 0.95fr);
  grid-template-rows: minmax(70px, 1fr) minmax(70px, 1fr);
  gap: 10px;
  align-items: stretch;
}

:root[data-theme="regal"] .theme-setting {
  grid-column: 1;
  grid-row: 1 / span 2;
}

:root[data-theme="regal"] .density-setting {
  grid-column: 2;
  grid-row: 1 / span 2;
}

:root[data-theme="regal"] .scale-setting {
  grid-column: 3;
  grid-row: 1 / span 2;
}

:root[data-theme="regal"] .accent-setting {
  grid-column: 4;
  grid-row: 1 / span 2;
}

:root[data-theme="regal"] .contrast-setting {
  grid-column: 5;
  grid-row: 1;
}

:root[data-theme="regal"] .focus-setting {
  grid-column: 5;
  grid-row: 2;
}

:root[data-theme="regal"] .setting-field,
:root[data-theme="regal"] .toggle-field {
  padding: 11px;
  border-color: rgba(211, 154, 56, 0.34);
  background: rgba(5, 20, 32, 0.72);
}

:root[data-theme="regal"] .setting-field > span,
:root[data-theme="regal"] .toggle-field > span:last-child {
  color: var(--rail-muted);
  font-size: 11px;
  letter-spacing: 0.18em;
}

:root[data-theme="regal"] .theme-card-group {
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 10px;
}

:root[data-theme="regal"] .theme-card {
  min-height: 104px;
  padding: 6px;
  border-color: rgba(211, 154, 56, 0.36);
  background: rgba(6, 20, 32, 0.82);
}

:root[data-theme="regal"] .theme-preview {
  min-height: 70px;
  font-size: 48px;
  border-color: rgba(211, 154, 56, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 236, 178, 0.08);
}

:root[data-theme="regal"] .theme-preview::before,
:root[data-theme="regal"] .theme-preview::after {
  content: "";
  position: absolute;
}

:root[data-theme="regal"] .theme-card .theme-preview {
  position: relative;
}

:root[data-theme="regal"] .theme-card.is-regal .theme-preview {
  color: #a86f25;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 251, 235, 0.78), transparent 40px),
    linear-gradient(135deg, rgba(211, 154, 56, 0.2), transparent 35%),
    #fbefd5;
}

:root[data-theme="regal"] .theme-card.is-midnight .theme-preview {
  color: #dec16d;
  background:
    radial-gradient(circle at 50% 50%, rgba(211, 154, 56, 0.12), transparent 38px),
    #061522;
}

:root[data-theme="regal"] .theme-card.is-ember .theme-preview {
  color: #efc56b;
  background:
    radial-gradient(circle at 50% 50%, rgba(211, 154, 56, 0.12), transparent 38px),
    #4a170e;
}

:root[data-theme="regal"] .theme-card.is-verdant .theme-preview {
  color: #e8c878;
  background:
    radial-gradient(circle at 50% 50%, rgba(211, 154, 56, 0.12), transparent 38px),
    #153b33;
}

:root[data-theme="regal"] .theme-card[aria-checked="true"] {
  border-color: #ffe39a;
  box-shadow: inset 0 0 0 2px rgba(255, 226, 166, 0.28);
}

:root[data-theme="regal"] .theme-card[aria-checked="true"]::after,
:root[data-theme="regal"] .density-choice[aria-checked="true"]::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle, #111 0 36%, transparent 38%), #d69c3e;
  border: 1px solid #ffe6a6;
}

:root[data-theme="regal"] .theme-card,
:root[data-theme="regal"] .density-choice {
  position: relative;
}

:root[data-theme="regal"] .density-choice-group {
  gap: 7px;
}

:root[data-theme="regal"] .density-choice {
  min-height: 34px;
  border-color: rgba(211, 154, 56, 0.34);
  background: rgba(7, 21, 33, 0.75);
}

:root[data-theme="regal"] .scale-setting .range-row {
  align-content: center;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
}

:root[data-theme="regal"] .scale-setting output {
  order: -1;
  grid-column: 1 / -1;
  margin-bottom: 8px;
  font-size: 17px;
}

:root[data-theme="regal"] .scale-step {
  width: 24px;
  min-height: 24px;
  color: #d9b978;
  background: #0b1b2c;
}

:root[data-theme="regal"] input[type="range"] {
  accent-color: #d39a38;
}

:root[data-theme="regal"] .swatch {
  width: 32px;
  height: 32px;
  border-color: rgba(255, 231, 166, 0.5);
}

:root[data-theme="regal"] .swatch[aria-checked="true"] {
  border-color: #ffe39a;
  box-shadow: 0 0 0 3px rgba(211, 154, 56, 0.28);
}

:root[data-theme="regal"] .switch-track {
  width: 38px;
  height: 22px;
  background: rgba(255, 255, 255, 0.12);
}

:root[data-theme="regal"] .composer {
  padding: 22px 28px;
  border-color: rgba(211, 154, 56, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 252, 242, 0.72), rgba(255, 252, 242, 0.08)),
    rgba(255, 247, 229, 0.82);
}

:root[data-theme="regal"] .prompt-editor {
  min-height: 132px;
}

:root[data-theme="regal"] .prompt-dropcap {
  font-size: 56px;
  color: #153d81;
}

:root[data-theme="regal"] .form-actions {
  justify-content: space-between;
}

:root[data-theme="regal"] .notebook-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
}

:root[data-theme="regal"] .cell-stack::before {
  content: "Notebook Cells";
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .cell-stack::before {
  border-bottom: 1px solid rgba(211, 154, 56, 0.34);
  padding: 0 0 10px;
}

:root[data-theme="regal"] .cell {
  min-height: 84px;
  grid-template-columns: 52px minmax(0, 1fr);
  background: rgba(255, 247, 229, 0.72);
}

:root[data-theme="regal"] .cell-body {
  padding: 12px 14px;
  gap: 4px;
}

:root[data-theme="regal"] .cell-input {
  min-height: 28px;
  max-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

:root[data-theme="regal"] .cell-output {
  display: none;
}

:root[data-theme="regal"] .inspector {
  top: 16px;
  padding: 22px 18px;
}

:root[data-theme="regal"] .detail-row {
  min-height: 30px;
}

@media (min-width: 1280px) {
  :root[data-theme="regal"] .topbar-actions {
    flex-wrap: nowrap;
  }
}

@media (max-width: 1279px) {
  :root[data-theme="regal"] .topbar {
    min-height: 128px;
    padding: 22px 24px 16px;
    overflow: visible;
  }

  :root[data-theme="regal"] .topbar h1 {
    font-size: clamp(30px, 3.2vw, 36px);
  }

  :root[data-theme="regal"] .topbar-actions {
    gap: 8px;
    flex-wrap: wrap;
    transform: none;
  }

  :root[data-theme="regal"] .customization-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  :root[data-theme="regal"] .theme-setting,
  :root[data-theme="regal"] .density-setting,
  :root[data-theme="regal"] .scale-setting,
  :root[data-theme="regal"] .accent-setting,
  :root[data-theme="regal"] .contrast-setting,
  :root[data-theme="regal"] .focus-setting {
    grid-column: auto;
    grid-row: auto;
  }

  :root[data-theme="regal"] .theme-setting {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1040px) {
  :root[data-theme="regal"] .app-shell,
  :root[data-theme="regal"] .landing-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root[data-theme="regal"] .customization-grid {
    grid-template-columns: 1fr;
  }

  :root[data-theme="regal"] .theme-card-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Regal concept source lock.
   This final block is intentionally last so the provided concept image controls
   the selected Regal theme without earlier responsive overrides drifting it. */
:root[data-theme="regal"] {
  color-scheme: light;
  --rail-width: 340px;
  --control-height: 46px;
  --panel-padding: 0;
  --content-gap: 20px;
  --cell-gap: 10px;
  --radius: 0;
  --bg: #eadbbd;
  --page: #f6ecd2;
  --surface: #fff8e8;
  --surface-soft: #ead9b4;
  --surface-panel: rgba(255, 248, 232, 0.88);
  --rail-bg: #061522;
  --rail-panel: #0b1c2d;
  --input-bg: #fffaf0;
  --output-bg: #f7ecd6;
  --active-row: rgba(133, 34, 27, 0.86);
  --ink: #17100b;
  --muted: #755532;
  --rail-ink: #fff0c4;
  --rail-muted: #d8ae57;
  --line: rgba(145, 92, 31, 0.26);
  --line-strong: rgba(145, 92, 31, 0.54);
  --gold: #d39a38;
  --gold-soft: rgba(211, 154, 56, 0.2);
  --oxblood: #8d241c;
  --lapis: #123f8c;
  --verdigris: #1c6a63;
  --green: #2e8b43;
  --accent: #123f8c;
  --accent-soft: rgba(18, 63, 140, 0.13);
  --accent-hover: rgba(18, 63, 140, 0.58);
  --accent-row: rgba(18, 63, 140, 0.42);
  --accent-ink: #fff4d1;
  --shadow: none;
  --rail-shadow: inset -1px 0 0 rgba(211, 154, 56, 0.5), 10px 0 26px rgba(0, 0, 0, 0.18);
}

:root[data-theme="regal"] body {
  min-width: 1600px;
  color: var(--ink);
  background: var(--page);
  font-family: Georgia, "Times New Roman", serif;
}

:root[data-theme="regal"] .app-shell,
:root[data-theme="regal"] .landing-shell {
  min-width: 1600px;
  grid-template-columns: 340px minmax(1260px, 1fr);
  background: var(--page);
}

:root[data-theme="regal"] .notebook-rail {
  width: 340px;
  height: 100vh;
  grid-template-rows: 178px auto auto 1fr auto;
  gap: 13px;
  padding: 20px 34px 28px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025), transparent 16px, transparent calc(100% - 16px), rgba(255, 255, 255, 0.022)),
    radial-gradient(circle at 14px 14px, rgba(211, 154, 56, 0.22), transparent 70px),
    radial-gradient(circle at calc(100% - 14px) 14px, rgba(211, 154, 56, 0.2), transparent 70px),
    radial-gradient(circle at 14px calc(100% - 14px), rgba(211, 154, 56, 0.16), transparent 70px),
    radial-gradient(circle at calc(100% - 14px) calc(100% - 14px), rgba(211, 154, 56, 0.16), transparent 70px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 7px),
    var(--rail-bg);
  border-right: 1px solid rgba(211, 154, 56, 0.64);
  box-shadow: var(--rail-shadow);
}

:root[data-theme="regal"] .notebook-rail::before,
:root[data-theme="regal"] .notebook-rail::after {
  left: 13px;
  right: 13px;
  height: 50px;
  border-color: rgba(211, 154, 56, 0.62);
}

:root[data-theme="regal"] .notebook-rail::before {
  top: 12px;
}

:root[data-theme="regal"] .notebook-rail::after {
  bottom: 12px;
}

:root[data-theme="regal"] .brand {
  gap: 13px;
  padding: 30px 0 8px;
}

:root[data-theme="regal"] .brand-mark {
  width: 84px;
  height: 84px;
  border: 1px solid rgba(249, 202, 104, 0.88);
  border-radius: 8px;
  box-shadow: 0 0 0 6px rgba(8, 20, 32, 0.72), 0 0 0 7px rgba(211, 154, 56, 0.38);
}

:root[data-theme="regal"] .brand strong {
  color: #f1c76c;
  font-size: 31px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .brand small {
  color: #d9b467;
  font-size: 14px;
  letter-spacing: 0.22em;
}

:root[data-theme="regal"] .brand small::before,
:root[data-theme="regal"] .brand small::after {
  content: "--";
  padding-inline: 6px;
}

:root[data-theme="regal"] .rail-actions {
  gap: 10px;
}

:root[data-theme="regal"] .notebook-rail .button {
  min-height: 39px;
  width: 100%;
  padding: 0 15px;
  color: #fff1cb;
  border: 1px solid rgba(211, 154, 56, 0.68);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.18)),
    #102033;
  box-shadow: inset 0 0 0 1px rgba(255, 232, 170, 0.12);
  font-size: 16px;
}

:root[data-theme="regal"] .notebook-rail .button.primary {
  background:
    linear-gradient(180deg, rgba(255, 226, 160, 0.12), rgba(0, 0, 0, 0.2)),
    var(--oxblood);
  border-color: rgba(255, 207, 128, 0.72);
}

:root[data-theme="regal"] .notebook-list {
  gap: 0;
  padding-top: 27px;
}

:root[data-theme="regal"] .source-scope {
  display: none;
}

:root[data-theme="regal"] .notebook-list::before {
  content: "Saved Notebooks";
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
  margin-bottom: 10px;
  color: #e4b75d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .notebook-row {
  min-height: 56px;
  padding: 11px 18px 11px 52px;
  border: 0;
  border-bottom: 1px solid rgba(211, 154, 56, 0.22);
  color: #fff1cc;
  background: transparent;
  font-size: 16px;
}

:root[data-theme="regal"] .notebook-row.is-active {
  border: 1px solid rgba(211, 154, 56, 0.62);
  background: var(--active-row);
}

:root[data-theme="regal"] .notebook-row span {
  color: #efd39b;
  font-size: 12px;
}

:root[data-theme="regal"] .rail-status {
  gap: 10px;
  min-height: 112px;
  padding: 18px;
  border: 1px solid rgba(211, 154, 56, 0.42);
  background: rgba(8, 20, 32, 0.86);
  box-shadow: inset 0 0 0 1px rgba(255, 232, 166, 0.08);
}

:root[data-theme="regal"] .workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 354px;
  grid-auto-rows: auto;
  column-gap: 24px;
  row-gap: 20px;
  align-content: start;
  padding: 0 20px 28px;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.62), transparent 250px),
    repeating-linear-gradient(90deg, rgba(126, 88, 35, 0.035) 0 1px, transparent 1px 34px),
    var(--page);
}

:root[data-theme="regal"] .customization-panel,
:root[data-theme="regal"] .composer,
:root[data-theme="regal"] .notebook-layout,
:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .destination-grid,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .library-layout,
:root[data-theme="regal"] .theatre-panel {
  margin-inline: 0;
}

:root[data-theme="regal"] .topbar {
  grid-column: 1 / -1;
  height: 130px;
  min-height: 130px;
  margin: 0 -20px -20px;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 26px 28px 16px 38px;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid rgba(145, 92, 31, 0.42);
  background: transparent;
}

:root[data-theme="regal"] .topbar h1 {
  max-width: 540px;
  margin-top: 8px;
  color: #17100b;
  font-size: 42px;
  line-height: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme="regal"] .context-label,
:root[data-theme="regal"] .field-label,
:root[data-theme="regal"] .cell-kind,
:root[data-theme="regal"] .panel-header p,
:root[data-theme="regal"] .rail-status span,
:root[data-theme="regal"] .detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .topbar .context-label {
  color: #4a3926;
  letter-spacing: 0.26em;
}

:root[data-theme="regal"] .topbar-actions {
  flex-wrap: nowrap;
  justify-content: end;
  gap: 12px;
  transform: none;
}

:root[data-theme="regal"] .topbar-actions #run-notebook ~ a.version-link[href="./library.html"],
:root[data-theme="regal"] .topbar-actions #run-notebook ~ a.version-link[href="./index.html"] {
  display: none;
}

:root[data-theme="regal"] .topbar-actions #run-notebook ~ a.version-link[href="../v7/notebook.html"] {
  min-width: 64px;
  font-size: 0;
}

:root[data-theme="regal"] .topbar-actions #run-notebook ~ a.version-link[href="../v7/notebook.html"]::before {
  content: "< V4";
  font-size: 16px;
}

:root[data-theme="regal"] .limit-control,
:root[data-theme="regal"] .topbar .button,
:root[data-theme="regal"] .topbar .version-link {
  min-height: 46px;
  border: 1px solid rgba(177, 116, 45, 0.68);
  border-radius: 5px;
  background: rgba(255, 248, 232, 0.72);
  color: #17100b;
  box-shadow: none;
  font-size: 16px;
}

:root[data-theme="regal"] .limit-control {
  gap: 14px;
  padding: 0 14px;
}

:root[data-theme="regal"] .limit-control span {
  color: #17100b;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

:root[data-theme="regal"] .topbar .button {
  padding: 0 20px;
}

:root[data-theme="regal"] #customize-toggle[aria-expanded="true"] {
  min-width: 152px;
  color: #f5c45f;
  border-color: rgba(246, 198, 103, 0.86);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.2)),
    #0b1b2c;
  box-shadow: inset 0 0 0 2px rgba(255, 232, 166, 0.28), 0 0 0 3px rgba(11, 27, 44, 0.28);
}

:root[data-theme="regal"] #customize-toggle[aria-expanded="true"]::after {
  bottom: -28px;
  border-left-width: 15px;
  border-right-width: 15px;
  border-top: 19px solid #0b1b2c;
}

:root[data-theme="regal"] #run-notebook,
:root[data-theme="regal"] .form-actions .button.primary {
  color: #fff5d5;
  border-color: rgba(255, 213, 132, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 226, 160, 0.12), rgba(0, 0, 0, 0.18)),
    var(--oxblood);
  box-shadow: inset 0 0 0 1px rgba(255, 226, 160, 0.18), 0 8px 18px rgba(83, 17, 13, 0.18);
}

:root[data-theme="regal"] .customization-panel {
  grid-column: 1 / -1;
  min-height: 225px;
  height: 225px;
  padding: 16px 28px 16px;
  gap: 10px;
  overflow: visible;
  color: #fff1cc;
  border: 1px solid rgba(211, 154, 56, 0.58);
  border-radius: 0;
  background:
    radial-gradient(circle at 0 0, rgba(211, 154, 56, 0.24), transparent 62px),
    radial-gradient(circle at 100% 0, rgba(211, 154, 56, 0.22), transparent 62px),
    radial-gradient(circle at 0 100%, rgba(211, 154, 56, 0.18), transparent 62px),
    radial-gradient(circle at 100% 100%, rgba(211, 154, 56, 0.18), transparent 62px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 8px),
    #071725;
  box-shadow: inset 0 0 0 1px rgba(255, 230, 164, 0.08);
}

:root[data-theme="regal"] .customization-panel::before {
  inset: 8px;
  border-color: rgba(211, 154, 56, 0.32);
  border-radius: 0;
}

:root[data-theme="regal"] .customization-panel .panel-header {
  position: relative;
  z-index: 1;
  min-height: 32px;
  align-items: start;
}

:root[data-theme="regal"] .customization-panel .panel-header h2 {
  margin-left: 10px;
  color: #f0bd5c;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .customization-panel .panel-header p {
  position: absolute;
  top: 2px;
  right: 235px;
  color: #8fcf73;
  letter-spacing: 0;
  text-transform: none;
}

:root[data-theme="regal"] .customization-panel .panel-header .button {
  min-height: 34px;
  min-width: 184px;
  padding: 0 16px;
  color: #f4c76b;
  border-color: rgba(211, 154, 56, 0.62);
  background: rgba(9, 25, 40, 0.9);
}

:root[data-theme="regal"] .customization-grid {
  grid-template-columns: 370px 148px 210px 170px 205px;
  grid-template-rows: 75px 75px;
  gap: 12px;
  align-items: stretch;
}

:root[data-theme="regal"] .theme-setting {
  grid-column: 1;
  grid-row: 1 / 3;
}

:root[data-theme="regal"] .density-setting {
  grid-column: 2;
  grid-row: 1 / 3;
}

:root[data-theme="regal"] .scale-setting {
  grid-column: 3;
  grid-row: 1 / 3;
}

:root[data-theme="regal"] .accent-setting {
  grid-column: 4;
  grid-row: 1 / 3;
}

:root[data-theme="regal"] .contrast-setting {
  grid-column: 5;
  grid-row: 1;
}

:root[data-theme="regal"] .focus-setting {
  grid-column: 5;
  grid-row: 2;
}

:root[data-theme="regal"] .setting-field,
:root[data-theme="regal"] .toggle-field {
  min-height: 0;
  padding: 10px 12px;
  border: 1px solid rgba(211, 154, 56, 0.34);
  border-radius: 0;
  background: rgba(5, 19, 31, 0.78);
}

:root[data-theme="regal"] .setting-field > span,
:root[data-theme="regal"] .toggle-field > span:last-child {
  color: #d9ad58;
  font-size: 12px;
  letter-spacing: 0.18em;
}

:root[data-theme="regal"] .toggle-field {
  grid-template-columns: 26px minmax(0, 1fr) 36px;
  align-items: center;
  padding: 0 10px;
}

:root[data-theme="regal"] .toggle-field::before {
  content: "";
  width: 22px;
  height: 22px;
  border: 1px solid rgba(217, 185, 120, 0.72);
  border-radius: 50%;
  box-shadow:
    0 -6px 0 -5px #d9b978,
    0 6px 0 -5px #d9b978,
    -6px 0 0 -5px #d9b978,
    6px 0 0 -5px #d9b978;
}

:root[data-theme="regal"] .focus-setting::before {
  border-radius: 2px;
  transform: rotate(45deg);
  box-shadow: none;
}

:root[data-theme="regal"] .toggle-field .switch-track {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

:root[data-theme="regal"] .toggle-field > span:last-child {
  grid-column: 2;
  grid-row: 1;
  color: #fff1cc;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

:root[data-theme="regal"] .theme-card.is-scholarly {
  display: none;
}

:root[data-theme="regal"] .theme-card-group {
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

:root[data-theme="regal"] .theme-card {
  min-height: 110px;
  padding: 6px;
  border: 1px solid rgba(211, 154, 56, 0.42);
  background: rgba(6, 20, 32, 0.86);
}

:root[data-theme="regal"] .theme-preview {
  min-height: 70px;
  color: #e5c66f;
  font-size: 48px;
  border: 1px solid rgba(211, 154, 56, 0.34);
  background: #061522;
}

:root[data-theme="regal"] .theme-card.is-regal .theme-preview {
  color: #a86f25;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 251, 235, 0.78), transparent 40px),
    linear-gradient(135deg, rgba(211, 154, 56, 0.22), transparent 35%),
    #fbefd5;
}

:root[data-theme="regal"] .theme-card strong {
  color: #fff1cc;
  font-size: 12px;
}

:root[data-theme="regal"] .density-choice-group {
  gap: 7px;
}

:root[data-theme="regal"] .density-choice {
  min-height: 34px;
  padding: 7px 9px;
  border-color: rgba(211, 154, 56, 0.38);
  background: rgba(7, 21, 33, 0.78);
}

:root[data-theme="regal"] .scale-setting .range-row {
  align-content: center;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
}

:root[data-theme="regal"] .scale-setting output {
  order: -1;
  grid-column: 1 / -1;
  margin-bottom: 8px;
  color: #fff1cc;
  font-size: 18px;
}

:root[data-theme="regal"] .scale-step {
  width: 24px;
  min-height: 24px;
  color: #d9b978;
  background: #0b1b2c;
}

:root[data-theme="regal"] input[type="range"] {
  accent-color: #d39a38;
}

:root[data-theme="regal"] .swatch {
  width: 34px;
  height: 34px;
  border-color: rgba(255, 231, 166, 0.5);
}

:root[data-theme="regal"] .swatch[aria-checked="true"] {
  border-color: #ffe39a;
  box-shadow: 0 0 0 3px rgba(211, 154, 56, 0.28);
}

:root[data-theme="regal"] .switch-track {
  width: 36px;
  height: 22px;
  background: rgba(255, 255, 255, 0.12);
}

:root[data-theme="regal"] .composer {
  grid-column: 1;
  grid-row: 3;
  align-self: start;
  height: 258px;
  min-height: 258px;
  padding: 24px 28px 18px;
  border: 1px solid rgba(211, 154, 56, 0.34);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 242, 0.72), rgba(255, 252, 242, 0.08)),
    rgba(255, 247, 229, 0.82);
}

:root[data-theme="regal"] .composer::before,
:root[data-theme="regal"] .inspector::before,
:root[data-theme="regal"] .landing-hero::before,
:root[data-theme="regal"] .landing-band::before,
:root[data-theme="regal"] .library-catalog::before,
:root[data-theme="regal"] .reader-panel::before,
:root[data-theme="regal"] .theatre-panel::before {
  inset: 8px;
  border-color: rgba(211, 154, 56, 0.28);
  border-radius: 0;
}

:root[data-theme="regal"] .field-label {
  color: var(--muted);
}

:root[data-theme="regal"] .prompt-editor {
  grid-template-columns: 54px minmax(0, 1fr);
  min-height: 132px;
  border-color: rgba(145, 92, 31, 0.54);
  border-radius: 0;
  background: rgba(255, 250, 238, 0.78);
}

:root[data-theme="regal"] .prompt-dropcap {
  color: var(--lapis);
  font-size: 56px;
  background:
    linear-gradient(180deg, rgba(211, 154, 56, 0.18), transparent),
    repeating-linear-gradient(135deg, rgba(139, 33, 25, 0.16) 0 1px, transparent 1px 6px);
}

:root[data-theme="regal"] textarea {
  border-radius: 0;
}

:root[data-theme="regal"] .form-actions {
  justify-content: space-between;
}

:root[data-theme="regal"] .notebook-layout {
  display: contents;
}

:root[data-theme="regal"] .cell-stack {
  grid-column: 1;
  grid-row: 4;
  gap: 10px;
}

:root[data-theme="regal"] .cell-stack::before {
  content: "Notebook Cells";
  display: flex;
  align-items: center;
  min-height: 26px;
  padding: 0 0 8px;
  border-bottom: 1px solid rgba(211, 154, 56, 0.34);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

:root[data-theme="regal"] .cell {
  min-height: 104px;
  grid-template-columns: 52px minmax(0, 1fr);
  border-color: rgba(211, 154, 56, 0.34);
  border-radius: 0;
  background: rgba(255, 247, 229, 0.72);
  box-shadow: none;
}

:root[data-theme="regal"] .cell-index {
  color: #4d3217;
  font-size: 28px;
  background: rgba(211, 154, 56, 0.13);
  border-right-color: rgba(211, 154, 56, 0.28);
}

:root[data-theme="regal"] .cell-body {
  padding: 12px 14px;
  gap: 4px;
}

:root[data-theme="regal"] .cell-title {
  display: block;
}

:root[data-theme="regal"] .cell-input {
  min-height: 28px;
  max-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

:root[data-theme="regal"] .cell-output {
  display: none;
}

:root[data-theme="regal"] .cell-actions {
  flex-wrap: nowrap;
}

:root[data-theme="regal"] .status-pill {
  min-height: 23px;
  padding: 2px 9px;
  border-radius: 3px;
  font-size: 11px;
}

:root[data-theme="regal"] .run-cell {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 0;
}

:root[data-theme="regal"] .run-cell::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

:root[data-theme="regal"] .inspector {
  grid-column: 2;
  grid-row: 3 / span 2;
  position: sticky;
  top: 16px;
  min-height: 600px;
  padding: 22px 18px;
  border: 1px solid rgba(211, 154, 56, 0.34);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 242, 0.68), rgba(255, 252, 242, 0.08)),
    rgba(255, 247, 229, 0.78);
  box-shadow: none;
}

:root[data-theme="regal"] .inspector .panel-header,
:root[data-theme="regal"] .library-catalog .panel-header,
:root[data-theme="regal"] .reader-panel .panel-header,
:root[data-theme="regal"] .theatre-panel .panel-header {
  justify-content: center;
  text-align: center;
}

:root[data-theme="regal"] .panel-header h2 {
  color: #17100b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
}

:root[data-theme="regal"] .detail-row {
  grid-template-columns: minmax(92px, 0.8fr) minmax(0, 1fr);
  min-height: 30px;
  padding: 6px 8px;
  border: 1px solid rgba(211, 154, 56, 0.22);
  border-bottom: 0;
  background: rgba(255, 248, 232, 0.58);
}

:root[data-theme="regal"] .detail-row:last-child {
  border-bottom: 1px solid rgba(211, 154, 56, 0.22);
}

:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .destination-grid,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .library-layout {
  grid-column: 1 / -1;
}

:root[data-theme="regal"] .landing-hero,
:root[data-theme="regal"] .destination-card,
:root[data-theme="regal"] .landing-band,
:root[data-theme="regal"] .library-catalog,
:root[data-theme="regal"] .reader-panel,
:root[data-theme="regal"] .theatre-panel,
:root[data-theme="regal"] .checkout-reader,
:root[data-theme="regal"] .reader-chunk,
:root[data-theme="regal"] .reader-page {
  border-color: rgba(211, 154, 56, 0.42);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.55), rgba(255, 252, 241, 0.05)),
    rgba(255, 247, 229, 0.86);
  box-shadow: none;
}

:root[data-theme="regal"] .theme-card-group {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 78px;
  justify-content: start;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

:root[data-theme="regal"] .theme-card-group::-webkit-scrollbar {
  display: none;
}

:root[data-theme="regal"] .theme-card.is-scholarly,
:root[data-theme="regal"] .theme-card.is-nature,
:root[data-theme="regal"] .theme-card.is-cosmic {
  display: grid;
}

/* Final Regal concept lock: these rules intentionally sit last. */
:root[data-theme="regal"] .notebook-row {
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
  gap: 2px;
  min-height: 54px;
  max-height: 58px;
  overflow: hidden;
}

:root[data-theme="regal"] .notebook-row strong,
:root[data-theme="regal"] .notebook-row span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  white-space: nowrap;
}

:root[data-theme="regal"] .swatch-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

:root[data-theme="regal"] .swatch {
  flex: 0 0 34px;
}

:root[data-theme="regal"] .focus-setting {
  height: 88px;
  margin-top: -13px;
  border-top: 0;
}

:root[data-theme="regal"] .cell-stack {
  margin-top: -96px;
}

:root[data-theme="regal"] .topbar-actions #run-notebook ~ a.version-link[href="../v7/notebook.html"]::before {
  content: "← V4";
}

/* V8 Library layout repair: keep the concept styling, but remove fixed-width overflow. */
:root[data-theme="regal"] body {
  min-width: 320px;
  overflow-x: hidden;
}

:root[data-theme="regal"] .app-shell,
:root[data-theme="regal"] .landing-shell {
  min-width: 0;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

:root[data-theme="regal"] .notebook-rail {
  width: auto;
}

:root[data-theme="regal"] .library-rail {
  grid-template-rows: auto auto minmax(13rem, 1fr) auto;
  min-height: 100vh;
  overflow: hidden;
}

:root[data-theme="regal"] .library-rail .brand {
  gap: 8px;
  padding: 24px 0 6px;
}

:root[data-theme="regal"] .library-rail .brand-mark {
  width: 76px;
  height: 76px;
}

:root[data-theme="regal"] .library-rail .brand strong {
  font-size: 27px;
}

:root[data-theme="regal"] .library-rail .brand small {
  font-size: 12px;
}

:root[data-theme="regal"] .library-rail .rail-category-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

:root[data-theme="regal"] .library-rail .rail-status {
  min-height: 82px;
  margin: 0;
  padding: 12px 14px;
}

:root[data-theme="regal"] .library-workspace {
  min-width: 0;
}

:root[data-theme="regal"] .library-layout {
  min-width: 0;
  grid-template-columns: minmax(30rem, 1.05fr) minmax(22rem, 0.95fr);
  align-items: start;
}

:root[data-theme="regal"] .library-catalog,
:root[data-theme="regal"] .reader-panel,
:root[data-theme="regal"] .semantic-search-panel,
:root[data-theme="regal"] .canon-reference-panel {
  min-width: 0;
}

:root[data-theme="regal"] .reader-panel {
  min-height: 0;
}

:root[data-theme="regal"] .semantic-search-actions,
:root[data-theme="regal"] .canon-reference-actions {
  min-width: 0;
}

:root[data-theme="regal"] .canon-reference-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.7fr) minmax(0, 0.75fr) minmax(0, 0.75fr);
}

:root[data-theme="regal"] .canon-reference-grid .setting-field {
  min-width: 0;
}

:root[data-theme="regal"] .canon-reference-grid .setting-field > span {
  line-height: 1.15;
  overflow-wrap: anywhere;
}

@media (max-width: 1500px) {
  :root[data-theme="regal"] .canon-reference-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1240px) {
  :root[data-theme="regal"] .library-layout {
    grid-template-columns: 1fr;
  }

  :root[data-theme="regal"] .reader-panel {
    min-height: 0;
  }
}

@media (max-width: 1040px) {
  :root[data-theme="regal"] .app-shell,
  :root[data-theme="regal"] .landing-shell {
    grid-template-columns: 1fr;
  }

  :root[data-theme="regal"] .notebook-rail,
  :root[data-theme="regal"] .library-rail {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    grid-template-rows: auto auto minmax(10rem, 16rem) auto;
  }

  :root[data-theme="regal"] .library-rail .rail-category-list {
    max-height: 16rem;
  }

  :root[data-theme="regal"] .workspace {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 14px 22px;
  }

  :root[data-theme="regal"] .topbar {
    height: auto;
    min-height: 0;
    margin: 0;
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 760px) {
  :root[data-theme="regal"] .canon-reference-grid,
  :root[data-theme="regal"] .voice-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :root[data-theme="regal"] .semantic-search-actions,
  :root[data-theme="regal"] .canon-reference-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  :root[data-theme="regal"] .canon-reference-grid,
  :root[data-theme="regal"] .voice-control-grid {
    grid-template-columns: 1fr;
  }
}
