:root {
  --bg: #12100e;
  --surface: #1c1814;
  --line: #3d342c;
  --text: #f3ead7;
  --muted: #b3a894;
  --gold: #d4ad63;
  --green: #8fbd7f;
  --red: #d98273;
  --blue: #78aab8;
}
* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #6b5a45 #12100e;
}
*::-webkit-scrollbar { width: 10px; height: 8px; }
*::-webkit-scrollbar-track { background: #12100e; }
*::-webkit-scrollbar-thumb {
  background: #6b5a45;
  border-radius: 999px;
  border: 2px solid #12100e;
}
*::-webkit-scrollbar-thumb:hover { background: #d4ad63; }
*::-webkit-scrollbar-corner { background: #12100e; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, #3a2a1855 0, transparent 26rem),
    radial-gradient(circle at 100% 20%, #24324640 0, transparent 28rem),
    var(--bg);
  font: 15px/1.55 "Segoe UI", sans-serif;
  min-height: 100vh;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.shell { width: min(1100px, calc(100% - 32px)); margin: 0 auto; }
.shell.wide { width: min(1720px, calc(100% - 32px)); }
nav {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 18px 0 0;
}
nav a {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #181410cc;
}
nav a[aria-current="page"], nav a:hover { color: var(--text); border-color: var(--gold); text-decoration: none; }
header.page { padding: 28px 0 18px; }
.eyebrow { color: var(--gold); letter-spacing: .16em; text-transform: uppercase; font-size: 11px; font-weight: 800; }
h1 { margin: 6px 0 8px; font-family: Georgia, serif; font-weight: 500; font-size: clamp(32px, 5vw, 52px); letter-spacing: -.03em; }
.lead { max-width: 740px; color: var(--muted); margin: 0; font-size: 17px; }
.stats, .filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.stat, .filters button, .chip {
  border: 1px solid var(--line);
  background: #181410cc;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
}
.stat b { color: var(--text); }
.filters button { cursor: pointer; }
.filters button.active { color: var(--text); border-color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; padding-bottom: 48px; }
.card, .quest, .chapter, .class-card, .panel {
  background: linear-gradient(160deg, #221c17f2, #16130ff5);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.card h2, .quest h2, .chapter h2, .class-card h2, .panel h2 {
  font-family: Georgia, serif; font-weight: 500; margin: 0 0 8px; font-size: 24px;
}
.card p, .muted { color: var(--muted); }
.stack { display: grid; gap: 12px; padding-bottom: 56px; }
.quest header, .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.badge { font-size: 12px; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.started { color: var(--gold); border-color: #d4ad6366; }
.badge.completed { color: var(--green); border-color: #8fbd7f66; }
.badge.failed { color: var(--red); border-color: #d9827366; }
.objective { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.objective b { font-weight: 650; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 16px; }
input, select, textarea {
  background: #100e0c;
  border: 1px solid #4a4036;
  border-radius: 10px;
  padding: 10px 12px;
}
input[type="search"], input[type="text"], select { min-width: min(100%, 280px); }
textarea { width: 100%; min-height: 74px; }
.level { width: 100%; }
.warn { color: var(--red); }
footer { color: var(--muted); font-size: 13px; padding: 8px 0 32px; }
.hidden { display: none; }
@media (max-width: 720px) {
  .quest header, .row { flex-direction: column; }
}
.save-tools { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.save-switch { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 64px;
  cursor: pointer;
}
.upload-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.save-card > [data-save],
#known-only,
#add-profile,
#delete-profile,
#download,
#save-scheme,
.upload-btn,
.meta button,
.chosen [data-remove] {
  background: #181410;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
#delete-profile:disabled { opacity: .45; cursor: default; }
.save-card { position: relative; }
.save-card > [data-save] {
  text-align: left;
  min-height: 64px;
  padding-right: 28px;
}
.save-card > [data-delete-save] {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #100e0c;
  color: var(--gold);
  cursor: pointer;
  line-height: 20px;
}
.save-card small { display: block; color: var(--muted); }
.save-card.active > [data-save],
#known-only.active,
.meta button.active {
  color: var(--text);
  border-color: var(--gold);
  background: #2a2218;
}
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upload-btn.compact { min-height: 0; }
.party-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.portrait-card { position: relative; flex: 0 0 auto; }
.portrait-hide {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #100e0c;
  color: var(--gold);
  cursor: pointer;
  line-height: 20px;
}
.hidden-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 0;
  margin-bottom: 8px;
}
.hidden-row span { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.hidden-row button {
  border: 1px solid var(--line);
  background: #181410;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.portrait-btn {
  width: 108px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #181410;
  border-radius: 16px;
  padding: 8px;
  cursor: pointer;
  color: var(--muted);
  text-align: center;
}
.portrait-btn small, .portrait-btn em {
  display: block;
  margin-top: 6px;
  line-height: 1.25;
}
.portrait-btn em {
  margin-top: 2px;
  font-style: normal;
  font-size: 10px;
  letter-spacing: .03em;
  color: var(--gold);
}
.portrait-btn.active { border-color: var(--gold); color: var(--text); }
.portrait-btn img, .portrait-fallback {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  background: #2a241c;
}
.portrait-fallback { display: grid; place-items: center; font-family: Georgia, serif; color: var(--gold); }
.spell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.circle-break {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.circle-break::before,
.circle-break::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}
.circle-hide {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: none;
  padding: 0;
}
.tag-row, #tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tag-row { margin-bottom: 8px; }
.tag-row span, .tag-row label { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.tag-row input { min-width: 140px; }
#open-visibility, #open-catalog, dialog button {
  border: 1px solid var(--line);
  background: #181410;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
#tag-filters button {
  border: 1px solid var(--line);
  background: #181410;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
#tag-filters button.active {
  color: var(--text);
  border-color: var(--gold);
  background: #2a2218;
}
.spell-marks { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; align-items: center; }
.mark {
  box-sizing: border-box;
  height: 16px;
  min-width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #e6d7b2;
}
.mark svg { width: 16px; height: 16px; display: block; }
.mark.dur {
  font-style: normal;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  border-radius: 3px;
  padding: 0 2px;
}
.mark.dur.short { color: #f6d2d2; background: #7a2e2e; }
.mark.dur.medium { color: #f6e2ae; background: #6d5520; }
.mark.dur.long { color: #d5f0d2; background: #24633a; }
.mark.radius { gap: 2px; padding: 0 3px; border-radius: 999px; }
.mark.radius svg { width: 12px; height: 12px; }
.mark.radius b { font-style: normal; font-size: 8px; font-weight: 700; line-height: 1; }
.mark.radius.short { color: #f6d2d2; background: #7a2e2e; }
.mark.radius.medium { color: #f6e2ae; background: #6d5520; }
.mark.radius.long { color: #d5f0d2; background: #24633a; }
dialog {
  background: #16130f;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 440px;
}
dialog::backdrop { background: #000000aa; }
#catalog { width: min(680px, 96vw); }
#catalog-body { max-height: 62vh; overflow: auto; display: grid; gap: 8px; margin: 12px 0; }
.catalog-group { display: grid; gap: 4px; }
.catalog-group b { font-weight: 650; }
.catalog-row { display: flex; align-items: center; gap: 8px; }
.catalog-row.child { padding-left: 16px; }
.catalog-row span { flex: 1; }
.catalog-row button {
  border: 1px solid var(--line);
  background: #181410;
  color: var(--text);
  border-radius: 12px;
  padding: 4px 8px;
  cursor: pointer;
}
.catalog-row button:disabled { opacity: .45; cursor: default; }
.visibility-options { display: grid; gap: 8px; margin: 12px 0 16px; }
.visibility-options label { display: flex; align-items: center; gap: 8px; }
.spell-tag {
  font-style: normal;
  font-size: 9px;
  letter-spacing: .03em;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 4px;
}
.cast-options { display: grid; gap: 12px; margin: 8px 0 16px; }
.cast-options label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}
.cast-options input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin: 0;
  flex: 0 0 26px;
  box-sizing: border-box;
  border: 1px solid var(--gold);
  border-radius: 7px;
  background-color: #100e0c;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  overflow: hidden;
}
.cast-options input[type="checkbox"]:checked {
  background-color: #2a2218;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.2 L6.5 11.4 L12.8 4.6' fill='none' stroke='%23d4ad63' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.cast-options input[type="number"] { width: 72px; min-width: 72px; }
.spell-btn, .mini {
  border: 1px solid var(--line);
  background: #181410cc;
  color: var(--text);
  border-radius: 12px;
  padding: 6px;
  cursor: pointer;
}
.spell-btn { min-height: 108px; }
.spell-btn img, .mini img { width: 48px; height: 48px; image-rendering: auto; display: block; }
.spell-btn small, .mini small { display: block; color: var(--muted); line-height: 1.25; }
.spell-btn.on { border-color: var(--gold); }
.spell-btn.missing { opacity: .55; }
.layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 14px; }
.shell.wide .layout { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
.layout > * { min-width: 0; }
.chosen { display: grid; gap: 3px; }
.mini {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 8px;
}
.mini img { width: 22px; height: 22px; flex: 0 0 22px; }
.mini b {
  flex: 0 1 108px;
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini .spell-marks { flex: 0 0 auto; justify-content: flex-start; }
.mini .meta {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 2px;
  overflow-x: auto;
}
.chosen .meta button,
.mini [data-remove] {
  font-size: 9px;
  line-height: 1.1;
  padding: 1px 4px;
  white-space: nowrap;
  border-radius: 999px;
}
.meta { display: flex; gap: 4px; flex-wrap: wrap; }
.meta button, .mini { font-size: 12px; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}
.spell {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.spell img, .spell .portrait-fallback {
  width: 64px;
  height: 64px;
  border-radius: 12px;
}
.spell header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.spell h2 { font-size: 22px; margin: 0; }
.spell .badge { text-decoration: none; }
.badge.panel-in { color: var(--green); border-color: #8fbd7f66; }
.badge.panel-hidden { color: var(--gold); border-color: #d4ad6366; }
.badge.panel-forms, .badge.panel-ability { color: var(--blue); border-color: #78aab866; }
.does {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  background: #2a221866;
  border-radius: 0 12px 12px 0;
}
.does h3 {
  margin: 0 0 4px;
  font: 800 11px/1.2 "Segoe UI", sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}
.does p { margin: 0; }
.mechanics, .calc-result { margin: 8px 0 0; padding-left: 18px; }
.mechanics li, .calc-result li { margin: 2px 0; }
.calc { margin-top: 12px; }
.calc .controls { margin: 0; }
.calc input[type="number"] { width: 88px; min-width: 88px; }
.spell button {
  border: 1px solid var(--line);
  background: #181410cc;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
.spell button:hover { border-color: var(--gold); }
@media (max-width: 720px) {
  .spell { grid-template-columns: 48px minmax(0, 1fr); gap: 10px; }
  .spell img, .spell .portrait-fallback { width: 48px; height: 48px; }
  .spell header { flex-direction: column; }
}
