/* Theory tab — integrated into main app. Themed via [data-theme]. */

.th-page {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
}
.th-page-head {
  display: flex; align-items: end; justify-content: space-between; gap: 24px;
}
.th-h2 {
  margin: 0 0 2px;
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
[data-theme="rpg"] .th-h2 {
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: 0.04em;
}
.th-sub { font-size: 13px; color: var(--ink-3); }
.th-head-right { display: flex; align-items: center; gap: 16px; }
.th-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); }
.th-legend i.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.th-legend i.dot.empty    { background: var(--bg); border: 1px solid var(--hair-strong, var(--hair)); }
.th-legend i.dot.pending  { background: oklch(0.74 0.13 70); }
.th-legend i.dot.verified { background: oklch(0.66 0.13 160); }
[data-theme="rpg"] .th-legend i.dot.pending  { background: #ff7a30; }
[data-theme="rpg"] .th-legend i.dot.verified { background: #f0a060; }

.th-note { font-size: 12px; color: var(--ink-3); padding: 4px 0; }

.th-av {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: white; font-weight: 600; flex: none;
}
[data-theme="rpg"] .th-av {
  box-shadow: 0 0 0 2px rgba(255,220,170,0.45), inset 0 0 0 1px rgba(0,0,0,0.2);
}

.th-pp { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.th-pp-bar { position: relative; height: 6px; border-radius: 999px; background: var(--hair); overflow: hidden; }
[data-theme="rpg"] .th-pp-bar { background: rgba(255,220,170,0.12); }
.th-pp-fill { position: absolute; left: 0; top: 0; bottom: 0; background: oklch(0.74 0.13 70); border-radius: 999px; }
.th-pp-fill.verified { background: oklch(0.66 0.13 160); }
[data-theme="rpg"] .th-pp-fill { background: #ff7a30; }
[data-theme="rpg"] .th-pp-fill.verified { background: #f0a060; }
.th-pp-text { display: flex; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; }
.th-pp-num { font-weight: 600; color: var(--ink); }
.th-pp-den { color: var(--ink-3); font-weight: 400; }
.th-pp-pct { color: var(--ink-3); }

/* Matrix */
.th-matrix-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 220px);
  overflow: auto;
  border: 1px solid var(--hair);
  border-radius: 12px;
  background: var(--bg-elev);
}
[data-theme="rpg"] .th-matrix-wrap {
  background: linear-gradient(180deg, #1f0a09 0%, #160706 100%);
}
.th-matrix { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.th-matrix th, .th-matrix td {
  border-bottom: 1px solid var(--hair);
  text-align: center; vertical-align: middle;
  height: 56px; padding: 0 8px; box-sizing: border-box;
}
.th-matrix thead th { height: 96px; padding: 8px 6px; vertical-align: bottom; }

.th-mx-corner, .th-mx-progress {
  position: sticky; top: 0;
  background: var(--bg-elev);
  font-weight: 500; color: var(--ink-2); font-size: 12px;
  text-align: left; padding-left: 16px !important;
  z-index: 3;
}
.th-mx-corner { left: 0; width: 240px; min-width: 240px; z-index: 4; }
.th-mx-progress { right: 0; width: 180px; min-width: 180px; z-index: 4; }
.th-mx-row-head { position: sticky; left: 0; z-index: 1; }
.th-mx-prog { position: sticky; right: 0; background: var(--bg-elev); z-index: 1; }
[data-theme="rpg"] .th-mx-prog { background: #1f0a09; }
[data-theme="rpg"] .th-mx-corner, [data-theme="rpg"] .th-mx-progress { background: #1f0a09; }

.th-mx-col {
  font-weight: 500; color: var(--ink-2);
  vertical-align: bottom;
  width: 110px; min-width: 110px; max-width: 110px;
  cursor: pointer;
  position: sticky; top: 0;
  background: var(--bg-elev); z-index: 2;
}
[data-theme="rpg"] .th-mx-col { background: #1f0a09; }
.th-mx-col:hover .th-mx-title { color: var(--ink); }
.th-mx-glyph { font-size: 16px; margin-bottom: 6px; }
.th-mx-title {
  font-size: 11.5px; font-weight: 500;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 auto; color: var(--ink-2);
}

.th-mx-row-head {
  display: flex !important; align-items: center; gap: 10px;
  padding-left: 16px !important; text-align: left !important;
  position: sticky; left: 0; background: var(--bg-elev); z-index: 1;
  font-weight: 500; white-space: nowrap; color: var(--ink);
}
[data-theme="rpg"] .th-mx-row-head { background: #1f0a09; }
.th-mx-row-name { flex: 1; }
.th-mx-mine-badge {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 8px; border-radius: 999px;
  background: oklch(0.65 0.16 145); color: white;
}
[data-theme="rpg"] .th-mx-mine-badge { background: linear-gradient(180deg, #d57a45, #8d3618); color: #fff8e6; }

.th-matrix tr.mine .th-mx-row-head,
.th-matrix tr.mine .th-mx-prog {
  background: color-mix(in oklch, oklch(0.65 0.16 145) 14%, var(--bg-elev));
  box-shadow: inset 3px 0 0 oklch(0.65 0.16 145);
}
[data-theme="rpg"] .th-matrix tr.mine .th-mx-row-head,
[data-theme="rpg"] .th-matrix tr.mine .th-mx-prog {
  background: rgba(213, 122, 69, 0.18);
  box-shadow: inset 3px 0 0 #d57a45;
}

.th-mx-cell {
  width: 110px; min-width: 110px; max-width: 110px;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.th-mx-cell.empty   { background: var(--bg-elev); color: var(--ink-3); }
.th-mx-cell.pending {
  background: color-mix(in oklch, oklch(0.74 0.13 70) 18%, var(--bg-elev));
  color: oklch(0.45 0.13 70);
}
.th-mx-cell.verified {
  background: color-mix(in oklch, oklch(0.66 0.13 160) 22%, var(--bg-elev));
  color: oklch(0.35 0.13 160);
  font-weight: 600;
}
[data-theme="rpg"] .th-mx-cell.empty   { background: #1f0a09; }
[data-theme="rpg"] .th-mx-cell.pending { background: rgba(255,122,48,0.20); color: #ffbf80; }
[data-theme="rpg"] .th-mx-cell.verified { background: rgba(240,160,96,0.28); color: #ffe4bd; }
.th-mx-cell.interactive { cursor: pointer; }
.th-mx-cell.interactive:hover { filter: brightness(0.96); }
[data-theme="rpg"] .th-mx-cell.interactive:hover { filter: brightness(1.15); }
.th-mx-cell.ghosted:hover { background: color-mix(in oklch, oklch(0.65 0.16 145) 14%, var(--bg-elev)); }

.th-mx-score { font-size: 13px; }
.th-mx-max { opacity: 0.55; font-weight: 400; }
.th-mx-check { font-size: 14px; }
.th-mx-ghost { font-size: 14px; color: var(--ink-4, var(--ink-3)); opacity: 0.5; }
[data-theme="rpg"] .th-mx-ghost { color: rgba(255,220,170,0.3); }

.th-mx-prog {
  padding: 0 16px !important; text-align: left !important;
  position: sticky; right: 0; background: var(--bg-elev);
}
[data-theme="rpg"] .th-mx-prog { background: #1f0a09; }

.th-mx-foot {
  font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2);
  background: var(--bg);
  width: 110px; min-width: 110px; max-width: 110px;
  position: sticky; bottom: 0; z-index: 1;
}
[data-theme="rpg"] .th-mx-foot { background: #150605; }
.th-mx-foot-num { font-weight: 600; color: var(--ink); }
.th-mx-foot-den { color: var(--ink-3); font-weight: 400; }
.th-mx-foot-head {
  position: sticky; left: 0; bottom: 0;
  background: var(--bg);
  z-index: 2;
  font-weight: 500; color: var(--ink-2); font-size: 12px;
  text-align: left; padding-left: 16px !important;
  z-index: 1;
}
[data-theme="rpg"] .th-mx-foot-head { background: #150605; }
.th-matrix tfoot td { border-top: 1px solid var(--hair); border-bottom: none; }

/* Modal */
.th-modal-back {
  position: fixed; inset: 0;
  background: rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100;
}
[data-theme="rpg"] .th-modal-back { background: rgba(10, 4, 4, 0.7); }

.th-modal, .th-add-modal, .th-pop {
  background: var(--bg-elev);
  border: 1px solid var(--hair);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(20,20,30,0.25);
  position: relative;
  max-height: 90vh; overflow: auto;
}
[data-theme="rpg"] .th-modal,
[data-theme="rpg"] .th-add-modal,
[data-theme="rpg"] .th-pop {
  background: linear-gradient(180deg, #2a0e0c 0%, #1a0807 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(213,122,69,0.25) inset;
}

.th-modal { width: min(640px, 100%); padding: 28px; }
.th-modal-x {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border: 0; background: transparent; border-radius: 8px;
  font-size: 16px; color: var(--ink-3); cursor: pointer;
}
.th-modal-x:hover { background: var(--hair); color: var(--ink); }

.th-modal-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: 999px;
  background: color-mix(in oklch, var(--type-color) 12%, white);
  color: var(--type-color);
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  border: 1px solid color-mix(in oklch, var(--type-color) 25%, white);
}
[data-theme="rpg"] .th-modal-eyebrow { background: rgba(213,122,69,0.18); color: #f0c89a; border-color: rgba(213,122,69,0.4); }
.th-modal-glyph { font-size: 14px; }
.th-modal-title { margin: 12px 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; color: var(--ink); }
[data-theme="rpg"] .th-modal-title { font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.04em; }
.th-modal-link { display: inline-block; font-size: 12px; color: oklch(0.62 0.16 30); text-decoration: none; word-break: break-all; margin-bottom: 12px; }
.th-modal-link:hover { text-decoration: underline; }
.th-modal-desc { margin: 8px 0 16px; font-size: 14px; color: var(--ink-2); line-height: 1.55; text-wrap: pretty; }
.th-modal-desc-link {
  color: oklch(0.62 0.16 30);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;
}
.th-modal-desc-link:hover { text-decoration-thickness: 2px; }
[data-theme="rpg"] .th-modal-desc-link { color: var(--accent, oklch(0.7 0.13 60)); }

.th-modal-meta {
  display: flex; gap: 24px;
  padding: 12px 16px;
  border: 1px solid var(--hair);
  border-radius: 10px;
  margin-bottom: 16px;
  background: var(--bg);
}
[data-theme="rpg"] .th-modal-meta { background: rgba(0,0,0,0.25); }
.th-modal-meta > div { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.th-modal-meta > div span { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.th-modal-meta > div b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }

.th-modal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.th-modal-stat { padding: 14px 16px; border: 1px solid var(--hair); border-radius: 10px; background: var(--bg); }
[data-theme="rpg"] .th-modal-stat { background: rgba(0,0,0,0.25); }
.th-modal-stat-num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.th-modal-stat-den { color: var(--ink-3); font-weight: 400; font-size: 16px; }
.th-modal-stat-lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

.th-modal-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 8px; font-weight: 500; }
.th-modal-list { display: flex; flex-direction: column; gap: 4px; }
.th-modal-row {
  display: grid;
  grid-template-columns: 26px 1fr 90px 90px auto;
  align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px;
}
.th-modal-row:hover { background: var(--bg); }
.th-modal-row.empty { opacity: 0.7; }
.th-modal-row-name { font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.th-mine-tag { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 6px; border-radius: 999px; background: oklch(0.65 0.16 145); color: white; }
[data-theme="rpg"] .th-mine-tag { background: linear-gradient(180deg, #d57a45, #8d3618); color: #fff8e6; }
.th-modal-row-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.th-modal-row-score { text-align: right; }
.th-mscore { font-size: 12px; font-variant-numeric: tabular-nums; }
.th-mscore.verified { color: oklch(0.66 0.13 160); font-weight: 600; }
.th-mscore.pending { color: oklch(0.74 0.13 70); }
.th-mscore.empty { color: var(--ink-3); }
[data-theme="rpg"] .th-mscore.verified { color: #f0a060; }
[data-theme="rpg"] .th-mscore.pending { color: #ff9a55; }

.th-modal-btn {
  border: 1px solid var(--hair);
  background: var(--bg-elev);
  color: var(--ink-2);
  font: inherit; font-size: 12px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.th-modal-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.th-modal-btn.primary { background: var(--ink); color: white; border-color: var(--ink); }
.th-modal-btn.primary:hover { filter: brightness(1.1); color: white; }
.th-modal-btn.primary:disabled { opacity: 0.4; cursor: not-allowed; }
[data-theme="rpg"] .th-modal-btn.primary { background: linear-gradient(180deg, #d57a45, #8d3618); color: #fff8e6; border-color: rgba(255,220,170,0.3); }

/* Score popover */
.th-pop { width: min(360px, 100%); padding: 24px; }
.th-pop-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.th-pop-title { font-size: 16px; font-weight: 600; color: var(--ink); margin: 4px 0 16px; }
.th-pop-slider { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 8px 0 16px; }
.th-pop-num { font-size: 36px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1; }
.th-pop-den { color: var(--ink-3); font-weight: 400; font-size: 18px; }
.th-pop-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 999px;
  background: var(--hair); outline: none; cursor: pointer;
  margin: 6px 0 2px;
}
[data-theme="rpg"] .th-pop-range { background: rgba(255,220,170,0.15); }
.th-pop-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: oklch(0.62 0.16 30);
  border: 3px solid var(--bg-elev);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
.th-pop-range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: oklch(0.62 0.16 30);
  border: 3px solid var(--bg-elev);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
[data-theme="rpg"] .th-pop-range::-webkit-slider-thumb { background: linear-gradient(180deg, #d57a45, #8d3618); border-color: #2a0e0c; }
[data-theme="rpg"] .th-pop-range::-moz-range-thumb { background: linear-gradient(180deg, #d57a45, #8d3618); border-color: #2a0e0c; }
.th-pop-range-labels {
  display: flex; justify-content: space-between;
  width: 100%; font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.th-pop-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Add material modal */
.th-add-modal { width: min(960px, 100%); padding: 28px 32px; }
.th-add-title { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
[data-theme="rpg"] .th-add-title { font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.04em; }
.th-add-sub { margin: 0 0 20px; font-size: 13px; color: var(--ink-3); }
.th-add-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; }
.th-add-form { display: flex; flex-direction: column; gap: 16px; }
.th-add-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.th-field { display: flex; flex-direction: column; gap: 6px; }
.th-flabel {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-2);
}
.th-flabel em { color: oklch(0.62 0.16 30); font-style: normal; margin-left: 2px; }
[data-theme="rpg"] .th-flabel em { color: #d57a45; }

.th-input {
  width: 100%; box-sizing: border-box;
  font: inherit; font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--bg-elev); color: var(--ink);
}
.th-input:focus {
  outline: none;
  border-color: oklch(0.62 0.16 30);
  box-shadow: 0 0 0 3px color-mix(in oklch, oklch(0.62 0.16 30) 24%, transparent);
}
[data-theme="rpg"] .th-input { background: rgba(0,0,0,0.25); }
[data-theme="rpg"] .th-input:focus { border-color: #d57a45; box-shadow: 0 0 0 3px rgba(213,122,69,0.3); }
.th-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.th-order { width: 100px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

.th-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.th-type {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 12px 6px;
  border: 1px solid var(--hair);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--ink-2);
  font: inherit; cursor: pointer;
}
[data-theme="rpg"] .th-type { background: rgba(0,0,0,0.25); }
.th-type:hover { border-color: var(--ink-3); color: var(--ink); }
.th-type.on {
  border-color: var(--tc);
  background: color-mix(in oklch, var(--tc) 12%, var(--bg-elev));
  color: var(--tc);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--tc) 18%, transparent);
}
[data-theme="rpg"] .th-type.on { background: rgba(213,122,69,0.22); border-color: #d57a45; color: #fff8e6; }
.th-type-glyph { font-size: 18px; }
.th-type-lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.th-stepper {
  display: grid; grid-template-columns: 36px 1fr 36px;
  height: 40px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--bg-elev);
  overflow: hidden;
}
[data-theme="rpg"] .th-stepper { background: rgba(0,0,0,0.25); }
.th-stepper button {
  border: 0; background: transparent; font: inherit; font-size: 18px;
  color: var(--ink-2); cursor: pointer;
}
.th-stepper button:hover { background: var(--hair); color: var(--ink); }
.th-stepper input {
  border: 0; outline: none; background: transparent;
  font: inherit; font-size: 18px; font-weight: 600;
  color: var(--ink); text-align: center; width: 100%;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.th-stepper input::-webkit-outer-spin-button,
.th-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.th-add-preview { display: flex; flex-direction: column; gap: 8px; }
.th-add-preview-lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.th-mat-card {
  background: var(--bg-elev);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 18px 20px;
  border-top: 3px solid var(--tc);
}
[data-theme="rpg"] .th-mat-card { background: rgba(0,0,0,0.25); border-top-color: #d57a45; }
.th-mat-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--tc);
  margin-bottom: 10px;
}
.th-mat-score { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: color-mix(in oklch, var(--tc) 14%, white); }
[data-theme="rpg"] .th-mat-score { background: rgba(213,122,69,0.20); color: #ffe4bd; }
.th-mat-title { font-size: 17px; font-weight: 600; color: var(--ink); margin-bottom: 4px; line-height: 1.25; }
[data-theme="rpg"] .th-mat-title { font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.03em; }
.th-mat-link { font-size: 12px; color: oklch(0.62 0.16 30); margin-bottom: 10px; word-break: break-all; font-family: ui-monospace, monospace; }
[data-theme="rpg"] .th-mat-link { color: #c89060; }
.th-mat-desc { font-size: 13px; color: var(--ink-2); line-height: 1.55; }

.th-add-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--hair); }

/* Inline state / errors */
.th-state {
  padding: 24px; text-align: center;
  font-size: 13px; color: var(--ink-3);
}
.th-err {
  background: color-mix(in oklch, oklch(0.62 0.16 30) 12%, transparent);
  color: oklch(0.5 0.18 30);
  border: 1px solid color-mix(in oklch, oklch(0.62 0.16 30) 30%, transparent);
  padding: 8px 10px; border-radius: 8px;
  font-size: 12px;
}
.th-err-block { margin-top: 14px; }
[data-theme="rpg"] .th-err { background: rgba(255, 80, 60, 0.12); color: #ff9a80; border-color: rgba(255,80,60,0.35); }

.th-pop-notes { margin-top: 12px; min-height: 60px; }

.th-modal-btn.danger { color: oklch(0.5 0.18 30); }
.th-modal-btn.danger:hover { background: color-mix(in oklch, oklch(0.62 0.16 30) 12%, transparent); border-color: oklch(0.62 0.16 30); }
[data-theme="rpg"] .th-modal-btn.danger { color: #ff9a80; }

.th-modal-admin-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--hair);
}

/* Top tab switcher (Board / Theory) */
.app-tabs {
  display: inline-flex; gap: 2px;
  margin-left: 16px;
}
.app-tab {
  padding: 7px 14px;
  font: inherit; font-size: 13px; font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink-3);
  cursor: pointer;
}
.app-tab:hover { color: var(--ink); }
.app-tab.on {
  background: var(--ink);
  color: white;
}
[data-theme="rpg"] .app-tab.on { background: linear-gradient(180deg, #c46a3a, #7a2d12); color: #fff8e6; }

@media (max-width: 1100px) {
  .th-add-grid { grid-template-columns: 1fr; }
  .th-modal-row { grid-template-columns: 26px 1fr auto; }
  .th-modal-row-date, .th-modal-row-score { display: none; }
}

/* ----------------------------- Stage modal ----------------------------- */
.sm-modal { width: min(680px, 100%); }
.sm-eyebrow { --type-color: oklch(0.62 0.16 220); }
[data-theme="rpg"] .sm-eyebrow { --type-color: oklch(0.7 0.13 60); }
.sm-no-url {
  display: inline-block;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 12px;
  font-style: italic;
}
.sm-alias {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px !important;
  font-weight: 500 !important;
  color: var(--ink-2) !important;
  text-transform: lowercase;
}

.sm-list { margin-bottom: 4px; }
.sm-empty {
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-style: italic;
  border: 1px dashed var(--hair);
  border-radius: 8px;
}
.sm-row {
  grid-template-columns: 26px 1fr auto;
  cursor: pointer;
  transition: background 100ms;
}
.sm-row.interactive:hover { background: var(--bg); }
.sm-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sm-row-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: oklch(0.62 0.16 220);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, oklch(0.62 0.16 220) 35%, transparent);
  background: color-mix(in oklch, oklch(0.62 0.16 220) 8%, transparent);
}
.sm-row-link:hover { background: color-mix(in oklch, oklch(0.62 0.16 220) 16%, transparent); }
[data-theme="rpg"] .sm-row-link {
  color: oklch(0.74 0.13 60);
  border-color: rgba(213,122,69,0.5);
  background: rgba(213,122,69,0.12);
}

.sm-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.sm-chip.ready {
  background: color-mix(in oklch, oklch(0.66 0.13 160) 14%, transparent);
  color: oklch(0.55 0.13 160);
  border-color: color-mix(in oklch, oklch(0.66 0.13 160) 35%, transparent);
}
.sm-chip.retries {
  background: color-mix(in oklch, oklch(0.66 0.13 30) 14%, transparent);
  color: oklch(0.55 0.13 30);
  border-color: color-mix(in oklch, oklch(0.66 0.13 30) 35%, transparent);
}
.sm-chip.dl {
  background: var(--bg);
  color: var(--ink-2);
  border-color: var(--hair);
}
.sm-chip.dl.ontime {
  background: color-mix(in oklch, oklch(0.66 0.13 160) 10%, transparent);
  color: oklch(0.55 0.13 160);
  border-color: color-mix(in oklch, oklch(0.66 0.13 160) 30%, transparent);
}
.sm-chip.dl.overdue {
  background: color-mix(in oklch, oklch(0.66 0.18 25) 12%, transparent);
  color: oklch(0.55 0.18 25);
  border-color: color-mix(in oklch, oklch(0.66 0.18 25) 35%, transparent);
}
[data-theme="rpg"] .sm-chip.ready { color: #b4d49a; background: rgba(110,160,80,0.18); border-color: rgba(110,160,80,0.4); }
[data-theme="rpg"] .sm-chip.retries { color: #f0a060; background: rgba(213,122,69,0.18); border-color: rgba(213,122,69,0.4); }
[data-theme="rpg"] .sm-chip.dl.overdue { color: #ff8a6c; background: rgba(200,70,40,0.18); border-color: rgba(200,70,40,0.4); }

.sm-section-2 { margin-top: 18px; }
.sm-pile {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sm-pile.muted { opacity: 0.7; }
.sm-pile-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  background: var(--bg);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
}
.sm-pile-item:hover { border-color: var(--ink-3); background: var(--bg-elev); color: var(--ink); }
.sm-pile-name { font-weight: 500; }
[data-theme="rpg"] .sm-pile-item { background: rgba(0,0,0,0.25); border-color: rgba(213,122,69,0.25); color: #e7d5b8; }
[data-theme="rpg"] .sm-pile-item:hover { border-color: rgba(213,122,69,0.5); background: rgba(0,0,0,0.4); }

.sm-loading-hint {
  margin-top: 14px;
  font-size: 11px;
  color: var(--ink-3);
  font-style: italic;
  text-align: right;
}
