/* ---------- shell ---------- */

.app-shell {
  min-height: 100vh;
}

.app-main {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}

.main {
  width: 100%;
  max-width: calc(var(--content-max) + 64px);
  flex: 1;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-w);
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 24px 18px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-mark--small {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 9px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: 0.01em;
}

.brand-text small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.sidebar__search {
  display: flex;
  height: 36px;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 6px 0 10px;
}

.sidebar__search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sidebar__search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 11.5px;
}

.sidebar__search button {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

.sidebar__search button:hover {
  background: var(--bg-soft);
  color: var(--accent);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-soft);
  font-size: 13.5px;
}

.nav__link:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.nav__link.is-active {
  border-color: #cfe8eb;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.nav__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.32;
}

.nav__link.is-active .nav__dot {
  opacity: 1;
}

.sidebar__section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.sidebar__section-title {
  margin: 0 0 10px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.world-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.world-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--text-soft);
  font-size: 12.5px;
}

.world-links a:hover {
  background: var(--surface);
  color: var(--accent-strong);
}

.world-links__code {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.sidebar__note {
  display: flex;
  gap: 8px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.sidebar__note-mark {
  color: var(--accent);
  font-size: 13px;
}

/* ---------- mobile bar ---------- */

.mobile-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: none;
  height: 56px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgb(247 247 245 / 92%);
  padding: 0 14px;
  backdrop-filter: blur(8px);
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 18px;
  text-decoration: none;
}

.icon-button:hover {
  border-color: var(--border);
  background: var(--surface);
}

.mobile-bar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

.nav-scrim {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: none;
  background: rgb(31 35 40 / 28%);
}

body[data-nav-open="true"] .sidebar {
  transform: translateX(0);
}

body[data-nav-open="true"] .nav-scrim {
  display: block;
}

body[data-nav-open="true"] {
  overflow: hidden;
}

/* ---------- home ---------- */

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: clamp(28px, 5vw, 56px);
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  top: -120px;
  right: -80px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  content: "";
  pointer-events: none;
}

.hero__title {
  max-width: 14ch;
  margin: 18px 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.14;
}

.hero__lead {
  max-width: 58ch;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.9;
}

.hero-search {
  display: flex;
  max-width: 620px;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 4px 4px 4px 12px;
}

.hero-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hero-search input {
  height: 40px;
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.hero-search button {
  height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  padding: 0 18px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.hero-search button:hover {
  background: var(--accent-strong);
}

.hero-search__icon {
  color: var(--muted);
  font-size: 16px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  margin-top: 36px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.stats__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: 28px;
  border-right: 1px solid var(--border);
  padding-right: 28px;
}

.stats__item:last-child {
  margin-right: 0;
  border-right: 0;
  padding-right: 0;
}

.stats__item strong {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.stats__item span {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

/* ---------- sections ---------- */

.section {
  margin-top: 54px;
}

.section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section__head h2 {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
}

.section--split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 36px;
}

.archive-note {
  border-left: 1px solid var(--border);
  padding-left: 28px;
  color: var(--text-soft);
}

.archive-note h2 {
  margin: 6px 0 12px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.archive-note p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.archive-note code {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-muted);
  padding: 0 3px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---------- grids & cards ---------- */

.grid {
  display: grid;
  gap: 18px;
}

.grid--worlds,
.grid--characters,
.grid--orgs,
.grid--wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition:
    border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    transform 0.15s var(--ease);
}

.card:hover {
  border-color: #c9dfe3;
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}

.card__link {
  display: flex;
  height: 100%;
  flex-direction: column;
  color: inherit;
}

.card__media {
  position: relative;
  overflow: hidden;
  margin: 10px 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease);
}

.card:hover .card__media img {
  transform: scale(1.015);
}

.card__code {
  position: absolute;
  bottom: 8px;
  left: 8px;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 3px;
  background: rgb(255 255 255 / 86%);
  padding: 1px 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(4px);
}

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 16px;
}

.card__title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card__title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card__arrow {
  color: var(--muted-2);
  font-size: 12px;
  transition:
    color 0.15s var(--ease),
    transform 0.15s var(--ease);
}

.card:hover .card__arrow {
  color: var(--accent);
  transform: translate(1px, -1px);
}

.card__aliases {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
}

.card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
}

.card__meta-sep {
  margin: 0 6px;
  color: var(--border-strong);
}

.card__meta--count {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.card__summary {
  display: -webkit-box;
  overflow: hidden;
  margin: 2px 0 4px;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ---------- page header ---------- */

.page-header {
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
  padding: 4px 0 26px;
}

.page-header h1 {
  margin: 6px 0 10px;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 3.5vw, 2.7rem);
  font-weight: 600;
}

.page-header__lead {
  max-width: 65ch;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.85;
}

.page-header--with-aside {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
}

.page-header__count {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  padding-left: 22px;
  text-align: right;
}

.page-header__count strong {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
}

.page-header__count span {
  color: var(--muted);
  font-size: 10.5px;
}

/* ---------- filters ---------- */

.filters {
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.filters__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filter-search {
  display: flex;
  min-width: 220px;
  height: 36px;
  flex: 1;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  padding: 0 10px;
}

.filter-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12.5px;
}

.filter-search__icon {
  color: var(--muted);
}

.filter-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
}

.filter-sort select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 8px;
  color: var(--text);
  font-size: 12px;
}

.filter-clear {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.filter-clear:hover {
  border-color: #d8ecef;
  background: var(--accent-soft-2);
  color: var(--accent);
}

.filter-groups {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.filter-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.filter-group__label {
  flex: 0 0 56px;
  padding-top: 5px;
  color: var(--muted-2);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.filter-group__options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 3px 9px;
  color: var(--text-soft);
  font-size: 11px;
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease);
}

.filter-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
}

.filter-chip.is-active {
  border-color: #bfe0e5;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.filters__status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.filters__status strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
}

.filters__hint {
  color: var(--muted-2);
  font-size: 10.5px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.filter-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}

.filter-empty__title {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 20px;
}

.filter-empty p {
  margin-bottom: 16px;
}

.list-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--muted);
  font-size: 11.5px;
}

.list-footer strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
}

.list-footer__note {
  color: var(--muted-2);
  font-size: 10.5px;
}

/* ---------- detail layout ---------- */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 11.5px;
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.profile-header {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  align-items: end;
  gap: 40px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 26px;
}

.profile-header h1 {
  margin: 8px 0;
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 600;
  line-height: 1.1;
}

.profile-header__aliases {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.profile-header__summary {
  margin: 0;
  border-left: 2px solid var(--accent-soft);
  padding-left: 16px;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.85;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: 44px;
  margin-top: 34px;
}

.detail-main {
  min-width: 0;
}

/* ---------- infobox ---------- */

.infobox {
  position: sticky;
  top: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.infobox__image {
  display: block;
  overflow: hidden;
  margin: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
}

.infobox__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.infobox__header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 8px 14px 12px;
}

.infobox__avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--font-serif);
  font-size: 16px;
}

.infobox__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.infobox__eyebrow {
  margin: 0;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
}

.infobox__code {
  margin: 2px 0 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.infobox__rows {
  margin: 0;
  padding: 0;
}

.infobox__row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 11.5px;
}

.infobox__row:last-child {
  border-bottom: 0;
}

.infobox__row dt {
  color: var(--muted);
}

.infobox__row dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text-soft);
}

.infobox__links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.infobox__links a {
  color: var(--accent);
}

.infobox__primary {
  display: inline-block;
  margin-right: 4px;
  border: 1px solid #bfe0e5;
  border-radius: 3px;
  background: var(--accent-soft);
  padding: 0 3px;
  color: var(--accent-strong);
  font-size: 8.5px;
  line-height: 1.4;
  vertical-align: 1px;
}

.infobox__note {
  margin: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 10px 14px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.65;
}

/* ---------- markdown ---------- */

.markdown {
  max-width: 72ch;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.9;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.35;
}

.markdown h1 {
  margin: 32px 0 12px;
  font-size: 26px;
}

.markdown h2 {
  margin: 34px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  font-size: 21px;
  font-weight: 600;
}

.markdown h3 {
  margin: 26px 0 8px;
  font-size: 17px;
}

.markdown p {
  margin: 0 0 14px;
}

.markdown ul,
.markdown ol {
  margin: 0 0 16px;
  padding-left: 1.4em;
}

.markdown li {
  margin: 4px 0;
}

.markdown strong {
  color: var(--text);
  font-weight: 650;
}

.markdown a {
  border-bottom: 1px solid #bfe0e5;
}

.markdown a:hover {
  border-color: var(--accent);
}

.markdown blockquote {
  margin: 20px 0;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft-2);
  padding: 10px 18px;
  color: var(--text-soft);
}

.markdown blockquote p:last-child {
  margin-bottom: 0;
}

.markdown code {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.markdown pre {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 14px;
}

.markdown pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.markdown img {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.markdown table {
  width: 100%;
  margin: 18px 0;
  border-collapse: collapse;
  font-size: 12.5px;
}

.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown th {
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 600;
}

.markdown hr {
  margin: 28px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.markdown mark {
  background: #fff1a8;
  color: var(--text);
}

.markdown--compact p {
  margin-bottom: 8px;
}

/* ---------- timeline ---------- */

.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 7px;
  width: 1px;
  background: var(--border);
  content: "";
}

.timeline__item {
  position: relative;
  padding: 0 0 28px 32px;
}

.timeline__item:last-child {
  padding-bottom: 0;
}

.timeline__marker {
  position: absolute;
  top: 6px;
  left: 3px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.timeline__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.timeline__version {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--accent-soft-2);
  padding: 0 5px;
  color: var(--accent-strong);
}

.timeline__title {
  margin: 5px 0 6px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

.timeline--compact .timeline__item {
  padding-bottom: 18px;
}

.timeline--compact .timeline__title {
  margin: 2px 0 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
}

/* ---------- world / org ---------- */

.world-hero,
.org-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: 34px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 28px;
}

.world-hero__image,
.org-hero__image {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
}

.world-hero__image img,
.org-hero__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.world-hero__body h1,
.org-hero__body h1 {
  margin: 8px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 600;
}

.world-hero__summary,
.org-hero__summary {
  max-width: 52ch;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.85;
}

.world-hero__meta,
.org-hero__meta {
  margin-top: 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.org-hero__meta a {
  color: var(--accent);
}

.world-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: 44px;
  margin-top: 34px;
}

.world-aside {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.side-panel--sticky {
  position: sticky;
  top: 24px;
}

.side-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.side-panel__head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.side-panel__head span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.side-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-list a {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 5px;
  padding: 6px 4px;
  color: var(--text-soft);
}

.side-list a:hover {
  background: var(--bg-soft);
  color: var(--accent-strong);
}

.side-list strong {
  font-size: 12.5px;
  font-weight: 550;
}

.side-list small {
  color: var(--muted);
  font-size: 10px;
}

.side-list--characters a {
  flex-direction: row;
  align-items: center;
  gap: 9px;
}

.side-list--characters img {
  width: 46px;
  border: 1px solid var(--border);
  border-radius: 3px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.side-list--characters span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.detail-layout--org {
  margin-top: 32px;
}

/* ---------- related mini cards ---------- */

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-character {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 7px;
  color: var(--text);
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease);
}

.mini-character:hover {
  border-color: #c9dfe3;
  background: var(--accent-soft-2);
}

.mini-character__image {
  width: 64px;
  border: 1px solid var(--border);
  border-radius: 3px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.mini-character__body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.mini-character__body strong {
  font-size: 13px;
}

.mini-character__body small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.mini-character__arrow {
  margin-left: auto;
  color: var(--muted-2);
}

/* ---------- search ---------- */

.search-page-form {
  display: flex;
  max-width: 760px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px 4px 4px 12px;
  box-shadow: var(--shadow);
}

.search-page-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-page-form input {
  width: 100%;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.search-page-form button {
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  padding: 0 22px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.search-page-form button:hover {
  background: var(--accent-strong);
}

.search-page-form__icon {
  color: var(--muted);
  font-size: 16px;
}

.search-results {
  margin-top: 30px;
}

.search-results__count {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.search-results__count strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
}

.search-more {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.search-group {
  margin-top: 26px;
}

.search-group__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.search-group__head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
}

.search-group__head span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.search-group__list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  color: var(--text);
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover {
  background: var(--bg-soft);
}

.search-result__image,
.search-result__mark {
  display: grid;
  width: 76px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  object-fit: cover;
}

.search-result__body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.search-result__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
}

.search-result__badge {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
}

.search-result__meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.search-result__snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.search-result__arrow {
  margin-left: auto;
  color: var(--muted-2);
}

.search-empty {
  margin-top: 30px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.search-empty__title {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 20px;
}

.search-empty .tag-row {
  justify-content: center;
  margin: 18px 0;
}

.search-empty__links {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}

.search-empty--results {
  text-align: left;
}

/* ---------- 404 ---------- */

.not-found {
  padding: 80px 20px;
  text-align: center;
}

.not-found h1 {
  margin: 8px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
}

.not-found p {
  max-width: 48ch;
  margin: 0 auto 24px;
  color: var(--muted);
  line-height: 1.8;
}

.not-found__actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ---------- footer ---------- */

.site-footer {
  display: flex;
  width: 100%;
  max-width: calc(var(--content-max) + 64px);
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  padding: 22px 32px 30px;
  color: var(--muted-2);
  font-size: 10.5px;
}

.site-footer__meta {
  font-family: var(--font-mono);
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .grid--worlds,
  .grid--characters,
  .grid--orgs,
  .grid--wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-layout,
  .world-layout {
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 28px;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-w: 0px;
  }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lift);
    transition: transform 0.2s var(--ease);
  }

  .app-main {
    margin-left: 0;
  }

  .mobile-bar {
    display: flex;
  }

  .main {
    padding: 26px 20px 60px;
  }

  .site-footer {
    padding: 18px 20px 26px;
  }

  .page-header--with-aside {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header__count {
    border-left: 0;
    padding-left: 0;
    text-align: left;
  }

  .profile-header {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .profile-header__summary {
    border-left: 0;
    padding-left: 0;
  }

  .detail-layout,
  .world-layout {
    grid-template-columns: 1fr;
  }

  .infobox,
  .side-panel--sticky,
  .world-aside {
    position: static;
  }

  .detail-layout > .infobox {
    order: -1;
  }

  .world-hero,
  .org-hero {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .section--split {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .archive-note {
    border-top: 1px solid var(--border);
    border-left: 0;
    padding-top: 22px;
    padding-left: 0;
  }
}

@media (max-width: 620px) {
  .grid--worlds,
  .grid--characters,
  .grid--orgs,
  .grid--wide,
  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card__media {
    margin: 8px 8px 0;
  }

  .card__body {
    padding: 10px 10px 12px;
  }

  .card__title {
    font-size: 15px;
  }

  .card__summary {
    font-size: 11.5px;
  }

  .card__aliases,
  .card__meta {
    font-size: 10.5px;
  }

  .tag {
    padding: 2px 5px;
    font-size: 9.5px;
  }

  .hero {
    padding: 24px 20px;
  }

  .hero__title {
    font-size: 2.1rem;
  }

  .stats__item {
    margin-right: 16px;
    padding-right: 16px;
  }

  .stats__item strong {
    font-size: 20px;
  }

  .filter-group {
    flex-direction: column;
    gap: 4px;
  }

  .filter-group__label {
    flex: none;
    padding-top: 0;
  }

  .filter-sort {
    width: 100%;
  }

  .filter-sort select {
    flex: 1;
  }

  .filters__top {
    gap: 8px;
  }

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

  .search-result__image,
  .search-result__mark {
    width: 56px;
  }

  .search-result {
    padding: 9px 10px;
  }

  .search-result__snippet {
    display: none;
  }

  .search-page-form button {
    padding: 0 14px;
  }

  .site-footer {
    flex-direction: column;
    gap: 6px;
  }

  .markdown table {
    table-layout: fixed;
  }

  .markdown th,
  .markdown td {
    padding: 6px 8px;
    word-break: break-word;
  }
}

@media (max-width: 380px) {
  .grid--worlds,
  .grid--characters,
  .grid--orgs,
  .grid--wide,
  .character-grid {
    grid-template-columns: 1fr;
  }
}
