:root {
  --bg: #0c0d10;
  --panel: #15171c;
  --panel-2: #1b1e25;
  --paper: #ece4d3;
  --line: #2a2d35;
  --line-soft: #1f2229;
  --text: #eee8dc;
  --muted: #9a9fab;
  --red: #9c332c;
  --red-bright: #c1493a;
  --gold: #c6a15b;
  --gold-soft: #8d7442;
  --shadow: 0 30px 70px rgba(0, 0, 0, .45);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p, ol { margin: 0; }
.muted { color: var(--muted); }

/* ---------- Shell layout ---------- */

.shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.brand__mark {
  width: 26px;
  height: 36px;
  color: var(--gold);
  flex: none;
}

.brand__title {
  display: block;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .01em;
}

.brand__subtitle {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

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

.nav__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.nav__item:hover {
  color: var(--text);
  background: var(--panel-2);
}

.nav__item[aria-current="page"] {
  color: var(--text);
  background: var(--panel-2);
  border-left-color: var(--gold);
  font-weight: 600;
}

.nav__count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sidebar__foot {
  margin-top: auto;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar__foot-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gold);
  margin-bottom: 6px;
}

.sidebar__foot p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.scrollarea {
  height: 100vh;
  overflow-y: auto;
}

main {
  width: min(980px, calc(100% - 64px));
  margin: 0 auto;
  padding: 40px 0 90px;
}

.screen[hidden] { display: none; }

/* ---------- Page headers ---------- */

.pagehead {
  margin-bottom: 28px;
}

.pagehead__lede {
  max-width: 62ch;
  margin-top: 10px;
  color: var(--muted);
  font-size: 16px;
}

.kicker {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 8px;
}

h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
}

.pagehead--hero {
  position: relative;
  min-height: 300px;
  display: flex;
  align-items: flex-end;
  padding: 28px;
  margin: -1px -1px 24px;
  border-radius: 14px;
  background-size: cover;
  background-position: center 20%;
  overflow: hidden;
  border: 1px solid var(--line);
}

.pagehead--hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 13, 16, .55) 0%, rgba(12, 13, 16, .96) 100%);
}

.pagehead__scrim {
  position: relative;
  max-width: 640px;
}

.pagehead--hero h1 {
  font-size: 42px;
  margin: 6px 0 10px;
}

.pagehead--hero .pagehead__lede {
  color: #d8d2c4;
  font-size: 17px;
}

/* ---------- Home ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--gold);
}

.stat span {
  font-size: 12.5px;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.card {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card p { font-size: 14.5px; line-height: 1.55; }

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  padding: 0 12px;
  height: 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover { color: var(--text); }

.chip.is-active {
  color: var(--bg);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
}

/* ---------- Characters ---------- */

.character-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, .95fr);
  gap: 18px;
  align-items: start;
}

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

.character-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
}

.character-card:hover,
.character-card.is-active {
  border-color: var(--gold-soft);
}

.character-card.is-active {
  box-shadow: inset 0 0 0 1px var(--gold-soft);
}

.character-card__frame {
  aspect-ratio: 16 / 11;
  background: var(--paper);
  display: block;
}

.character-card__frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.character-card__body {
  padding: 12px 13px 14px;
}

.character-card__body h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 6px 0 4px;
}

.character-card__body p {
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag--protagonista, .tag--deuteragonista { color: var(--gold); }
.tag--antagonista { color: var(--red-bright); }
.tag--coadjuvante, .tag--default { color: #7fa0b8; }

.profile {
  position: sticky;
  top: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.profile__frame {
  aspect-ratio: 16 / 11;
  background: var(--paper);
}

.profile__frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.profile__body { padding: 20px; }

.profile__body h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin: 8px 0 4px;
}

.profile__role {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.profile__body h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gold);
  margin: 16px 0 6px;
}

.profile__body p,
.profile__body li { font-size: 14px; line-height: 1.55; color: var(--text); }

.profile__body ul { margin: 0; padding-left: 18px; color: var(--muted); }

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.thumb-strip button {
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  overflow: hidden;
  cursor: pointer;
}

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

.empty {
  padding: 26px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Timeline ---------- */

.era {
  margin-bottom: 26px;
}

.era__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.era__head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

.era__count {
  font-size: 12.5px;
  color: var(--muted);
}

.timeline {
  position: relative;
  display: grid;
  gap: 10px;
  padding-left: 20px;
}

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

.timeline-item {
  position: relative;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 19px;
  left: -20px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
}

.timeline-item.is-planejado::before,
.timeline-item.is-rascunho::before { background: var(--muted); }

.timeline-item h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.timeline-item p {
  font-size: 13.5px;
  color: var(--muted);
}

.status-pill {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  margin-left: 8px;
}

/* ---------- Consistency ---------- */

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

.compare figure {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.compare__frame {
  aspect-ratio: 4 / 3;
  background: var(--paper);
}

.compare img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.compare figcaption {
  padding: 10px 13px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Chapters ---------- */

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

.chapter-card {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.chapter-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 10px 0 3px;
}

.chapter-card .muted { font-size: 13px; }

.progress-row {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.progress-track {
  height: 5px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
}

.progress-fill.is-pending { background: var(--line); }
.progress-fill.is-progress { background: var(--red-bright); }

/* ---------- Operation ---------- */

.operation-list {
  display: grid;
  gap: 12px;
  counter-reset: op;
  padding: 0;
}

.operation-list li {
  list-style: none;
  counter-increment: op;
  position: relative;
  padding: 16px 18px 16px 54px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.operation-list li::before {
  content: counter(op);
  position: absolute;
  left: 18px;
  top: 16px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.operation-list h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.operation-list p { font-size: 14px; color: var(--muted); }

code {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--gold);
  font-size: .93em;
}

/* ---------- Dialog ---------- */

dialog {
  width: min(1100px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
  position: relative;
}

dialog::backdrop { background: rgba(0, 0, 0, .82); }

dialog img {
  width: 100%;
  max-height: calc(100vh - 90px);
  object-fit: contain;
  display: block;
}

.dialog-caption {
  padding: 12px 16px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; height: auto; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    overflow-x: auto;
  }
  .brand__subtitle { display: none; }
  .nav { flex-direction: row; }
  .nav__item { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .nav__item[aria-current="page"] { border-left-color: transparent; border-bottom-color: var(--gold); }
  .sidebar__foot { display: none; }
  .scrollarea { height: auto; overflow: visible; }
  main { padding: 24px 0 60px; }
  .split, .character-layout, .compare, .chapter-grid, .character-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile { position: static; }
  h1 { font-size: 28px; }
  .pagehead--hero h1 { font-size: 32px; }
}
