:root {
  --bg: #1b212b;
  --panel: #242b36;
  --panel-hover: #2c3542;
  --text: #e8eaef;
  --muted: #c5ccd8;
  --link: #9ec4ff;
  --border: #3a4454;
  --accent: #3b6fd4;
  --accent-soft: rgba(59, 111, 212, 0.22);
  --gold: #e2c57a;
  --gold-soft: rgba(226, 197, 122, 0.35);
  --nav-active: #2a3d5c;
  --sidebar-w: 300px;
  --spell-w: 420px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  font: 17px/1.65 "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #161b22;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 18px 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar-search {
  padding: 0 10px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

#spell-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

#spell-search::placeholder { color: #8b95a6; }

#spell-search:focus-visible,
.search-raid:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.search-status {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(42vh, 420px);
  margin-top: 8px;
  overflow-y: auto;
}

.search-hit {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.search-hit-spell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.search-hit-spell img {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 3px;
  flex-shrink: 0;
}

.search-hit-name {
  font-weight: 650;
  line-height: 1.3;
}

.search-hit-ids,
.search-hit-effect {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.search-hit-effect {
  font-weight: 500;
}

.search-id-more {
  display: block;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.search-id-more:hover { text-decoration: underline; }

.search-id-more:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.search-mark {
  background: var(--gold-soft);
  color: inherit;
  border-radius: 2px;
}

.search-hit-raids {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.search-raid {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-soft);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.search-raid:hover {
  background: var(--panel-hover);
  border-color: var(--gold);
}

.brand-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand-title {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--text);
}

.brand-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 600;
}

#navList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px 24px;
}

.nav-group + .nav-group {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}

.nav-group-toggle:hover { color: var(--text); background: var(--panel); }

.nav-group-toggle:focus-visible,
.nav-btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.nav-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  transition: transform 0.15s ease;
}

.nav-group.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }

.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 8px;
}

.nav-btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-soft);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--panel-hover);
  border-color: var(--gold);
}

.nav-btn.active {
  background: var(--nav-active);
  border-color: var(--accent);
  border-left-color: var(--gold);
}

#content {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 64px;
}

.writeup {
  max-width: 48rem;
}

.writeup h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.25;
  font-weight: 650;
  color: #f4f1e6;
}

.meta {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 16px;
}

.forum-link {
  display: inline-block;
  margin: 10px 0 28px;
  color: var(--link);
  font-weight: 600;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

.stage {
  margin: 28px 0 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 22px;
  line-height: 1.35;
  color: var(--gold);
}

.block { margin: 18px 0 8px; }

.block h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.4;
  font-weight: 650;
}

.block.actor h3,
.block.add h3,
.block.group h3 {
  color: #d7deea;
  font-size: 18px;
}

.prose {
  margin: 0 0 8px;
}

ul.effects {
  margin: 6px 0 10px;
  padding-left: 1.3rem;
}

ul.effects li { margin: 4px 0; }

ul.effects ul { margin: 4px 0; }

.summary-title {
  margin: 32px 0 8px;
  font-size: 22px;
  color: var(--gold);
}

.spell {
  display: inline;
  white-space: nowrap;
  border-radius: 4px;
}

.spell.is-open {
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.spell img {
  width: 22px;
  height: 22px;
  vertical-align: -4px;
  margin-right: 4px;
  border-radius: 3px;
}

.spell-ids {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.spell-effect {
  color: var(--text);
  font-weight: 500;
}

.spell-copies {
  margin: 6px 0 12px;
  padding-left: 1.2rem;
}

.spell-copies li {
  margin: 6px 0;
}

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

#spell-panel {
  width: var(--spell-w);
  flex-shrink: 0;
  background: #161b22;
  border-left: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.spell-panel-kicker {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 22px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: #161b22;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.spell-panel-empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

#spell-card {
  color: #eef1f6;
}

.spell-card-spell {
  padding: 14px 16px;
}

.spell-card-spell + .spell-card-spell {
  border-top: 1px solid #465266;
}

.spell-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spell-card-head img {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
}

.spell-card-name {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: #f4f1e6;
  text-decoration: none;
}

.spell-card-name:hover { text-decoration: underline; }

.spell-card-id {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--link);
}

.spell-card-slots {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.spell-card-slots li {
  margin: 0;
  padding: 3px 0;
  font-size: 16px;
  line-height: 1.45;
}

.spell-card-details {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid #465266;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 4px;
  font-size: 15px;
  line-height: 1.4;
}

.spell-card-details dt {
  margin: 0;
  color: #d5deee;
  font-weight: 650;
}

.spell-card-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1280px) {
  :root {
    --sidebar-w: 248px;
    --spell-w: 340px;
  }
}

@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar {
    position: relative;
    width: 100%;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  #content { padding: 22px 18px 46vh; }
  .search-results { max-height: 28vh; }
  #spell-panel {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 42vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    z-index: 20;
  }
}
