/* DW2 workspace: original interface styling, with compact application chrome. */
:root {
  --ink: #25272a;
  --muted: #686c72;
  --canvas: #eef0f2;
  --chrome: #e3e5e8;
  --surface: #fff;
  --surface-soft: #f5f5f6;
  --line: #d5d7db;
  --line-light: #e9eaec;
  --accent: #343a43;
  --accent-soft: #eef0f3;
  --focus: #336bb0;
  --danger: #a43737;
  --warning: #886222;
  --success: #386b4b;
  --shadow: 0 1px 2px rgb(20 25 32 / 4%);
  --radius: 5px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color-scheme: light;
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  /* Palette: every other colour in this file, one variable each so the dark theme can remap it.
     Light values are the original colours; add new colours here (with a dark value below), not inline. */
  --c-111111: #111111;
  --c-1d426f: #1d426f;
  --c-222222: #222222;
  --c-22252a: #22252a;
  --c-262c35: #262c35;
  --c-293545: #293545;
  --c-2b2f35: #2b2f35;
  --c-2b313a: #2b313a;
  --c-2b6468: #2b6468;
  --c-2c5b8a: #2c5b8a;
  --c-2d3540: #2d3540;
  --c-2e3742: #2e3742;
  --c-2e3d50: #2e3d50;
  --c-2f4968: #2f4968;
  --c-2f6a43: #2f6a43;
  --c-303946: #303946;
  --c-303a48: #303a48;
  --c-333d4b: #333d4b;
  --c-34383e: #34383e;
  --c-343a43: #343a43;
  --c-344053: #344053;
  --c-354254: #354254;
  --c-363f4c: #363f4c;
  --c-365d8a: #365d8a;
  --c-383e47: #383e47;
  --c-394554: #394554;
  --c-3a4656: #3a4656;
  --c-3b414b: #3b414b;
  --c-3b4553: #3b4553;
  --c-3d4c60: #3d4c60;
  --c-424750: #424750;
  --c-424b57: #424b57;
  --c-445569: #445569;
  --c-454b55: #454b55;
  --c-476a52: #476a52;
  --c-477254: #477254;
  --c-494d53: #494d53;
  --c-496078: #496078;
  --c-4a525c: #4a525c;
  --c-4a5666: #4a5666;
  --c-4b525b: #4b525b;
  --c-4d5867: #4d5867;
  --c-515b6b: #515b6b;
  --c-526175: #526175;
  --c-566070: #566070;
  --c-566b83: #566b83;
  --c-59606a: #59606a;
  --c-5b4290: #5b4290;
  --c-5c636c: #5c636c;
  --c-5c6878: #5c6878;
  --c-5e6268: #5e6268;
  --c-60656d: #60656d;
  --c-616d7c: #616d7c;
  --c-62666e: #62666e;
  --c-62676f: #62676f;
  --c-626b78: #626b78;
  --c-626c7a: #626c7a;
  --c-626d7c: #626d7c;
  --c-626e7e: #626e7e;
  --c-637083: #637083;
  --c-637569: #637569;
  --c-646d79: #646d79;
  --c-657286: #657286;
  --c-666666: #666666;
  --c-687381: #687381;
  --c-687483: #687483;
  --c-687b92: #687b92;
  --c-69717c: #69717c;
  --c-697483: #697483;
  --c-6a7078: #6a7078;
  --c-6a717b: #6a717b;
  --c-6a727d: #6a727d;
  --c-6a737f: #6a737f;
  --c-6b7e96: #6b7e96;
  --c-6c747f: #6c747f;
  --c-6c7683: #6c7683;
  --c-6f3f80: #6f3f80;
  --c-6f747c: #6f747c;
  --c-6f7681: #6f7681;
  --c-707681: #707681;
  --c-717985: #717985;
  --c-727780: #727780;
  --c-727882: #727882;
  --c-727b87: #727b87;
  --c-737e8c: #737e8c;
  --c-747982: #747982;
  --c-747d88: #747d88;
  --c-758396: #758396;
  --c-76859b: #76859b;
  --c-777c84: #777c84;
  --c-77818f: #77818f;
  --c-778290: #778290;
  --c-77879d: #77879d;
  --c-7a622e: #7a622e;
  --c-7a8089: #7a8089;
  --c-7a818a: #7a818a;
  --c-7a818b: #7a818b;
  --c-7b8490: #7b8490;
  --c-7b8592: #7b8592;
  --c-7c8da0: #7c8da0;
  --c-7d5a12: #7d5a12;
  --c-7d858f: #7d858f;
  --c-7d8590: #7d8590;
  --c-7d8998: #7d8998;
  --c-7d899a: #7d899a;
  --c-82652f: #82652f;
  --c-8390a0: #8390a0;
  --c-87642d: #87642d;
  --c-886b35: #886b35;
  --c-89929e: #89929e;
  --c-8a4b22: #8a4b22;
  --c-8a95a3: #8a95a3;
  --c-8b929b: #8b929b;
  --c-8c6529: #8c6529;
  --c-8c96a5: #8c96a5;
  --c-8f3450: #8f3450;
  --c-929ba8: #929ba8;
  --c-96522f: #96522f;
  --c-969eaa: #969eaa;
  --c-9a4343: #9a4343;
  --c-9aa0a8: #9aa0a8;
  --c-9b4545: #9b4545;
  --c-9da3ac: #9da3ac;
  --c-a3abb7: #a3abb7;
  --c-a3adbc: #a3adbc;
  --c-a6abb2: #a6abb2;
  --c-a98240: #a98240;
  --c-aaaaaa: #aaaaaa;
  --c-aeb3ba: #aeb3ba;
  --c-b3b8bf: #b3b8bf;
  --c-b4bac2: #b4bac2;
  --c-b8c0cb: #b8c0cb;
  --c-b9bec5: #b9bec5;
  --c-bac9d9: #bac9d9;
  --c-bbc3ce: #bbc3ce;
  --c-bfc8d5: #bfc8d5;
  --c-c3cad4: #c3cad4;
  --c-c58d8d: #c58d8d;
  --c-c5cad1: #c5cad1;
  --c-c6c8cc: #c6c8cc;
  --c-c7cacf: #c7cacf;
  --c-c7cdd6: #c7cdd6;
  --c-c9ac76: #c9ac76;
  --c-c9cdd4: #c9cdd4;
  --c-cbd1da: #cbd1da;
  --c-cccccc: #cccccc;
  --c-cdd2db: #cdd2db;
  --c-cfd8e3: #cfd8e3;
  --c-cfdae6: #cfdae6;
  --c-d2d7df: #d2d7df;
  --c-d3d6dc: #d3d6dc;
  --c-d3dae4: #d3dae4;
  --c-d4dbe5: #d4dbe5;
  --c-d5d8de: #d5d8de;
  --c-d5dce5: #d5dce5;
  --c-d5e1d8: #d5e1d8;
  --c-d7d9de: #d7d9de;
  --c-d8dce3: #d8dce3;
  --c-d8dfe7: #d8dfe7;
  --c-d9dce1: #d9dce1;
  --c-d9dce2: #d9dce2;
  --c-d9dde4: #d9dde4;
  --c-d9dfe6: #d9dfe6;
  --c-d9e1ea: #d9e1ea;
  --c-dcdfe3: #dcdfe3;
  --c-dcdfe4: #dcdfe4;
  --c-dce0e6: #dce0e6;
  --c-dce1e8: #dce1e8;
  --c-dce3ec: #dce3ec;
  --c-dedfe3: #dedfe3;
  --c-dee4ec: #dee4ec;
  --c-dfe2e7: #dfe2e7;
  --c-dfe4e9: #dfe4e9;
  --c-e0d4bc: #e0d4bc;
  --c-e0e5ec: #e0e5ec;
  --c-e0e6ed: #e0e6ed;
  --c-e1e3e7: #e1e3e7;
  --c-e1e5eb: #e1e5eb;
  --c-e1e7ef: #e1e7ef;
  --c-e2f0f1: #e2f0f1;
  --c-e3e5e8: #e3e5e8;
  --c-e3e7ed: #e3e7ed;
  --c-e3eef9: #e3eef9;
  --c-e4e9ef: #e4e9ef;
  --c-e4f1e8: #e4f1e8;
  --c-e5d7bb: #e5d7bb;
  --c-e5e9ee: #e5e9ee;
  --c-e5eaf0: #e5eaf0;
  --c-e6c7c7: #e6c7c7;
  --c-e6dcc6: #e6dcc6;
  --c-e6e7e9: #e6e7e9;
  --c-e6e9ed: #e6e9ed;
  --c-e6e9ee: #e6e9ee;
  --c-e6eaf0: #e6eaf0;
  --c-e6ebf0: #e6ebf0;
  --c-e8eaee: #e8eaee;
  --c-e8edf4: #e8edf4;
  --c-e9eaed: #e9eaed;
  --c-e9ecf0: #e9ecf0;
  --c-e9edf2: #e9edf2;
  --c-ece7f6: #ece7f6;
  --c-eceef1: #eceef1;
  --c-edf0f5: #edf0f5;
  --c-eef0f2: #eef0f2;
  --c-eef1f4: #eef1f4;
  --c-eef1f5: #eef1f5;
  --c-eef3f8: #eef3f8;
  --c-eff0f2: #eff0f2;
  --c-f0f3f7: #f0f3f7;
  --c-f0f5f1: #f0f5f1;
  --c-f1e8f5: #f1e8f5;
  --c-f1f3f6: #f1f3f6;
  --c-f1f5f9: #f1f5f9;
  --c-f2f3f5: #f2f3f5;
  --c-f2f4f7: #f2f4f7;
  --c-f3f5f8: #f3f5f8;
  --c-f4f4f5: #f4f4f5;
  --c-f4f5f6: #f4f5f6;
  --c-f4f5f7: #f4f5f7;
  --c-f4f6f9: #f4f6f9;
  --c-f5f5f6: #f5f5f6;
  --c-f5f6f8: #f5f6f8;
  --c-f5f7fa: #f5f7fa;
  --c-f7f7f7: #f7f7f7;
  --c-f7f8f9: #f7f8f9;
  --c-f7f8fa: #f7f8fa;
  --c-f8e4e4: #f8e4e4;
  --c-f8ece2: #f8ece2;
  --c-f8f9fa: #f8f9fa;
  --c-f8f9fb: #f8f9fb;
  --c-f9fbfe: #f9fbfe;
  --c-fae6ec: #fae6ec;
  --c-faf6ec: #faf6ec;
  --c-fafbfc: #fafbfc;
  --c-fbe7a1: #fbe7a1;
  --c-fbf1d9: #fbf1d9;
  --c-fbf3e4: #fbf3e4;
  --c-fbf7ee: #fbf7ee;
  --c-fcf1f1: #fcf1f1;
  --c-fcf2f2: #fcf2f2;
  --c-fcfcfd: #fcfcfd;
  --c-fdfaf3: #fdfaf3;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
}
body {
  background: var(--canvas);
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
button,
a {
  touch-action: manipulation;
}
button {
  border: 0;
  background: none;
}
a {
  color: var(--c-365d8a);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--c-1d426f);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
input,
textarea,
select {
  accent-color: var(--accent);
}
input[type='checkbox'],
input[type='radio'] {
  width: 17px;
  height: 17px;
  margin: 2px 0;
  flex: 0 0 auto;
}
input::placeholder,
textarea::placeholder {
  color: var(--c-777c84);
  opacity: 1;
}
textarea {
  resize: vertical;
}
svg {
  display: block;
  flex: 0 0 auto;
}
h1,
h2,
h3,
h4,
p,
dl,
dd {
  margin: 0;
}
h1,
h2,
h3,
h4 {
  font-family: var(--sans);
  overflow-wrap: anywhere;
}
h1 {
  font-size: 22px;
  line-height: 1.35;
  font-weight: 650;
}
h2 {
  font-size: 20px;
  line-height: 1.4;
  font-weight: 650;
}
h3 {
  font-size: 16px;
  line-height: 1.45;
  font-weight: 650;
}
h4 {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 650;
}
small,
.small {
  font-size: 12px;
}
strong {
  font-weight: 650;
}
[hidden],
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 9px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 3px;
  transform: translateY(-160%);
}
.skip:focus {
  transform: none;
}
.loading {
  padding: 48px 24px;
  text-align: center;
}
.loading p {
  margin: 12px 0 18px;
}

/* The header and footer stay outside the scrolling workspace. */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 300px;
}
.app-header {
  flex: 0 0 50px;
  min-height: 50px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--chrome);
  border-bottom: 1px solid var(--c-c6c8cc);
}
.app-title {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}
.app-title > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-mark {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 4px 7px 4px 0;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.2px;
  color: var(--c-454b55);
}
.home-mark:hover {
  color: var(--c-111111);
}
.app-title svg {
  width: 20px;
  height: 20px;
}
.app-version {
  color: var(--c-5e6268);
  font-size: 11px;
  font-weight: 450;
}
.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
}
.header-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.header-actions .search {
  width: 210px;
}
.draft-status {
  white-space: nowrap;
}
.header-actions .muted {
  font-size: 11px;
}
.app-body {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  background: var(--canvas);
}
.page-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  height: auto;
  min-height: 100%;
  max-width: 1180px;
  padding: 24px;
  margin: 0 auto;
  overflow: visible;
}
.page-content.mode-build,
.page-content.editor-page {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.page-content.mode-library {
  max-width: 1100px;
}
.page-content.mode-reference {
  max-width: 1148px;
}
.page-content.mode-sheet {
  max-width: 1048px;
}
.page-content > * {
  flex: 0 0 auto;
}
.page-content > .editor-content {
  flex: 1 1 0;
}
.app-footer {
  flex: 0 0 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 16px;
  background: var(--chrome);
  border-top: 1px solid var(--c-c6c8cc);
  font-size: 11px;
  z-index: 10;
}
.app-footer nav {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 4px;
  padding: 2px;
  background: var(--c-f4f4f5);
}
.app-footer button {
  min-height: 30px;
  padding: 5px 12px;
  border-radius: 3px;
  color: var(--c-494d53);
  font-size: 12px;
  white-space: nowrap;
}
.app-footer button:hover {
  background: var(--c-e6e7e9);
}
.app-footer button.active,
.app-footer button[aria-current='page'] {
  background: var(--c-dedfe3);
  color: var(--c-22252a);
  font-weight: 650;
}

/* General controls and compact command rows. */
.toolbar,
.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}
.toolbar-spacer {
  flex: 1 1 auto;
}
.toolbar h1,
.library-toolbar h1 {
  margin-right: auto;
}
.toolbar .muted,
.library-toolbar .muted {
  font-size: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--c-c7cacf);
  border-radius: 4px;
  background: var(--surface);
  color: var(--c-34383e);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
}
.btn:hover:not(:disabled) {
  background: var(--c-f2f3f5);
  border-color: var(--c-9da3ac);
}
.btn:active:not(:disabled) {
  background: var(--c-e8eaee);
}
.btn.primary {
  background: var(--c-3b414b);
  color: var(--surface);
  border-color: var(--c-3b414b);
}
.btn.primary:hover:not(:disabled) {
  background: var(--c-262c35);
  border-color: var(--c-262c35);
}
.btn.danger {
  color: var(--danger);
}
.btn.danger:hover:not(:disabled) {
  background: var(--c-fcf1f1);
  border-color: var(--c-c58d8d);
}
.btn.small {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}
.btn.icon {
  min-width: 34px;
  width: 34px;
  min-height: 34px;
  padding: 6px;
  flex: 0 0 auto;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.text-button {
  padding: 6px 0;
  color: var(--c-4d5867);
  font-size: 12px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.search,
input[type='search'] {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--c-c7cacf);
  border-radius: 4px;
  background: var(--surface);
  font-size: 13px;
}
.toolbar > select,
.library-sort select {
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--c-c7cacf);
  border-radius: 4px;
  background: var(--surface);
  font-size: 13px;
}
.toolbar > .search,
.library-toolbar > .search {
  flex: 1 1 200px;
  width: auto;
  max-width: 380px;
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
}
.error {
  color: var(--danger);
  font-size: 12px;
}
.badge.complete {
  color: var(--c-476a52);
  background: var(--c-f0f5f1);
  border-color: var(--c-d5e1d8);
}
.badge.partial {
  color: var(--c-82652f);
  background: var(--c-faf6ec);
  border-color: var(--c-e6dcc6);
}
.badge,
.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--c-e1e3e7);
  border-radius: 3px;
  background: var(--c-f4f5f6);
  color: var(--c-62676f);
  font-size: 11px;
  font-weight: 450;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.status {
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
}
.status.empty {
  color: var(--c-9b4545);
}
.status.partial {
  color: var(--c-8c6529);
}
.status.complete {
  color: var(--c-477254);
}
.segmented,
.tabs,
.view-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 4px;
  background: var(--c-eff0f2);
}
.segmented button,
.tabs button,
.view-tabs button {
  flex: 1 1 auto;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 3px;
  color: var(--c-60656d);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}
.segmented button:hover,
.tabs button:hover,
.view-tabs button:hover {
  background: var(--c-e3e5e8);
  color: var(--ink);
}
.segmented button.active,
.tabs button.active,
.view-tabs button.active,
.tabs [aria-selected='true'],
.view-tabs [aria-selected='true'] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
}

.view-tabs {
  flex: 0 0 auto;
  align-self: flex-start;
  max-width: 100%;
  overflow-x: auto;
}
.view-tabs button {
  min-width: 70px;
}

/* Editing: all sections are navigable, with progress shown as quiet text. */
.section-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: 54px;
  height: 60px;
  gap: 2px;
  flex: 0 0 60px;
  padding: 3px;
  border-radius: 5px;
  background: var(--c-f4f4f5);
}
.section-button {
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  text-align: center;
}
.section-button:hover {
  background: var(--c-e9eaed);
}
.section-button.active,
.section-button[aria-current='step'] {
  background: var(--surface);
  border-color: var(--c-dcdfe3);
  box-shadow: var(--shadow);
}
.section-name {
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.section-state {
  color: var(--c-6f747c);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 400;
}
.section-button.empty .section-state,
.section-state.empty {
  color: var(--c-9b4545);
}
.section-button.partial .section-state,
.section-state.partial {
  color: var(--c-8c6529);
}
.section-button.complete .section-state,
.section-state.complete {
  color: var(--c-637569);
}
.mobile-section-select,
.mobile-reference {
  display: none;
}
.editor-content {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow: auto;
}
.editor-content > .toolbar {
  margin-bottom: 12px;
}
.editor-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 20px;
  height: 100%;
  min-height: 0;
}
.reference-column,
.choices-column {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 1px 3px 8px 1px;
}
.reference-column > .panel:last-child,
.choices-column > :last-child {
  margin-bottom: 0;
}
.choices-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.choices-column > * {
  flex: 0 0 auto;
}
.choices-column > .panel {
  margin-bottom: 0;
}
.single-column {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  min-width: 0;
}
.single-column > .panel + .panel {
  margin-top: 12px;
}
.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--c-dcdfe3);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.panel.compact {
  padding: 14px 16px;
}
.panel-heading {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-light);
  font-size: 16px;
  line-height: 1.4;
  font-weight: 650;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-light);
}
.panel-head > div {
  min-width: 0;
}
.panel-head .panel-heading {
  border: 0;
  padding: 0;
  margin: 0;
  font-size: 16px;
}
.panel-head h2,
.panel-head h3 {
  font-size: 18px;
}
.panel-head .btn {
  flex-shrink: 0;
}
.panel-body {
  min-width: 0;
}
.panel-body > :first-child {
  margin-top: 0;
}
.panel-body > :last-child {
  margin-bottom: 0;
}
.panel .segmented,
.panel .tabs {
  margin-bottom: 15px;
}

.editor-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
  padding-top: 10px;
  margin-top: 3px;
  border-top: 1px solid var(--c-d7d9de);
  font-size: 12px;
}
.editor-bottom .muted {
  margin-right: auto;
}

/* Class and character lists are compact, information-bearing surfaces. */
.class-grid,
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  align-items: start;
  gap: 12px;
}
.class-card {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 17px 18px;
  border: 1px solid var(--c-d3d6dc);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  overflow-wrap: anywhere;
}
.class-card:focus-visible,
.character-entry:focus-visible {
  outline-offset: -3px;
}
.segmented button:focus-visible,
.tabs button:focus-visible,
.view-tabs button:focus-visible {
  outline-offset: -2px;
}
.class-card:hover {
  border-color: var(--c-969eaa);
  background: var(--c-fcfcfd);
}
.class-card.selected {
  border-color: var(--c-616d7c);
  box-shadow: inset 0 0 0 1px var(--c-616d7c);
  background: var(--c-f7f8fa);
}
.class-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.4;
}
.class-title small {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.class-description {
  min-height: 3em;
  color: var(--c-62666e);
  font-size: 13px;
  line-height: 1.6;
}
.class-data {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-light);
  font-size: 12px;
  line-height: 1.6;
}
.class-data dt {
  color: var(--c-747982);
}
.class-data dd {
  min-width: 0;
  color: var(--c-383e47);
}
.class-data > div {
  display: contents;
}
.class-actions {
  font-size: 12px;
  color: var(--c-626d7c);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding-top: 4px;
  margin-top: auto;
}
.character-grid {
  align-content: start;
}
.character-entry {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px 18px;
  border: 1px solid var(--c-d3d6dc);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
  overflow-wrap: anywhere;
}
.character-entry .panel-head {
  margin: 0;
  padding: 0;
  border: 0;
  align-items: flex-start;
}
.character-entry .character-name {
  font-size: 20px;
}
.character-entry:hover {
  border-color: var(--c-929ba8);
  background: var(--c-fcfcfd);
}
.character-name {
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.character-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--c-6a7078);
  font-size: 12px;
}
.character-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid var(--line-light);
  padding-top: 10px;
  font-size: 11px;
  text-align: center;
}
.character-stats span {
  color: var(--c-6f747c);
}
.character-stats strong {
  display: block;
  color: var(--c-343a43);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.draft-banner {
  padding: 10px 13px;
  border: 1px solid var(--c-e0d4bc);
  border-radius: 4px;
  background: var(--c-fbf7ee);
  color: var(--c-7a622e);
  font-size: 12px;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 150px;
  padding: 28px 20px;
  border: 1px solid var(--c-d5d8de);
  border-radius: 5px;
  background: var(--c-f5f5f6);
  text-align: center;
}
.empty-state h2,
.empty-state h3 {
  font-size: 18px;
}
.empty-state p {
  max-width: 520px;
  color: var(--muted);
  font-size: 13px;
}

/* Inline selections summarize chosen values; the drawer carries the options. */
.choice-group {
  min-width: 0;
  border: 1px solid var(--c-d9dce1);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-body > .choice-group + .choice-group {
  margin-top: 10px;
}
.choice-group > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 12px 15px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  border-radius: 4px;
}
.choice-group > summary::-webkit-details-marker {
  display: none;
}
.choice-group > summary::before {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: 2px;
  border-right: 1.5px solid var(--c-7a8089);
  border-bottom: 1.5px solid var(--c-7a8089);
  transform: rotate(-45deg);
}
.choice-group[open] > summary::before {
  transform: rotate(45deg);
  margin-top: -3px;
}
.choice-group[open] > summary {
  border-bottom: 1px solid var(--line-light);
  border-radius: 4px 4px 0 0;
}
.choice-group > summary:hover {
  background: var(--c-f7f8f9);
}
.group-count {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--c-727882);
  font-size: 11px;
  font-weight: 400;
}

.choice-group-body {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px;
  min-width: 0;
}
.choice-group-body .field,
.choice-group-body .notice {
  margin: 0;
}
.selection-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--c-dcdfe4);
  border-radius: 4px;
  background: var(--surface);
  min-width: 0;
}
.selection-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.selection-main > strong,
.selection-main > h3,
.selection-main > h4 {
  display: block;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
}
.selection-main > p,
.selection-main > small {
  display: block;
  margin-top: 4px;
  color: var(--c-727780);
  font-size: 12px;
  line-height: 1.6;
}
.selection-main .rules-body {
  margin-top: 7px;
}
.selection-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}
.selection-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--c-69717c);
  font-size: 15px;
}
.selection-actions button:hover {
  border-color: var(--c-d2d7df);
  background: var(--c-f1f3f6);
  color: var(--c-303a48);
}
.selection-actions button.danger {
  color: var(--danger);
}
.choice-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px dashed var(--c-b8c0cb);
  border-radius: 4px;
  background: var(--c-f8f9fb);
  color: var(--c-515b6b);
  font-size: 13px;
  line-height: 1.5;
}
.choice-trigger:hover {
  border-color: var(--c-76859b);
  background: var(--c-f0f3f7);
}
.incomplete .choice-trigger,
.choice-trigger.incomplete {
  border-color: var(--c-c9ac76);
  background: var(--c-fdfaf3);
  color: var(--c-87642d);
}
.incomplete .choice-trigger:hover,
.choice-trigger.incomplete:hover {
  border-color: var(--c-a98240);
  background: var(--c-fbf3e4);
}
.choice-hint {
  color: var(--c-707681);
  font-size: 12px;
  line-height: 1.65;
}
.subchoices {
  padding-left: 13px;
  margin: 8px 0 0 9px;
  border-left: 2px solid var(--c-dce0e6);
}

/* Forms use native controls and keep labels next to the relevant choice. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0 0 12px;
}
.field:last-child {
  margin-bottom: 0;
}
.field-grid .field {
  margin-bottom: 0;
}
.field-label {
  color: var(--c-424750);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
}
.optional {
  margin-left: 6px;
  color: var(--c-727882);
  font-size: 11px;
  font-weight: 400;
}
.field-help {
  color: var(--c-6a717b);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.field input:not([type='checkbox']):not([type='radio']),
.field textarea,
.field select,
.mobile-section-select select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--c-c9cdd4);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}
.field textarea {
  min-height: 78px;
}
.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: var(--c-a3abb7);
}
.field input[type='file'] {
  padding: 6px;
}
.field input[type='file']::file-selector-button {
  margin-right: 10px;
  padding: 5px 8px;
  border: 1px solid var(--c-cdd2db);
  border-radius: 3px;
  background: var(--c-f2f4f7);
  color: var(--c-3a4656);
  font: inherit;
  cursor: pointer;
}
.field + .chips {
  margin-top: -4px;
  margin-bottom: 14px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}
.chips button {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--c-d8dce3);
  border-radius: 3px;
  background: var(--c-f5f6f8);
  color: var(--c-626c7a);
  font-size: 11px;
  line-height: 1.5;
  text-align: left;
}
.chips button:hover {
  border-color: var(--c-a3adbc);
  background: var(--c-edf0f5);
}
.chips button.selected,
.chips button.active {
  border-color: var(--c-7d899a);
  background: var(--c-e8edf4);
  color: var(--c-344053);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.stat-box {
  min-width: 0;
  padding: 12px 6px 8px;
  border: 1px solid var(--c-d9dde4);
  border-radius: 4px;
  background: var(--c-f8f9fb);
  text-align: center;
}
.stat-box > span {
  display: block;
  font-size: 13px;
  font-weight: 650;
}
.stat-box label {
  display: block;
  font-size: 13px;
  font-weight: 650;
}
.stat-box small {
  display: block;
  margin: 3px 0 7px;
  color: var(--c-7d8590);
  font-size: 11px;
}
.stat-box strong,
.stat-box .value {
  display: block;
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.stat-box select {
  min-width: 0;
  width: 100%;
  min-height: 38px;
  padding: 4px 3px;
  border: 1px solid var(--c-cbd1da);
  border-radius: 3px;
  background: var(--surface);
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  text-align-last: center;
  font-variant-numeric: tabular-nums;
}

.inline-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 9px 0;
  color: var(--c-646d79);
  font-size: 12px;
  line-height: 1.55;
}
.inline-check input {
  margin-top: 2px;
}
.bond-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line-light);
}
.bond-row:first-child {
  padding-top: 0;
}
.bond-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.bond-row > .toolbar {
  margin-bottom: 10px;
}
.notice {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--c-d9dde4);
  border-radius: 4px;
  background: var(--c-f3f5f8);
  color: var(--c-637083);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.notice.warning {
  border-color: var(--c-e5d7bb);
  background: var(--c-fbf7ee);
  color: var(--c-886b35);
}
.notice.error {
  border-color: var(--c-e6c7c7);
  background: var(--c-fcf2f2);
  color: var(--c-9a4343);
}

.notice > :first-child {
  margin-top: 0;
}
.notice > :last-child {
  margin-bottom: 0;
}
.error-list {
  padding-left: 18px;
  margin: 8px 0;
}
.error-list li {
  padding: 2px 0;
}
.error-list button {
  padding: 3px 0;
  color: var(--c-96522f);
  font-size: 12px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Character detail and rules retain a predictable reading hierarchy. */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
}
.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 13px 8px;
  border: 1px solid var(--c-dfe2e7);
  border-radius: 4px;
  background: var(--c-f7f8fa);
  text-align: center;
}
.metric label,
.metric span,
.metric .label {
  color: var(--c-727b87);
  font-size: 11px;
}
.metric strong,
.metric .value {
  color: var(--c-363f4c);
  font-size: 24px;
  line-height: 1.25;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 13px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line-light);
  border-bottom: 1px solid var(--line-light);
  text-align: center;
}
.stats-strip span,
.stats-strip small {
  display: block;
  color: var(--c-6c7683);
  font-size: 11px;
}
.stats-strip strong {
  display: block;
  color: var(--c-3b4553);
  font-size: 19px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.panel-body > p + .data-list,
.panel-body > .data-list + p {
  margin-top: 14px;
}
.panel-body > p + p {
  margin-top: 8px;
}

.data-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  font-size: 13px;
}
.data-list > div {
  display: contents;
}
.data-list dt {
  color: var(--c-6c747f);
}
.data-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rule-title {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.45;
}
.rule-kind {
  color: var(--c-6a727d);
  font-size: 11px;
  font-weight: 400;
}

.rules-body {
  margin-top: 14px;
  color: var(--c-424b57);
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.rules-body > :first-child {
  margin-top: 0;
}
.rules-body > :last-child {
  margin-bottom: 0;
}
.rules-body p {
  margin: 11px 0;
}
.rules-body h2,
.rules-body h3,
.rules-body h4 {
  margin: 22px 0 8px;
  color: var(--c-303946);
  font-size: 15px;
  font-weight: 650;
}
.rules-body ul,
.rules-body ol {
  padding-left: 21px;
  margin: 9px 0;
}
.rules-body li {
  padding-left: 2px;
  margin: 7px 0;
}
.rules-body li > ul,
.rules-body li > ol {
  margin: 5px 0;
}
.rules-body strong {
  color: var(--c-303946);
  font-weight: 650;
}
.rules-body blockquote {
  margin: 12px 0;
  padding: 7px 12px;
  border-left: 2px solid var(--c-bfc8d5);
  background: var(--c-f4f6f9);
  color: var(--c-626e7e);
}
.rules-body hr {
  border: 0;
  border-top: 1px solid var(--c-e3e7ed);
  margin: 16px 0;
}
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}
.rules-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.7;
}
.rules-body th,
.rules-body td {
  padding: 9px 11px;
  border: 1px solid var(--c-dce1e8);
  text-align: left;
  vertical-align: top;
}
.rules-body th,
.rules-body tr:first-child td {
  background: var(--c-eef1f4);
  color: var(--c-394554);
  font-weight: 650;
}
.rules-body tbody tr:nth-child(even) {
  background: var(--c-fafbfc);
}
.rules-body .tag {
  padding: 1px 6px;
  font-size: 12px;
  vertical-align: baseline;
}
.source {
  margin-top: 16px;
  padding-top: 9px;
  border-top: 1px solid var(--c-e6e9ee);
  color: var(--c-6f7681);
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.details {
  margin-top: 13px;
  border-top: 1px solid var(--line-light);
  padding-top: 10px;
}
.details > summary {
  cursor: pointer;
  color: var(--c-687483);
  font-size: 12px;
}

/* Reading layouts: one index, one detail, and a bounded character sheet. */

.reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px 138px 18px;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 58px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--c-e6e9ed);
  text-align: left;
  background: var(--surface);
}
.reference-row:last-child {
  border-bottom: 0;
}
.reference-row:hover {
  background: var(--c-f5f7fa);
}
.reference-row:focus-visible {
  position: relative;
  z-index: 1;
  outline-offset: -3px;
}
.reference-row-name {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 12px;
  min-width: 0;
}
.reference-row-name strong {
  color: var(--c-2e3742);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.reference-row-name small {
  color: var(--c-747d88);
  font-size: 12px;
  line-height: 1.5;
}

.reference-row-kind {
  color: var(--c-717985);
  font-size: 12px;
}
.reference-row-arrow {
  color: var(--c-8a95a3);
  font-size: 17px;
  text-align: right;
}

.sheet-screen {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 26px 28px 28px;
  border: 1px solid var(--c-d9dfe6);
  border-radius: 7px;
  background: var(--surface);
}

.sheet-screen > .view-tabs {
  display: flex;
  width: 100%;
  margin-bottom: 24px;
  padding: 0;
  gap: 4px;
  background: none;
  border-bottom: 1px solid var(--c-dfe4e9);
  border-radius: 0;
  overflow-x: auto;
}
.sheet-screen > .view-tabs button {
  flex: 0 0 auto;
  min-width: 68px;
  min-height: 39px;
  padding: 8px 14px 10px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 13px;
}
.sheet-screen > .view-tabs button.active {
  border-bottom-color: var(--c-445569);
  color: var(--c-2e3d50);
  background: transparent;
}
.sheet-screen > .view-tabs button:hover {
  background: var(--c-f5f7fa);
}

.sheet-screen .panel {
  padding: 0;
  margin-bottom: 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.sheet-screen .panel:last-child {
  margin-bottom: 0;
}
.sheet-screen .panel-head {
  margin-bottom: 13px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--c-e9ecf0);
}
.sheet-screen .panel-head h2,
.sheet-screen .panel-head h3,
.sheet-screen .panel-heading {
  font-size: 15px;
  line-height: 1.5;
}
.sheet-screen .panel-body {
  font-size: 13px;
  line-height: 1.75;
}
.sheet-screen .data-list {
  grid-template-columns: minmax(68px, max-content) minmax(0, 1fr);
  gap: 9px 14px;
  font-size: 13px;
  line-height: 1.75;
}
.sheet-screen .data-list dt {
  color: var(--c-7b8490);
}

.sheet-screen .stats-strip {
  gap: 8px;
  margin: 0 0 20px;
  padding: 0 0 17px;
  border-top: 0;
  border-bottom: 1px solid var(--c-e5e9ee);
}
.sheet-screen .stats-strip span {
  color: var(--c-737e8c);
  font-size: 12px;
  line-height: 1.5;
}
.sheet-screen .stats-strip small {
  display: inline;
  margin-left: 2px;
  font-size: 11px;
  color: var(--c-89929e);
}
.sheet-screen .stats-strip strong {
  margin-top: 4px;
  color: var(--c-3d4c60);
  font-size: 19px;
  line-height: 1.3;
}

.sheet-screen .notice {
  padding: 9px 11px;
  font-size: 12px;
}

.class-selected-layout {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}
.class-selected-layout > .toolbar {
  margin-bottom: 14px;
}
.class-selected-layout > .panel {
  padding: 24px 26px;
}
.class-selected-layout .data-list {
  margin-top: 18px;
  margin-bottom: 18px;
  line-height: 1.75;
}

.class-selected-layout .choice-group {
  box-shadow: none;
}
.rule-detail {
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.rule-detail > .rule-title {
  margin: 0 0 8px;
  font-size: 19px;
}
.rule-detail > .rule-kind {
  margin-bottom: 12px;
}
.rule-detail .rules-body {
  margin-top: 0;
}
.rule-detail .rules-body + .rules-body {
  margin-top: 20px;
}
.drawer-content > .panel {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.drawer-content > .panel + .panel {
  margin-top: 24px;
}
.drawer-content .rules-body .table-scroll {
  margin: 16px 0;
}
.drawer-content .rules-body strong {
  font-weight: 650;
}

/* The same short rule row is reused for granted moves and class paths. */

.move-link {
  grid-template-columns: minmax(0, 1fr) max-content 14px;
  min-height: 46px;
  padding: 10px 0;
  gap: 12px;
}
.move-link .reference-row-name strong {
  font-size: 13px;
}
.move-link .reference-row-kind {
  font-size: 11px;
}
.sheet-screen .sheet-section {
  margin: 21px 0 0;
}
.sheet-screen .sheet-section > h2,
.sheet-screen .sheet-section .toolbar > h2,
.sheet-screen > .toolbar > h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 15px;
  line-height: 1.5;
}
.sheet-screen .sheet-section > h2,
.sheet-screen .sheet-section > .toolbar {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-e9edf2);
}

.sheet-screen .text-button {
  padding: 3px 0;
  font-size: 11px;
  color: var(--c-758396);
  text-decoration: none;
}
.sheet-screen .text-button:hover {
  color: var(--c-365d8a);
  text-decoration: underline;
}

.preserve-lines {
  white-space: pre-wrap;
}
.incomplete-character {
  margin-top: 25px;
  padding-top: 18px;
  border-top: 1px solid var(--c-e6eaf0);
}
.incomplete-character > h2 {
  font-size: 15px;
}
.sheet-screen > .toolbar {
  margin-bottom: 12px;
}

.sheet-screen .selection-box {
  margin-top: 12px;
  border: 0;
  border-bottom: 1px solid var(--c-e6ebf0);
  border-radius: 0;
  padding: 0 0 14px;
}
.sheet-screen .selection-box:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.class-intro {
  padding: 28px;
  border: 1px solid var(--c-d8dfe7);
  border-radius: 6px;
  background: var(--surface);
}
.class-intro h1 {
  font-size: 24px;
  margin-bottom: 12px;
}
.class-intro > p {
  max-width: 650px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--c-5c6878);
}
.class-intro > h2 {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--c-e5eaf0);
  font-size: 16px;
}
.class-paths {
  margin-top: 12px;
}
.class-paths .reference-row {
  grid-template-columns: minmax(0, 1fr) 14px;
  padding: 13px 0;
}
.class-paths .reference-row-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.class-paths .reference-row-name strong {
  font-size: 14px;
}
.class-paths .reference-row-name small {
  color: var(--c-778290);
  font-size: 13px;
  line-height: 1.75;
}
.rule-source {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--c-e5eaf0);
  color: var(--c-89929e);
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.rule-source > summary {
  cursor: pointer;
  color: var(--c-7d8998);
  font-size: 11px;
}
.rule-source p {
  margin-top: 7px;
}
.rule-source p.small {
  font-size: 11px;
}
.rule-tag {
  display: inline;
  padding: 1px 4px;
  border: 1px solid var(--c-d9e1ea);
  border-radius: 3px;
  background: var(--c-f1f5f9);
  color: var(--c-566b83);
  font-size: 0.88em;
  white-space: nowrap;
}
.rules-body .roll-result {
  position: relative;
  margin: 10px 0;
  padding: 9px 12px 9px 30px;
  border-left: 2px solid var(--c-bac9d9);
  background: var(--c-f5f7fa);
}
.roll-marker {
  position: absolute;
  top: 9px;
  left: 10px;
  color: var(--c-6b7e96);
}
.reference-column > .rule-detail + .rule-detail {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--c-d5dce5);
}
.reference-column > .rule-detail {
  padding-inline: 6px;
}
.drawer-content > .rule-detail + .rule-detail {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--c-dce3ec);
}
.drawer-content > p + .rule-detail {
  margin-top: 22px;
}
.drawer-content > .rule-detail > .rule-kind {
  margin-bottom: 16px;
}
.drawer-selected-region {
  flex: 0 0 auto;
  max-height: 160px;
  overflow-y: auto;
}
.drawer-selected {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-e0e6ed);
  background: var(--surface);
}
.drawer-selected > .small {
  flex: 0 0 auto;
  padding-top: 6px;
}
.drawer-selected .chips {
  flex: 1 1 auto;
  margin: 0;
}
.drawer-selected .chips button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  color: var(--c-496078);
  background: var(--c-eef3f8);
  border-color: var(--c-cfdae6);
}
.drawer-selected .chips button span {
  color: var(--c-7c8da0);
}

.rules-body li.rule-option {
  list-style: none;
  padding-left: 0;
}
.class-growth {
  margin-top: 24px;
  padding-top: 17px;
  border-top: 1px solid var(--c-e5eaf0);
}
.class-growth > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  padding: 3px 0;
  cursor: pointer;
  list-style: none;
  color: var(--c-526175);
  font-size: 14px;
  font-weight: 600;
}
.class-growth > summary::-webkit-details-marker {
  display: none;
}
.class-growth > summary::after {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-right: 1.5px solid var(--c-8390a0);
  border-bottom: 1.5px solid var(--c-8390a0);
  transform: rotate(45deg);
}
.class-growth[open] > summary::after {
  transform: rotate(225deg);
}
.class-growth > summary:hover {
  color: var(--c-2f4968);
}

.choice-group > summary > span:first-child {
  min-width: 0;
}
.group-selection {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--c-7b8592);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.choice-group[open] .group-selection,
.group-selection:empty {
  display: none;
}
.equipment-member + .equipment-member {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--c-e4e9ef);
}
.equipment-member > .rule-title {
  margin: 0 0 6px;
  color: var(--c-354254);
  font-size: 14px;
  line-height: 1.6;
}
.equipment-member > .tag {
  display: inline-block;
  margin: 2px 0 7px;
  width: auto;
}
.equipment-member > .rules-body {
  margin-top: 4px;
}
.equipment-member > .rules-body > :first-child {
  margin-top: 0;
}
.full-rule-details {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--c-e1e7ef);
}
.full-rule-details > summary {
  cursor: pointer;
  padding: 4px 0;
  color: var(--c-687b92);
  font-size: 13px;
  line-height: 1.7;
}
.full-rule-details > summary:hover {
  color: var(--c-365d8a);
}
.full-rule-details[open] > summary {
  margin-bottom: 16px;
}
.full-rule-details > .rule-detail {
  padding: 0;
}

/* Native dialogs handle modality; only their content area scrolls. */
dialog {
  color: var(--ink);
  font: inherit;
}
dialog::backdrop {
  background: rgb(25 31 41 / 38%);
}
#modal,
.dialog {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--c-c3cad4);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 44px rgb(22 30 44 / 22%);
  overflow: auto;
}
#modal[open],
.dialog[open] {
  display: flex;
  flex-direction: column;
}
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  padding: 16px 18px;
  border-bottom: 1px solid var(--c-e1e5eb);
  background: var(--surface);
}
.dialog-head h2 {
  font-size: 18px;
}
.dialog-body {
  padding: 18px;
  min-height: 0;
  overflow-y: auto;
}
.dialog-body > p + .field {
  margin-top: 14px;
}
.dialog-body > :last-child {
  margin-bottom: 0;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  padding: 12px 18px;
  border-top: 1px solid var(--c-e1e5eb);
  background: var(--c-fafbfc);
}
.close-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 4px;
  color: var(--c-687381);
  font-size: 24px;
  line-height: 1;
}
.close-button:hover {
  color: var(--c-293545);
  background: var(--c-eef1f5);
}
#drawer.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: 620px;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--c-bbc3ce);
  border-radius: 0;
  background: var(--surface);
  box-shadow: -8px 0 28px rgb(17 26 39 / 16%);
  overflow: hidden;
}
#drawer.drawer[open] {
  display: flex;
  flex-direction: column;
}
.drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  padding: 17px 18px;
  border-bottom: 1px solid var(--c-dce1e8);
  background: var(--surface);
}
.drawer-header > div {
  min-width: 0;
}
.drawer-header h2 {
  margin: 2px 0;
  font-size: 20px;
}
.drawer-header p {
  color: var(--c-77818f);
  font-size: 12px;
  margin-top: 5px;
}
.drawer-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-e0e5ec);
  background: var(--c-f8f9fb);
}
.drawer-search .search {
  flex: 1 1 auto;
}
.drawer-search > .small {
  flex: 0 0 auto;
  color: var(--c-6a737f);
  white-space: nowrap;
}
.drawer-content > .option-card + .option-card {
  margin-top: 12px;
}
.option-card > h3 + .field {
  margin-top: 10px;
}
.drawer-content {
  flex: 1 1 0;
  min-height: 0;
  padding: 22px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.drawer-content > .rules-body {
  margin-top: 0;
}
.drawer-content .panel:last-child {
  margin-bottom: 0;
}
.drawer-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 62px;
  padding: 12px 16px;
  border-top: 1px solid var(--c-dce1e8);
  background: var(--surface);
}
.drawer-footer .muted {
  margin-right: auto;
  font-size: 12px;
}

.option-card {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--c-d4dbe5);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.option-card.selected {
  border-color: var(--c-77879d);
  box-shadow: inset 0 0 0 1px var(--c-77879d);
  background: var(--c-f9fbfe);
}
.option-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.option-head > div {
  min-width: 0;
}
.option-head h3,
.option-head strong {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.5;
}
.option-head > .btn,
.option-head > button {
  flex: 0 0 auto;
}
.option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 7px;
  color: var(--c-697483);
  font-size: 11px;
}
.option-card .rules-body {
  font-size: 12px;
}
.option-card .rules-body h4 {
  font-size: 13px;
}
.option-card .source {
  margin-top: 12px;
}
#toast {
  position: fixed;
  z-index: 100;
  bottom: 58px;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 15px;
  border: 1px solid var(--c-4a5666);
  border-radius: 4px;
  background: var(--c-333d4b);
  color: var(--surface);
  box-shadow: 0 3px 10px rgb(0 0 0 / 16%);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition:
    opacity 0.15s,
    transform 0.15s;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* A printable sheet is separate from the interactive character view. */

.print-view {
  min-width: 0;
}
.sheet {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--c-d3dae4);
  border-radius: 5px;
  background: var(--surface);
  color: var(--c-2d3540);
  box-shadow: var(--shadow);
}

.sheet-section {
  margin: 20px 0;
  overflow-wrap: anywhere;
}
.sheet-section h2,
.sheet-section h3 {
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--c-dee4ec);
  font-size: 16px;
  font-weight: 650;
}
.sheet-section p,
.sheet-section li {
  font-size: 13px;
  line-height: 1.75;
}
.sheet-section ul,
.sheet-section ol {
  padding-left: 20px;
  margin: 8px 0;
}

@media (min-width: 1600px) {
  .page-content {
    padding-top: 20px;
    padding-bottom: 20px;
  }
}
@media (max-width: 1100px) {
  .page-content {
    padding: 14px;
    gap: 12px;
  }
  .editor-columns {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 14px;
  }
  .panel {
    padding: 16px;
  }
  .header-actions .search {
    width: 160px;
  }
  .app-version {
    display: none;
  }
}
@media (max-width: 899px) {
  .section-nav {
    display: none;
  }
  .mobile-section-select {
    display: block;
    min-width: 0;
    flex: 0 0 auto;
  }
  select.mobile-section-select {
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--c-c7cdd6);
    border-radius: 4px;
    background: var(--surface);
    font-size: 14px;
  }
  .mobile-section-select select {
    min-height: 40px;
  }
  .mobile-reference {
    display: inline-flex;
    margin-bottom: 12px;
  }
  .editor-columns {
    display: block;
    height: auto;
  }
  .reference-column {
    display: none;
  }
  .choices-column {
    overflow: visible;
    padding: 1px 1px 8px;
    scrollbar-gutter: auto;
  }
  .editor-content {
    overflow-y: auto;
  }
  .single-column {
    max-width: none;
  }
  .class-grid,
  .character-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  }
  .app-footer > .muted {
    font-size: 11px;
  }
  .header-actions .muted {
    display: none;
  }
  .sheet {
    padding: 22px;
  }
}
@media (max-width: 599px) {
  :root {
    font-size: 14px;
  }
  .app-header {
    flex-basis: auto;
    min-height: 50px;
    padding: 7px 10px;
    gap: 8px;
  }
  .app-title {
    gap: 5px;
    font-size: 16px;
  }
  .app-title svg {
    width: 18px;
    height: 18px;
  }
  .app-title {
    flex: 1 1 auto;
  }
  .header-actions {
    gap: 5px;
    flex: 0 0 auto;
    max-width: 73%;
  }
  .header-actions .btn {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
  }
  .header-actions .search {
    display: none;
  }
  .app-footer {
    padding: 4px 8px;
    gap: 5px;
  }
  .app-footer nav {
    padding: 0;
  }
  .app-footer button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .app-footer > .muted,
  .app-footer > small {
    display: none;
  }
  .page-content {
    padding: 12px 10px;
    gap: 12px;
  }
  .toolbar,
  .library-toolbar {
    gap: 7px;
  }
  .toolbar > .search,
  .library-toolbar > .search {
    flex-basis: 100%;
    max-width: none;
  }
  .toolbar-spacer {
    display: none;
  }
  .library-toolbar h1 {
    flex-basis: 100%;
  }
  .btn {
    min-height: 40px;
    padding: 8px 11px;
  }
  .btn.small {
    min-height: 36px;
  }
  .btn.icon {
    min-width: 36px;
    width: 36px;
    min-height: 36px;
  }
  .panel {
    padding: 15px;
  }
  .panel.compact {
    padding: 12px;
  }
  .panel-head {
    gap: 8px;
  }
  .panel-head h2,
  .panel-head h3 {
    font-size: 17px;
  }
  .class-grid,
  .character-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .class-card {
    padding: 16px;
    gap: 9px;
  }
  .class-description {
    min-height: 0;
  }
  .class-title {
    font-size: 20px;
  }
  .character-entry {
    padding: 15px 16px;
  }

  .view-tabs {
    width: 100%;
    align-self: stretch;
  }
  .view-tabs button {
    min-width: 59px;
    min-height: 36px;
    padding: 7px 8px;
  }

  .field-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .field input:not([type='checkbox']):not([type='radio']),
  .field textarea,
  .field select,
  .search,
  input[type='search'],
  .mobile-section-select select,
  select.mobile-section-select {
    min-height: 42px;
    font-size: 16px;
  }
  .toolbar > select {
    min-height: 42px;
    font-size: 16px;
  }
  .field-help,
  .rules-body {
    font-size: 13px;
  }
  .stat-grid {
    gap: 5px;
  }
  .stat-box {
    padding: 10px 3px 6px;
  }
  .stat-box label {
    font-size: 12px;
  }
  .stat-box small {
    font-size: 11px;
    margin-bottom: 6px;
  }
  .stat-box select {
    min-height: 42px;
    padding: 5px 0;
    font-size: 20px;
  }
  .choice-group > summary {
    min-height: 46px;
    padding: 12px;
  }
  .choice-group-body {
    padding: 12px;
  }
  .selection-box {
    gap: 6px;
    padding: 11px;
  }
  .selection-actions {
    gap: 1px;
  }
  .selection-actions button {
    min-width: 32px;
    min-height: 34px;
  }
  .choice-trigger {
    min-height: 44px;
  }
  .chips {
    gap: 6px;
  }
  .chips button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
  }
  .inline-check {
    min-height: 30px;
    align-items: flex-start;
    font-size: 13px;
  }
  .data-list {
    column-gap: 12px;
  }
  .metric-grid {
    gap: 6px;
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  }
  .metric {
    padding: 11px 6px;
  }

  #drawer.drawer {
    width: 100%;
    border-left: 0;
  }
  .drawer-header {
    padding: 13px 14px;
  }
  .drawer-header h2 {
    font-size: 19px;
  }
  .drawer-search {
    padding: 10px 12px;
  }
  .drawer-content {
    padding: 12px;
    scrollbar-gutter: auto;
  }
  .drawer-footer {
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }
  .close-button {
    width: 36px;
    height: 36px;
  }
  .option-card {
    padding: 13px;
  }
  .option-head {
    gap: 8px;
  }
  .option-card .rules-body {
    font-size: 13px;
  }
  #modal,
  .dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
  }
  .dialog-head {
    padding: 12px 14px;
  }
  .dialog-body {
    padding: 14px;
  }
  .dialog-actions {
    padding: 10px 14px;
  }
  .sheet {
    padding: 18px 14px;
  }
}
@media (max-width: 359px) {
  .app-title {
    font-size: 14px;
  }
  .header-actions .btn {
    padding-inline: 6px;
    font-size: 11px;
  }
  .app-footer button {
    padding-inline: 8px;
  }
  .stat-grid {
    gap: 3px;
  }
  .stat-box {
    padding-inline: 2px;
  }
  .view-tabs button {
    min-width: 52px;
    padding-inline: 6px;
  }
  .data-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }
  .data-list dd {
    margin-bottom: 6px;
  }
}
@media (max-width: 1100px) {
  .page-content.mode-sheet,
  .page-content.mode-reference {
    padding: 20px;
  }
  .sheet-screen {
    padding: 22px 24px 24px;
  }
}
@media (max-width: 760px) {
  .reference-row {
    grid-template-columns: minmax(0, 1fr) 70px 116px 14px;
    gap: 10px;
  }
}
@media (max-width: 599px) {
  .app-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
  }
  .app-title {
    flex: 1 1 100%;
    font-size: 16px;
    line-height: 1.5;
  }
  .app-title > span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
  .home-mark {
    min-height: 26px;
    padding: 3px 7px 3px 0;
  }
  .header-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    max-width: none;
  }
  .header-actions:empty {
    display: none;
  }
  .header-actions .btn {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
  }
  .app-footer {
    flex-basis: auto;
    min-height: 50px;
    padding: 5px 10px max(5px, env(safe-area-inset-bottom));
  }
  .app-footer nav {
    flex: 1 1 auto;
    width: 100%;
    gap: 2px;
    background: transparent;
  }
  .app-footer button {
    flex: 1 1 0;
    min-height: 38px;
    padding: 7px 9px;
    border-color: transparent;
    background: transparent;
  }
  .app-footer button.active {
    background: var(--c-f8f9fa);
  }
  .page-content,
  .page-content.mode-sheet,
  .page-content.mode-reference {
    padding: 14px 12px;
  }
  .page-content.mode-build {
    padding: 12px 10px;
    gap: 10px;
  }
  .editor-bottom {
    padding-top: 8px;
    gap: 6px;
  }
  .editor-bottom .muted {
    display: none;
  }
  .editor-bottom .btn {
    min-height: 38px;
  }

  .reference-row {
    grid-template-columns: auto minmax(0, 1fr) 14px;
    gap: 5px 12px;
    min-height: 74px;
    padding: 12px 13px;
  }
  .reference-row-name {
    grid-column: 1 / 3;
    grid-row: 1;
    gap: 3px 9px;
  }
  .reference-row-name strong {
    font-size: 14px;
  }
  .reference-row-name small {
    font-size: 11px;
  }

  .reference-row-kind {
    grid-column: 2;
    grid-row: 2;
    font-size: 11px;
  }
  .reference-row-arrow {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .sheet-screen {
    padding: 19px 16px 21px;
    border-radius: 6px;
  }

  .sheet-screen > .view-tabs {
    margin-bottom: 20px;
    gap: 0;
  }
  .sheet-screen > .view-tabs button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 42px;
    padding: 8px 6px 10px;
    font-size: 12px;
  }

  .sheet-screen .data-list {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px 12px;
  }
  .sheet-screen .panel {
    margin-bottom: 20px;
  }
  .sheet-screen .panel-head {
    margin-bottom: 11px;
  }

  .sheet-screen .stats-strip {
    gap: 3px;
    margin-bottom: 19px;
    padding-bottom: 15px;
  }
  .sheet-screen .stats-strip span {
    font-size: 11px;
  }
  .sheet-screen .stats-strip small {
    display: block;
    margin-left: 0;
    font-size: 11px;
  }
  .sheet-screen .stats-strip strong {
    font-size: 18px;
  }

  .class-selected-layout > .panel {
    padding: 18px 16px;
  }
  .class-selected-layout .data-list {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px 12px;
  }
  .class-selected-layout > .toolbar {
    align-items: center;
  }
  .drawer-header {
    padding: 15px 16px;
  }
  .drawer-content {
    padding: 18px 16px;
  }
  .drawer-content .rules-body,
  .rule-detail .rules-body {
    font-size: 14px;
    line-height: 1.85;
  }
  .drawer-content .rules-body h2,
  .drawer-content .rules-body h3,
  .drawer-content .rules-body h4 {
    font-size: 15px;
  }
  .drawer-content .rules-body table {
    font-size: 12px;
    line-height: 1.7;
  }
  .drawer-content .rules-body td,
  .drawer-content .rules-body th {
    padding: 8px;
  }
  .rule-detail > .rule-title {
    font-size: 18px;
  }
}
@media (max-width: 599px) {
  .move-link {
    grid-template-columns: minmax(0, 1fr) max-content 14px;
    min-height: 46px;
    gap: 9px;
    padding: 11px 0;
  }
  .move-link .reference-row-name {
    grid-column: 1;
    grid-row: auto;
  }
  .move-link .reference-row-name strong {
    font-size: 13px;
  }
  .move-link .reference-row-kind {
    grid-column: 2;
    grid-row: auto;
    font-size: 11px;
  }
  .move-link .reference-row-arrow {
    grid-column: 3;
    grid-row: auto;
  }
  .class-intro {
    padding: 20px 17px;
  }
  .class-intro h1 {
    font-size: 22px;
  }
  .class-intro > p {
    font-size: 14px;
  }
  .class-paths .reference-row {
    grid-template-columns: minmax(0, 1fr) 14px;
    min-height: 0;
  }
  .class-paths .reference-row-name {
    grid-column: 1;
    grid-row: auto;
  }
  .class-paths .reference-row-arrow {
    grid-column: 2;
    grid-row: auto;
  }

  .drawer-selected {
    padding: 10px 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
@media print {
  @page {
    size: A4;
    margin: 12mm;
  }
  :root {
    color: var(--c-111111);
    font-size: 10pt;
  }
  html,
  body {
    width: auto;
    height: auto;
    min-height: 0;
    background: var(--surface);
    color: var(--c-111111);
  }
  .app-header,
  .app-footer,
  .section-nav,
  .mobile-section-select,
  .mobile-reference,
  .toolbar,
  .library-toolbar,
  .view-tabs,
  .editor-bottom,
  .no-print,
  #toast,
  dialog,
  .skip {
    display: none !important;
  }
  .app-shell,
  .app-body,
  .page-content,
  .print-view {
    display: block;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    max-width: none;
    padding: 0;
    margin: 0;
    overflow: visible;
    background: var(--surface);
  }

  .sheet-screen {
    display: block;
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--surface);
  }
  .sheet-screen .print-view,
  .sheet-screen .print-view > .sheet {
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .sheet-screen .sheet-section {
    margin: 14px 0;
  }
  .sheet-screen .sheet-section > h2 {
    margin-bottom: 7px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--c-dee4ec);
    font-size: 12pt;
  }

  .sheet {
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--surface);
    color: var(--c-111111);
  }

  .sheet-section {
    margin: 14px 0;
  }

  .sheet .data-list {
    font-size: 9pt;
    gap: 5px 10px;
  }
  .sheet-section h2,
  .sheet-section h3 {
    margin-bottom: 7px;
    padding-bottom: 5px;
    font-size: 12pt;
    color: var(--c-111111);
  }
  .sheet-section p,
  .sheet-section li,
  .rules-body {
    font-size: 9pt;
    line-height: 1.6;
    color: var(--c-222222);
  }

  .rule-title {
    font-size: 11pt;
  }

  .rules-body {
    margin-top: 8px;
  }
  .rules-body p {
    margin: 5px 0;
  }
  .rules-body h2,
  .rules-body h3,
  .rules-body h4 {
    margin: 12px 0 5px;
    font-size: 10pt;
    color: var(--c-111111);
  }
  .rules-body ul,
  .rules-body ol {
    margin: 6px 0;
    padding-left: 17px;
  }
  .rules-body li {
    margin: 3px 0;
  }
  .rules-body table {
    font-size: 8pt;
  }
  .rules-body td,
  .rules-body th {
    padding: 4px 5px;
    border-color: var(--c-aaaaaa);
  }
  .rules-body strong {
    color: var(--c-111111);
  }
  .rules-body blockquote {
    background: var(--c-f7f7f7);
    border-color: var(--c-aaaaaa);
  }
  .table-scroll {
    overflow: visible;
  }
  .source {
    margin-top: 9px;
    padding-top: 6px;
    color: var(--c-666666);
    font-size: 7.5pt;
  }
  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }
  p,
  li {
    orphans: 3;
    widows: 3;
  }
  .metric,
  .selection-box,
  tr {
    break-inside: avoid;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Advancement uses the existing archive / split-reader vocabulary. */
.advance-page {
  max-width: 1100px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border, var(--c-d9dce2));
  border-radius: 5px;
}
.advance-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--c-e3e5e8);
}
.advance-heading h1 {
  margin: 0 0 6px;
  font-size: 21px;
}
.advance-heading p {
  margin: 0;
  color: var(--c-626b78);
  font-size: 14px;
}
.advance-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 380px;
}
.growth-slots {
  padding: 14px;
  border-right: 1px solid var(--c-e3e5e8);
}
.growth-slot {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
  margin-bottom: 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
}
.growth-slot:hover,
.growth-candidate:hover {
  background: var(--c-f4f5f7);
}
.growth-slot.selected,
.growth-candidate.selected {
  border-color: var(--c-8c96a5);
  background: var(--c-eef1f5);
}
.growth-slot strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.growth-slot small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--c-626b78);
}
.growth-content {
  min-width: 0;
  padding: 22px;
}
.growth-candidates {
  margin-bottom: 20px;
}
.growth-candidates > .search {
  width: 100%;
  min-width: 0;
  margin-bottom: 10px;
}
.growth-candidate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  max-height: 230px;
  overflow: auto;
}
.growth-candidate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid var(--c-e3e5e8);
  border-radius: 3px;
  background: var(--surface);
  font-size: 14px;
}
.growth-rule {
  border-top: 1px solid var(--c-e3e5e8);
  padding-top: 20px;
}
.growth-rule h2 {
  font-size: 18px;
  margin: 0 0 13px;
}
.growth-rule .rules-body {
  font-size: 14px;
  line-height: 1.8;
}
.advance-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--c-e3e5e8);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.advance-page > .notice {
  margin: 16px 24px;
}
.growth-xp {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 0 22px;
  border-bottom: 1px solid var(--c-e3e5e8);
}
.growth-xp h2,
.growth-pending h2 {
  font-size: 16px;
  margin: 0 0 12px;
}
.xp-track {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
}
.xp-track strong {
  margin-left: 8px;
}
.xp-mark {
  width: 16px;
  height: 16px;
  border: 1px solid var(--c-8c96a5);
  border-radius: 50%;
}
.xp-mark.filled {
  background: var(--c-657286);
}
.growth-pending {
  margin: 22px 0;
}
.growth-history-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--c-eceef1);
}
.growth-history-row > div {
  flex: 1;
  min-width: 0;
}
.growth-history-row small {
  display: block;
  margin-top: 4px;
  color: var(--c-626b78);
  font-size: 12px;
}
.growth-level {
  color: var(--c-626b78);
  min-width: 42px;
  font-size: 13px;
}
.growth-config {
  padding-top: 18px;
  margin-top: 20px;
  border-top: 1px solid var(--c-e3e5e8);
}
.growth-config h3 {
  font-size: 16px;
  margin: 0 0 14px;
}
.growth-config .inline-check {
  margin: 8px 0;
  font-size: 14px;
}
.growth-config select,
.growth-config input,
.growth-config textarea {
  width: 100%;
}
.growth-config .inline-check input {
  width: auto;
}
.class-change-section {
  margin-bottom: 22px;
}
.class-change-section h2 {
  font-size: 17px;
}
.class-change-progress {
  font-size: 13px;
  color: var(--c-626b78);
}
@media (max-width: 700px) {
  .advance-heading {
    padding: 18px 16px;
  }
  .advance-heading h1 {
    font-size: 18px;
  }
  .advance-layout {
    display: block;
  }
  .growth-slots {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    border-right: 0;
    border-bottom: 1px solid var(--c-e3e5e8);
    padding: 12px;
  }
  .growth-slot {
    padding: 10px;
    border-color: var(--c-e3e5e8);
    margin: 0;
  }
  .growth-content {
    padding: 18px 16px;
  }
  .growth-candidate-list {
    grid-template-columns: minmax(0, 1fr);
    max-height: 240px;
  }
  .advance-footer {
    padding: 14px 16px;
  }
  .growth-xp {
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
  }
  .growth-xp > .toolbar {
    width: 100%;
    justify-content: flex-end;
  }
  .growth-history-row {
    gap: 10px;
  }
}
@media print {
  .growth-slots,
  .advance-footer {
    display: none;
  }
}
.growth-hp {
  max-width: 180px;
  margin-top: 16px;
}
.growth-hp input {
  width: 100%;
}
.advance-page > .class-change-progress {
  margin: 0 24px 18px;
}
.xp-mark {
  flex: 0 0 16px;
}
.xp-track strong {
  white-space: nowrap;
  flex: 0 0 auto;
}
.growth-slot:disabled {
  color: var(--c-7a818a);
  cursor: default;
  opacity: 0.7;
}
.growth-rule > .growth-config:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--c-e3e5e8);
  margin-bottom: 20px;
}
.advance-page {
  width: 100%;
  min-width: 0;
}
/* The action row stays within the scrollable main region, above global navigation. */
.advance-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  z-index: 2;
}
@media (max-width: 599px) {
  .app-shell:has(.mode-advance) .app-header {
    flex-wrap: nowrap;
    height: 52px;
    min-height: 52px;
    flex-basis: 52px;
  }
  .app-shell:has(.mode-advance) .header-actions {
    flex: 0 0 auto;
    width: auto;
  }
  .app-shell:has(.mode-advance) .app-title {
    flex: 1 1 auto;
  }
}

/* Rules library: filterable index on the left, a persistent reading pane on the right.
   Below 900px the two panes become separate screens, switched by the current selection. */
.page-content.mode-reference {
  height: 100%;
  min-height: 0;
  max-width: 1360px;
  padding: 20px 24px;
  overflow: hidden;
}
.reference-page {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 20px;
  height: 100%;
  min-height: 0;
}
.reference-index,
.reference-detail {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.reference-index {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.reference-index-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 8px;
  border-bottom: 1px solid var(--line-light);
}
.reference-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-soft);
}
.reference-tabs button {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  padding: 6px 6px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.reference-tabs button:hover {
  color: var(--ink);
}
.reference-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(20 25 32 / 10%);
}
.ref-tab-count {
  color: var(--c-8b929b);
  font-size: 11px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.ref-search {
  position: relative;
  display: block;
}
.ref-search .search {
  min-height: 38px;
  padding: 8px 12px 8px 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 14px;
}
.ref-search .search:hover {
  border-color: var(--line);
}
.ref-search .search:focus {
  border-color: var(--focus);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 3px rgb(51 107 176 / 14%);
}
.ref-search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 12px;
  height: 12px;
  margin-top: -7px;
  border: 1.5px solid var(--c-8b929b);
  border-radius: 50%;
  pointer-events: none;
}
.ref-search-icon::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 1.5px;
  background: var(--c-8b929b);
  transform: rotate(45deg);
}
.reference-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reference-filters:empty {
  display: none;
}
.ref-filter-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}
.ref-filter-label {
  padding-top: 5px;
  color: var(--c-8b929b);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ref-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ref-chips-segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: var(--surface-soft);
}
.ref-chips-segmented .ref-chip {
  min-height: 26px;
  padding: 2px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}
.ref-chips-segmented .ref-chip:hover {
  color: var(--ink);
}
.ref-chips-segmented .ref-chip.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(20 25 32 / 12%);
}
.ref-chip {
  min-height: 26px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--c-4b525b);
  font-size: 12px;
  white-space: nowrap;
}
.ref-chip:hover {
  border-color: var(--c-aeb3ba);
  color: var(--ink);
}
.ref-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}
.reference-results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
}
.reference-results-toolbar .text-button {
  padding: 2px 0;
}
.reference-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 8px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ref-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 12px 8px 6px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(4px);
  color: var(--c-7a818b);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
}
.ref-item {
  display: block;
  width: 100%;
  margin: 1px 0;
  padding: 8px 10px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
}
.ref-item:hover {
  background: var(--surface-soft);
}
.ref-item[aria-current='true'] {
  border-color: var(--c-cfd8e3);
  background: var(--c-eef3f8);
}
.ref-item:focus-visible {
  outline-offset: -2px;
}
.ref-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ref-item-name {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.ref-item-preview {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.reference-list mark {
  padding: 0 1px;
  border-radius: 2px;
  background: var(--c-fbe7a1);
  color: inherit;
}
.reference-list > .empty-state {
  min-height: 0;
  margin: 24px 6px;
  border: 0;
  background: none;
  color: var(--muted);
  line-height: 1.8;
  text-align: center;
}
.ref-badge {
  flex: 0 0 auto;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--c-eef0f2);
  color: var(--c-5c636c);
  font-size: 11px;
  font-weight: 500;
  line-height: 19px;
  white-space: nowrap;
}
.ref-badge-class {
  background: var(--c-ece7f6);
  color: var(--c-5b4290);
}
.ref-badge-path {
  background: var(--c-e3eef9);
  color: var(--c-2c5b8a);
}
.ref-badge-struggle {
  background: var(--c-f8ece2);
  color: var(--c-8a4b22);
}
.ref-badge-warning {
  background: var(--c-fbf1d9);
  color: var(--c-7d5a12);
}
.reference-detail {
  display: flex;
  flex-direction: column;
  padding: 32px 44px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
}
.reference-detail > :last-child:not(.ref-related) {
  margin-bottom: 44px;
}
.reference-detail > * {
  max-width: 760px;
}
.ref-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-light);
}
.ref-detail-head h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
}
.ref-detail-head .ref-badge {
  font-size: 12px;
  line-height: 22px;
  padding: 0 9px;
}
.ref-crumbs {
  display: flex;
  flex-basis: 100%;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.ref-crumbs span {
  color: var(--c-a6abb2);
}
.ref-back {
  display: none;
}
.ref-lead {
  margin: 18px 0 0;
  padding-left: 12px;
  border-left: 3px solid var(--line);
  color: var(--c-4a525c);
  font-size: 15px;
  line-height: 1.75;
}
.reference-detail .rules-body {
  margin-top: 18px;
  font-size: 15px;
  line-height: 1.85;
}
.ref-path-moves {
  margin-top: 8px;
}
.ref-path-move {
  padding: 20px 0 4px;
  border-top: 1px solid var(--line-light);
}
.ref-path-move:first-child {
  border-top: 0;
}
.ref-path-move h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 17px;
}
.ref-path-move .rules-body {
  margin-top: 8px;
}
.ref-inline-link {
  padding: 0;
  color: var(--ink);
  font-weight: 650;
  text-align: left;
}
.ref-inline-link:hover {
  color: var(--focus);
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* Sibling switcher pinned to the bottom edge of the reading pane: pushed down when the rule is short,
   sticky when it is long, so it never moves while switching between siblings. */
.ref-related {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 14px 0 20px;
  border-top: 1px solid var(--line-light);
  background: var(--surface);
}
.reference-detail > .ref-related {
  width: 100%;
}
.reference-detail > :has(+ .ref-related) {
  margin-bottom: 28px;
}
.ref-related h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.ref-related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ref-related-item {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
}
.ref-related-item:hover {
  border-color: var(--c-aeb3ba);
}
.ref-related-item small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 11px;
}
.ref-related-item[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.ref-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: none;
  height: 100%;
  color: var(--muted);
  text-align: center;
}
.ref-empty p {
  max-width: 400px;
  margin: 0;
  line-height: 1.8;
}
.ref-empty .ref-empty-title {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}
@media (max-width: 899px) {
  .page-content.mode-reference {
    padding: 0;
  }
  .reference-page {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .reference-index,
  .reference-detail {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .reference-page.has-selection .reference-index,
  .reference-page:not(.has-selection) .reference-detail {
    display: none;
  }
  .reference-index-head {
    padding: 12px 14px 8px;
  }
  .ref-search .search {
    font-size: 16px;
  }
  .ref-chips-pills {
    flex-wrap: nowrap;
    margin-right: -14px;
    padding: 0 14px 2px 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .ref-chips::-webkit-scrollbar {
    display: none;
  }
  .reference-list {
    padding: 0 6px 16px;
  }
  .ref-item {
    padding: 10px;
  }
  .reference-detail {
    padding: 14px 18px 0;
  }
  .reference-detail > :last-child:not(.ref-related) {
    margin-bottom: 36px;
  }
  .ref-back {
    display: inline-flex;
    flex-basis: 100%;
    padding: 4px 0 8px;
    color: var(--focus);
    font-size: 14px;
  }
  .ref-detail-head h1 {
    font-size: 21px;
  }
  .reference-detail .rules-body {
    font-size: 15px;
  }
}

/* Trackers ("风采：□ □ □", "记忆 □ □ □ □ □") render as one row of boxes. */
.rules-body .rule-track {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.rule-track-boxes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rule-track-box {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--c-7d858f);
  border-radius: 3px;
  background: var(--surface);
}
.rule-track-box.marked {
  border-color: var(--accent);
  background: var(--accent);
}
.rule-track-gap {
  width: 1px;
  height: 15px;
  margin: 0 3px;
  background: var(--c-b4bac2);
}

/* Character sheet: one page modelled on the official Beta v3 sheet.
   Desktop: identity | moves | vitals+gear. Narrower screens stack vitals first. */
.page-content.mode-sheet:has(.cs-screen) {
  max-width: 1480px;
}
.sheet-screen.cs-screen {
  max-width: none;
  padding: 0;
  border: 0;
  background: none;
}
.cs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.cs-toolbar .view-tabs {
  flex: 0 0 auto;
}
.cs-toolbar .view-tabs button {
  min-width: 84px;
}
.sheet-screen.cs-growth-screen {
  max-width: 1000px;
  margin: 0 auto;
}
.sheet-screen > .cs-toolbar + .growth-page {
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.cs-screen > .notice,
.cs-screen > .incomplete-character {
  margin-bottom: 14px;
}
.cs-sheet {
  --cs-serif: 'Songti SC', 'Noto Serif SC', 'Source Han Serif SC', 'STSong', serif;
  --cs-rule: var(--c-2b2f35);
  /* One column grid for the whole sheet: the top block, moves and shared moves split at the same lines. */
  --cs-cols: 3;
  --cs-gutter: 48px;
  --cs-divider: var(--line-light);
  padding: 26px 30px 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.cs-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 12px 32px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--cs-rule);
}
.cs-title h1 {
  display: flex;
  /* Serif name and sans pronoun: CJK glyphs fill the em box, so bottom-aligned boxes line up; baselines don't. */
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0;
  font-family: var(--cs-serif);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}
.cs-pronouns {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}
.cs-class {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 10px 0 0;
  line-height: 1.2;
  color: var(--muted);
  font-size: 13px;
}
.cs-class strong {
  color: var(--ink);
  font-family: var(--cs-serif);
  font-size: 15px;
}
.cs-label,
.cs-level > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.cs-level {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cs-level strong {
  min-width: 44px;
  padding: 0 6px;
  border-bottom: 2px solid var(--cs-rule);
  font-family: var(--cs-serif);
  font-size: 30px;
  line-height: 1.1;
  text-align: center;
}
.cs-xp {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cs-xp-track {
  display: flex;
  gap: 5px;
}
.cs-xp-dot,
.cs-dot,
.cs-use {
  display: inline-block;
  flex: 0 0 auto;
  border: 1.5px solid var(--c-59606a);
  border-radius: 50%;
  background: var(--surface);
}
.cs-xp-dot {
  width: 18px;
  height: 18px;
}
.cs-dot {
  width: 11px;
  height: 11px;
}
.cs-use {
  width: 10px;
  height: 10px;
}
.cs-xp-dot.filled,
.cs-dot.filled {
  border-color: var(--cs-rule);
  background: var(--cs-rule);
}
.cs-stepper {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.cs-stepper button {
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
}
.cs-stepper button + button {
  border-left: 1px solid var(--line);
}
.cs-stepper button:hover:not(:disabled) {
  background: var(--surface-soft);
}

.cs-col {
  min-width: 0;
}

.cs-section + .cs-section {
  margin-top: 22px;
}
.cs-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--cs-rule);
}
.cs-section-head h2 {
  margin: 0 0 3px;
  font-family: var(--cs-serif);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.cs-edit {
  padding: 2px 0;
  color: var(--muted);
  font-size: 12px;
}
.cs-edit:hover {
  color: var(--focus);
}
.cs-empty,
.cs-blank {
  color: var(--c-9aa0a8);
}
.cs-empty {
  margin: 0;
  font-size: 13px;
}
.cs-note {
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.cs-note.warning {
  color: var(--warning);
}

/* Vitals: HP + five stats, then armor + five conditions, as on the paper sheet. */
.cs-vitals-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px 6px;
}
.cs-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  text-align: center;
}
.cs-cell-head {
  font-family: var(--cs-serif);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.cs-cell-foot {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.cs-stat-box {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 48px;
  aspect-ratio: 1;
  border: 2px solid var(--cs-rule);
  border-radius: 4px;
  font-family: var(--cs-serif);
  font-size: 22px;
  font-weight: 800;
}
.cs-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 52px;
}
.cs-icon svg {
  width: 100%;
  height: auto;
  fill: var(--surface);
  stroke: var(--cs-rule);
  stroke-width: 2.5;
}
.cs-icon > strong,
.cs-hp-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.cs-icon > strong,
.cs-hp-value strong {
  font-family: var(--cs-serif);
  font-size: 19px;
  font-weight: 800;
}
.cs-hp-value {
  padding-bottom: 5px;
}
.cs-hp .cs-stepper button {
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  font-size: 13px;
}
.cs-armor {
  grid-column: 1;
}
.cs-armor .cs-icon {
  max-width: 44px;
}
.cs-condition {
  justify-content: flex-start;
  padding-top: 4px;
}

/* Gear */
.cs-items {
  display: flex;
  flex-direction: column;
}

.cs-item-name {
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: var(--c-c5cad1);
  text-underline-offset: 3px;
}

.cs-item-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cs-damage {
  font-family: var(--cs-serif);
  font-size: 13px;
  font-weight: 800;
}
.cs-chip {
  padding: 0 6px;
  border-radius: 3px;
  background: var(--surface-soft);
  color: var(--c-566070);
  font-size: 11px;
  line-height: 18px;
}

/* Moves */

.cs-subhead {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.cs-move-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 4px;
  font-family: var(--cs-serif);
  font-size: 16px;
  font-weight: 800;
}

.cs-move-full {
  margin-top: 6px;
  font-size: 12px;
}
.cs-move-full > summary {
  color: var(--muted);
  cursor: pointer;
}

/* Identity */
.cs-origins {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
  font-size: 13px;
}
.cs-origins dt {
  color: var(--muted);
}
.cs-origins dd {
  margin: 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-light);
}
.cs-bond-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.cs-bond-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-light);
}
.cs-bond-list strong {
  font-size: 13px;
}
.cs-bond-list p {
  margin: 1px 0 0;
  color: var(--c-4a525c);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.55;
}
.cs-notes p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}
.cs-growth-list {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.cs-growth-list li {
  display: flex;
  gap: 10px;
  padding: 4px 0;
}
.cs-growth-level {
  flex: 0 0 34px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 759px) {
  .cs-toolbar [data-action='print'] {
    display: none;
  }
  .cs-toolbar-actions {
    flex: 1 1 100%;
  }
  .cs-toolbar-actions .btn {
    flex: 1 1 0;
  }
  .cs-toolbar .view-tabs {
    flex: 1 1 auto;
  }
  .cs-sheet {
    padding: 18px 16px 22px;
    border-radius: 8px;
  }
  .cs-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .cs-title {
    grid-column: 1 / -1;
  }
  .cs-title h1 {
    font-size: 26px;
  }
}
@media print {
  @page {
    size: A4 landscape;
    margin: 9mm;
  }
  .page-content.mode-sheet:has(.cs-screen) {
    max-width: none;
  }
  .cs-sheet {
    padding: 0;
    border: 0;
    box-shadow: none;
    font-size: 9pt;
  }

  .cs-move-full {
    display: none;
  }
}

/* Character sheet layout: three balanced columns on top, then moves flowing into up to three columns
   (masonry via CSS columns), so many moves no longer stretch one column while the others stay empty. */
.cs-top {
  display: grid;
  grid-template-columns: repeat(var(--cs-cols), minmax(0, 1fr));
  gap: 0 var(--cs-gutter);
  margin-top: 18px;
}
/* Column dividers sit in the middle of the gutter, where the moves' column rule is drawn. */
.cs-col {
  position: relative;
}
.cs-col-gear::before,
.cs-col-gear::after {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--cs-divider);
  content: '';
}
.cs-col-gear::before {
  left: calc(var(--cs-gutter) / -2);
}
.cs-col-gear::after {
  right: calc(var(--cs-gutter) / -2);
}
.cs-col-vitals {
  grid-column: 3;
  grid-row: 1;
}
.cs-col-gear {
  grid-column: 2;
  grid-row: 1;
}
.cs-col-identity {
  grid-column: 1;
  grid-row: 1;
}
.cs-moves {
  margin-top: 26px;
}
.cs-setup {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 13px;
}
.cs-schools {
  flex: 1 1 280px;
}
.cs-schools > div {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  padding: 2px 0;
}
.cs-schools span {
  color: var(--muted);
}
.cs-move-flow {
  column-count: var(--cs-cols);
  column-gap: var(--cs-gutter);
  column-rule: 1px solid var(--cs-divider);
}
.cs-move {
  break-inside: avoid;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}
.cs-move .rules-body {
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.75;
}
.cs-move .rules-body p {
  margin: 6px 0;
}
.cs-move .rules-body li {
  margin: 4px 0;
}
.cs-conditional {
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid var(--line);
  background: var(--surface-soft);
  font-size: 12.5px;
}
.cs-conditional p {
  margin: 4px 0 0;
  color: var(--c-4a525c);
}

/* Trackers: every box/circle on the sheet is a button that saves play state. */
.cs-track {
  display: inline-flex;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 3px;
}
button.cs-dot,
button.cs-use,
button.cs-box,
button.rule-track-box,
button.cs-condition-mark {
  padding: 0;
  cursor: pointer;
  transition:
    background-color 0.12s,
    box-shadow 0.12s;
}
button.cs-dot,
button.cs-use {
  width: 14px;
  height: 14px;
}
button.cs-dot:hover,
button.cs-use:hover,
button.cs-box:hover,
button.rule-track-box:hover,
button.cs-condition-mark:hover {
  box-shadow: 0 0 0 3px rgb(51 107 176 / 18%);
}
.cs-use.filled {
  border-color: var(--cs-rule);
  background: var(--cs-rule);
}
.cs-box {
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--c-59606a);
  border-radius: 2px;
  background: var(--surface);
}
.cs-box.filled,
.rule-track-box.marked {
  border-color: var(--cs-rule);
  background: var(--cs-rule);
}
.cs-condition-mark {
  position: relative;
  width: 100%;
  max-width: 38px;
  aspect-ratio: 1;
  border: 2px solid var(--cs-rule);
  border-radius: 50%;
  background: var(--surface);
}
.cs-condition-mark.marked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 18%;
  right: 18%;
  height: 2.5px;
  margin-top: -1.25px;
  background: var(--cs-rule);
  transform: rotate(-35deg);
}
.cs-condition-mark.locked {
  background: var(--cs-rule);
}
.cs-stat.hindered .cs-stat-box {
  border-color: var(--danger);
  color: var(--danger);
}
.cs-dis {
  padding: 0 5px;
  border-radius: 3px;
  background: var(--c-f8e4e4);
  color: var(--danger);
  font-weight: 700;
}
.cs-hint {
  margin: 8px 0 0;
  color: var(--c-9aa0a8);
  font-size: 11px;
}

/* Gear rows: name and tags open the description; the uses track stays clickable outside it. */
.cs-items {
  display: flex;
  flex-direction: column;
}
.cs-item {
  border-bottom: 1px dashed var(--line);
}
.cs-item.spent .cs-item-name {
  color: var(--c-9aa0a8);
  text-decoration-line: line-through;
}
.cs-item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
}
.cs-item-detail {
  flex: 1 1 auto;
  min-width: 0;
}
.cs-item-detail > summary,
div.cs-item-detail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  list-style: none;
}
.cs-item-detail > summary {
  cursor: pointer;
}
.cs-item-detail > summary::-webkit-details-marker {
  display: none;
}
.cs-item-detail > summary::after {
  content: '';
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid var(--c-9aa0a8);
  border-bottom: 1.5px solid var(--c-9aa0a8);
  transform: rotate(45deg) translateY(-2px);
}
.cs-item-detail[open] > summary::after {
  transform: rotate(-135deg) translateY(-1px);
}
.cs-item-detail[open] > .rules-body,
.cs-item-detail[open] > .equipment-member {
  padding: 6px 0 4px;
}
.cs-item .rules-body {
  margin-top: 0;
  font-size: 13px;
  line-height: 1.7;
}
.cs-item-row > .cs-track {
  padding-top: 3px;
}
.cs-resources {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}
.cs-resources > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.cs-wealth {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-light);
}
.cs-subhead-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.cs-subhead-row .cs-subhead {
  margin: 0;
}
.cs-tier {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  color: var(--muted);
  font-size: 12px;
}
.cs-tier.current {
  color: var(--ink);
  font-weight: 650;
}
.cs-tier .cs-note {
  margin: 0;
}
.rule-track-boxes.cs-live {
  gap: 5px;
}
button.rule-track-box {
  width: 16px;
  height: 16px;
}

@media (max-width: 1179px) {
  .cs-sheet {
    --cs-cols: 2;
    --cs-gutter: 40px;
  }
  .cs-top {
    row-gap: 22px;
  }
  .cs-col-vitals {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .cs-col-gear {
    grid-column: 1;
    grid-row: 2;
  }
  .cs-col-gear::before {
    display: none;
  }
  .cs-col-identity {
    grid-column: 2;
    grid-row: 2;
  }
  /* The full-width vitals row puts growth beside the stats, on the same two columns as below. */
  .cs-col-vitals {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    column-gap: var(--cs-gutter);
  }
  .cs-col-vitals > .cs-section + .cs-section {
    margin-top: 0;
  }
}
@media (max-width: 759px) {
  .cs-sheet {
    --cs-cols: 1;
  }
  .cs-col-vitals,
  .cs-col-gear,
  .cs-col-identity {
    grid-column: 1;
    grid-row: auto;
  }
  .cs-col-gear::after {
    display: none;
  }
  /* Single column: growth drops below gear and identity, which matter more at the table. */
  .cs-col-vitals {
    display: contents;
  }
  .cs-col-vitals > .cs-growth {
    order: 1;
  }
}
@media print {
  /* A4 landscape is ~1123px wide, inside the tablet breakpoint: pin the three-column layout explicitly. */
  .cs-sheet {
    --cs-cols: 3;
    --cs-gutter: 28px;
    --cs-divider: var(--c-cccccc);
  }
  .cs-top {
    row-gap: 0;
  }
  .cs-col-gear::before,
  .cs-col-gear::after {
    display: block;
  }
  .cs-col-vitals,
  .cs-col-gear,
  .cs-col-identity {
    grid-row: 1;
  }
  .cs-col-vitals {
    display: block;
    grid-column: 3;
  }
  .cs-col-vitals > .cs-section + .cs-section {
    margin-top: 22px;
  }
  .cs-col-gear {
    grid-column: 2;
  }
  .cs-col-identity {
    grid-column: 1;
  }
  .cs-hint,
  .cs-item-detail > summary::after {
    display: none;
  }
  .cs-move .rules-body,
  .cs-item .rules-body {
    font-size: 8.5pt;
    line-height: 1.5;
  }
}

/* Shared moves, bonds and in-text rule links */

.ref-badge-core {
  background: var(--c-e4f1e8);
  color: var(--c-2f6a43);
}
.ref-badge-extra {
  background: var(--c-e2f0f1);
  color: var(--c-2b6468);
}
.ref-badge-campaign {
  background: var(--c-f1e8f5);
  color: var(--c-6f3f80);
}
.ref-badge-bond {
  background: var(--c-fae6ec);
  color: var(--c-8f3450);
}
.ref-bond-prompt {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface-soft);
}
.reference-detail .ref-bond-prompt {
  margin-top: 14px;
}
.ref-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.rule-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline dotted var(--c-9aa0a8);
  text-underline-offset: 3px;
  cursor: pointer;
}
.rule-link:hover {
  color: var(--focus);
  text-decoration-color: currentColor;
}
.cs-basic {
  margin-top: 26px;
}
.cs-basic-groups {
  display: grid;
  grid-template-columns: repeat(var(--cs-cols), minmax(0, 1fr));
  gap: 14px var(--cs-gutter);
}
.cs-basic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cs-basic-move {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}
.cs-basic-move small {
  color: var(--muted);
  font-size: 11px;
}
.cs-basic-move:hover {
  border-color: var(--focus);
  color: var(--focus);
}

@media (max-width: 420px) {
  .reference-tabs button {
    gap: 2px;
    padding-inline: 3px;
  }
}

/* Tag tooltips (src/ui/tooltip.js) */

[data-tip] {
  cursor: help;
}
[data-tip]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
#tip {
  position: fixed;
  z-index: 200;
  max-width: min(320px, calc(100vw - 16px));
  padding: 7px 10px;
  border-radius: 5px;
  background: var(--c-2b313a);
  color: var(--surface);
  box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
  font: 12px/1.6 var(--sans);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
#tip.visible {
  opacity: 1;
}
@media print {
  #tip {
    display: none;
  }
}

/* Choices a move asks for, filled in on the sheet like the blanks on the paper character sheet. */

.cs-move-config {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 6px 0 10px;
}
.cs-field {
  display: flex;
  flex: 1 1 160px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cs-field-wide {
  flex-basis: 100%;
}
.cs-field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.cs-field-label small {
  font-weight: 400;
}
.cs-field input,
.cs-field textarea,
.cs-field select {
  width: 100%;
  min-height: 30px;
  padding: 3px 2px;
  border: 0;
  border-bottom: 1px solid var(--c-b9bec5);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.cs-field textarea {
  resize: vertical;
  line-height: 1.6;
}
.cs-field input::placeholder,
.cs-field textarea::placeholder {
  color: var(--c-b3b8bf);
}
.cs-field input:focus,
.cs-field textarea:focus,
.cs-field select:focus {
  border-bottom-color: var(--focus);
  outline: none;
  background: var(--surface-soft);
}
.cs-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 3px;
}
.cs-pick {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}
.cs-pick:hover {
  border-color: var(--c-aeb3ba);
  color: var(--ink);
}
.cs-pick[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}
@media print {
  .cs-field input,
  .cs-field textarea,
  .cs-field select {
    min-height: 0;
    appearance: none;
    resize: none;
  }
  .cs-pick[aria-pressed='false'] {
    display: none;
  }
}

/* Sheet play actions (src/ui/play.js): camp, end of session and bonds formed in play. */

.cs-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.cs-formed-bonds .text-button {
  margin-top: 6px;
}
.cs-bond {
  padding: 8px 0 10px;
  border-bottom: 1px dashed var(--line);
}
.cs-bond-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cs-bond-head strong {
  font-family: var(--cs-serif);
  font-size: 15px;
}
.cs-bond-head span {
  color: var(--muted);
  font-size: 13px;
}
.cs-bond-remove {
  margin-left: auto;
  padding: 0 4px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}
.cs-bond-remove:hover {
  color: var(--danger);
}
.cs-bond .cs-note {
  margin: 2px 0 0;
}
.play-list {
  margin: 0 0 12px;
  padding-left: 18px;
}
.play-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.play-choice legend {
  margin-bottom: 6px;
  font-weight: 600;
}
.play-reminders {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 13px;
}
.play-reminders h3 {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}
.play-reminders p {
  margin: 4px 0;
}
.play-total {
  margin: 8px 0 0;
}
.play-total strong {
  font-size: 18px;
}
@media (max-width: 759px) {
  .cs-toolbar {
    flex-wrap: wrap;
  }
}

/* Character library: current status on each card, sort and full backup. */

.character-status {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  color: var(--muted);
}
.character-status strong {
  color: var(--ink);
}
.character-conditions {
  color: var(--danger);
}
.library-sort {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Dark theme. index.html sets data-theme="dark" from the stored choice (跟随系统 / 浅色 / 深色) or the
   system preference; print always uses the light values. Main tokens are tuned by hand, the palette was
   generated by flipping OKLCH lightness and keeping hue, so tinted badges keep their colour family. */
@media screen {
  :root[data-theme='dark'] {
    color-scheme: dark;
    --ink: #e4e6e9;
    --muted: #9ba1a9;
    --canvas: #141619;
    --chrome: #1b1e22;
    --surface: #1e2125;
    --surface-soft: #262a2e;
    --line: #3a3f45;
    --line-light: #2c3035;
    --accent: #cdd4de;
    --accent-soft: #2c3138;
    --focus: #6ea6ea;
    --danger: #e57373;
    --warning: #d6a64f;
    --success: #72b88d;
    --shadow: 0 1px 2px rgb(0 0 0 / 35%);
    --c-111111: #e5e5e5;
    --c-1d426f: #84b1eb;
    --c-222222: #d0d0d0;
    --c-22252a: #c9cdd5;
    --c-262c35: #bec6d3;
    --c-293545: #adbed4;
    --c-2b2f35: #bdc3cb;
    --c-2b313a: #b8c1cd;
    --c-2b6468: #63a3a7;
    --c-2c5b8a: #669cd5;
    --c-2d3540: #b2bdcc;
    --c-2e3742: #afbbca;
    --c-2e3d50: #a2b6cf;
    --c-2f4968: #8babd3;
    --c-2f6a43: #63a677;
    --c-303946: #adb9ca;
    --c-303a48: #aab8cb;
    --c-333d4b: #a8b5c8;
    --c-34383e: #b3b9c1;
    --c-343a43: #afb7c3;
    --c-344053: #a2b1ca;
    --c-354254: #9fb0c8;
    --c-363f4c: #a7b2c4;
    --c-365d8a: #6b99ce;
    --c-383e47: #abb3bf;
    --c-394554: #9eadc1;
    --c-3a4656: #9dacc1;
    --c-3b414b: #a8b0bd;
    --c-3b4553: #a0adbf;
    --c-3d4c60: #94a7c0;
    --c-424750: #a3a9b5;
    --c-424b57: #9ba7b6;
    --c-445569: #8a9fb7;
    --c-454b55: #9ea5b2;
    --c-476a52: #739c7f;
    --c-477254: #679875;
    --c-494d53: #9ea3ab;
    --c-496078: #7b96b2;
    --c-4a525c: #96a0ac;
    --c-4a5666: #8e9cb0;
    --c-4b525b: #979fab;
    --c-4d5867: #8d9aac;
    --c-515b6b: #8b97aa;
    --c-526175: #8192aa;
    --c-566070: #8692a5;
    --c-566b83: #738ba7;
    --c-59606a: #8a929e;
    --c-5b4290: #a489e7;
    --c-5c636c: #878f9a;
    --c-5c6878: #7e8c9e;
    --c-5e6268: #8b8f96;
    --c-60656d: #878d96;
    --c-616d7c: #7a8798;
    --c-62666e: #878b95;
    --c-62676f: #858b94;
    --c-626b78: #7e8897;
    --c-626c7a: #7c8798;
    --c-626d7c: #7a8798;
    --c-626e7e: #788698;
    --c-637083: #75849a;
    --c-637569: #74887b;
    --c-646d79: #7c8794;
    --c-657286: #738299;
    --c-666666: #8b8b8b;
    --c-687381: #758291;
    --c-687483: #748192;
    --c-687b92: #677c96;
    --c-69717c: #7a838f;
    --c-697483: #748191;
    --c-6a7078: #7c838c;
    --c-6a717b: #7b828e;
    --c-6a727d: #79828e;
    --c-6a737f: #77818f;
    --c-6b7e96: #657994;
    --c-6c747f: #77808c;
    --c-6c7683: #747f8d;
    --c-6f3f80: #b980ce;
    --c-6f747c: #7a7f88;
    --c-6f7681: #767e8a;
    --c-707681: #777d8a;
    --c-717985: #737c89;
    --c-727780: #777c86;
    --c-727882: #757c87;
    --c-727b87: #707a87;
    --c-737e8c: #6c7887;
    --c-747982: #757b85;
    --c-747d88: #6f7985;
    --c-758396: #657489;
    --c-76859b: #62728a;
    --c-777c84: #737881;
    --c-77818f: #6a7584;
    --c-778290: #697584;
    --c-77879d: #607188;
    --c-7a622e: #a3874d;
    --c-7a8089: #6f757f;
    --c-7a818a: #6d757f;
    --c-7a818b: #6d757f;
    --c-7b8490: #69737f;
    --c-7b8592: #677280;
    --c-7c8da0: #5b6d81;
    --c-7d5a12: #b1883e;
    --c-7d858f: #69727c;
    --c-7d8590: #69717d;
    --c-7d8998: #626f7f;
    --c-7d899a: #626f81;
    --c-82652f: #a38245;
    --c-8390a0: #5c6a7a;
    --c-87642d: #a77f41;
    --c-886b35: #9d7c40;
    --c-89929e: #5e6773;
    --c-8a4b22: #c87e50;
    --c-8a95a3: #5a6573;
    --c-8b929b: #606770;
    --c-8c6529: #a87b38;
    --c-8c96a5: #596473;
    --c-8f3450: #dc708d;
    --c-929ba8: #57606d;
    --c-96522f: #c2734c;
    --c-969eaa: #555d69;
    --c-9a4343: #d16c6a;
    --c-9aa0a8: #555b63;
    --c-9b4545: #cf6b69;
    --c-9da3ac: #535962;
    --c-a3abb7: #4b535f;
    --c-a3adbc: #485260;
    --c-a6abb2: #4e5359;
    --c-a98240: #8d640e;
    --c-aaaaaa: #525252;
    --c-aeb3ba: #484d53;
    --c-b3b8bf: #444950;
    --c-b4bac2: #42484f;
    --c-b8c0cb: #3c444e;
    --c-b9bec5: #40454b;
    --c-bac9d9: #313f4d;
    --c-bbc3ce: #3a424b;
    --c-bfc8d5: #363e4a;
    --c-c3cad4: #363c45;
    --c-c58d8d: #814a4b;
    --c-c5cad1: #383c42;
    --c-c6c8cc: #3b3d40;
    --c-c7cacf: #393c40;
    --c-c7cdd6: #353a42;
    --c-c9ac76: #654901;
    --c-c9cdd4: #363a40;
    --c-cbd1da: #313741;
    --c-cccccc: #3a3a3a;
    --c-cdd2db: #313640;
    --c-cfd8e3: #2a343f;
    --c-cfdae6: #273340;
    --c-d2d7df: #2e333c;
    --c-d3d6dc: #30333a;
    --c-d3dae4: #2a323c;
    --c-d4dbe5: #29313c;
    --c-d5d8de: #2f3239;
    --c-d5dce5: #29303a;
    --c-d5e1d8: #253229;
    --c-d7d9de: #2f3137;
    --c-d8dce3: #2b3037;
    --c-d8dfe7: #272f37;
    --c-d9dce1: #2c3035;
    --c-d9dce2: #2c2f36;
    --c-d9dde4: #2b2f36;
    --c-d9dfe6: #282e36;
    --c-d9e1ea: #252e37;
    --c-dcdfe3: #2b2e32;
    --c-dcdfe4: #2a2e33;
    --c-dce0e6: #292d34;
    --c-dce1e8: #272d34;
    --c-dce3ec: #252c35;
    --c-dedfe3: #2c2d31;
    --c-dee4ec: #252b33;
    --c-dfe2e7: #292c31;
    --c-dfe4e9: #262b30;
    --c-e0d4bc: #3f3214;
    --c-e0e5ec: #252a31;
    --c-e0e6ed: #242a31;
    --c-e1e3e7: #292b2f;
    --c-e1e5eb: #262a30;
    --c-e1e7ef: #232931;
    --c-e2f0f1: #182829;
    --c-e3e5e8: #282a2d;
    --c-e3e7ed: #25292f;
    --c-e3eef9: #1a2631;
    --c-e4e9ef: #23282e;
    --c-e4f1e8: #1a281f;
    --c-e5d7bb: #3d2f11;
    --c-e5e9ee: #23282d;
    --c-e5eaf0: #22272d;
    --c-e6c7c7: #4e2d2e;
    --c-e6dcc6: #382d13;
    --c-e6e7e9: #27282a;
    --c-e6e9ed: #24272b;
    --c-e6e9ee: #24272c;
    --c-e6eaf0: #23272d;
    --c-e6ebf0: #22272c;
    --c-e8eaee: #24262a;
    --c-e8edf4: #20252c;
    --c-e9eaed: #252629;
    --c-e9ecf0: #22252a;
    --c-e9edf2: #21252a;
    --c-ece7f6: #292332;
    --c-eceef1: #222427;
    --c-edf0f5: #202328;
    --c-eef0f2: #212325;
    --c-eef1f4: #1f2326;
    --c-eef1f5: #1f2226;
    --c-eef3f8: #1d2227;
    --c-eff0f2: #212224;
    --c-f0f3f7: #1e2125;
    --c-f0f5f1: #1d221e;
    --c-f1e8f5: #2a212e;
    --c-f1f3f6: #1f2124;
    --c-f1f5f9: #1c2024;
    --c-f2f3f5: #202123;
    --c-f2f4f7: #1e2023;
    --c-f3f5f8: #1e2023;
    --c-f4f4f5: #202021;
    --c-f4f5f6: #1f2021;
    --c-f4f5f7: #1e1f21;
    --c-f4f6f9: #1d1f22;
    --c-f5f5f6: #1f1f20;
    --c-f5f6f8: #1e1f21;
    --c-f5f7fa: #1c1e21;
    --c-f7f7f7: #1e1e1e;
    --c-f7f8f9: #1d1e1f;
    --c-f7f8fa: #1d1e20;
    --c-f8e4e4: #342121;
    --c-f8ece2: #2d2116;
    --c-f8f9fa: #1c1d1e;
    --c-f8f9fb: #1c1d1f;
    --c-f9fbfe: #1a1c1f;
    --c-fae6ec: #321e25;
    --c-faf6ec: #221e14;
    --c-fafbfc: #1b1c1d;
    --c-fbe7a1: #302706;
    --c-fbf1d9: #2b2003;
    --c-fbf3e4: #271f0f;
    --c-fbf7ee: #221e15;
    --c-fcf1f1: #281d1d;
    --c-fcf2f2: #261d1d;
    --c-fcfcfd: #1b1b1c;
    --c-fdfaf3: #1f1c15;
  }
}
