:root {
  --bg-ink: #12100e;
  --bg-smoke: #1d1a17;
  --panel: #231f1b;
  --panel-2: #2d2722;
  --text-main: #f1e8d7;
  --text-dim: #c0b29d;
  --accent: #d17c38;
  --accent-2: #a53f2b;
  --ok: #4f8f5a;
  --warn: #ba3f3f;
  --line: #3d342d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 10% -10%, #40352e 0%, rgba(64, 53, 46, 0) 35%),
    radial-gradient(circle at 100% 10%, #3a251d 0%, rgba(58, 37, 29, 0) 40%),
    linear-gradient(120deg, var(--bg-ink), var(--bg-smoke));
  min-height: 100vh;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 280px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #171310, #1f1914);
  padding: 22px 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#sidebar-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

#logo-sigil {
  font-size: 1.5rem;
  color: var(--accent);
}

#wiki-title {
  margin: 6px 0 0;
  font-size: 1.45rem;
  letter-spacing: 0.03em;
}

#wiki-subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

#nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  text-decoration: none;
  color: var(--text-main);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  transform: translateX(3px);
  border-color: var(--accent);
  background: #2c251f;
}

#sidebar-footer {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--text-dim);
}

#hamburger {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 25;
  border: 1px solid var(--line);
  background: #1f1914;
  color: var(--text-main);
  font-size: 1.1rem;
  border-radius: 9px;
  width: 42px;
  height: 42px;
  display: none;
}

#content {
  margin-left: 280px;
  padding: 30px 28px;
}

.wiki-section {
  animation: reveal 0.25s ease;
}

.hidden {
  display: none;
}

.section-header h2 {
  margin: 0;
  font-size: 1.7rem;
}

.section-tagline {
  color: var(--text-dim);
  margin: 6px 0 18px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 14px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-btn,
#search-btn,
.back-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #2a221d;
  color: var(--text-main);
  padding: 8px 12px;
  cursor: pointer;
}

.filter-btn.active,
#search-btn:hover,
.back-btn:hover {
  border-color: var(--accent);
  background: #3a2a20;
}

.char-card {
  cursor: pointer;
}

.character-portrait {
  display: block;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #171310;
}

.card-portrait {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.detail-portrait {
  width: 132px;
  height: 132px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.status-alive {
  color: #8cd18e;
}

.status-deceased {
  color: #f28c8c;
}

.timeline-item {
  border-left: 3px solid var(--accent-2);
  margin: 10px 0;
  padding: 10px 12px;
  background: #251f1a;
  border-radius: 0 10px 10px 0;
}

.timeline-item .time {
  color: #f2be88;
  font-size: 0.87rem;
}

.search-bar-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

#search-input {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1a1512;
  color: var(--text-main);
}

.search-hit {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #241d19;
  padding: 10px;
  margin-bottom: 8px;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  place-items: center;
  z-index: 30;
}

#modal-overlay.hidden {
  display: none;
}

#modal-overlay:not(.hidden) {
  display: grid;
}

#modal-box {
  width: min(760px, 92vw);
  max-height: 80vh;
  overflow: auto;
  background: #201a15;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

#modal-close {
  float: right;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-main);
  border-radius: 8px;
}

a.inline-link {
  color: #ffd7ad;
}

.gem-embed-card {
  padding: 0;
  overflow: hidden;
}

.gem-embed {
  display: block;
  width: 100%;
  min-height: 78vh;
  border: 0;
  background: #0f0d0b;
}

.character-timeline {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.timeline-entry {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #2c241e, #241d18);
}

.timeline-entry-event {
  border-left-color: #8f6848;
  background: linear-gradient(180deg, #2a241f, #221c17);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.timeline-head h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-main);
}

.timeline-meta {
  border: 1px solid #5f4836;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: #f2be88;
  white-space: nowrap;
}

.timeline-summary {
  margin: 0;
  color: var(--text-dim);
  line-height: 1.45;
}

.timeline-focus {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid #7e5635;
  background: rgba(20, 14, 11, 0.35);
  border-radius: 0 8px 8px 0;
  color: #e7d6be;
}

.story-background {
  display: grid;
  gap: 10px;
  margin: 6px 0 10px;
}

.story-paragraph {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #2a221c, #231c17);
  color: var(--text-dim);
  line-height: 1.5;
}

/* Character section styling */
.character-section {
  margin-bottom: 28px;
}

.character-section-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 14px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.story-paragraph strong {
  color: var(--text-main);
}

.story-notes {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px dashed #6a4f3b;
  border-radius: 10px;
  background: rgba(20, 14, 11, 0.35);
}

.story-notes h4 {
  margin: 0 0 8px;
  color: #f2be88;
}

.story-notes ul {
  margin: 0;
  padding-left: 18px;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  #content {
    margin-left: 0;
    padding: 74px 14px 20px;
  }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 260px;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #hamburger {
    display: block;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .timeline-head {
    flex-direction: column;
  }

  .timeline-meta {
    white-space: normal;
  }
}
