:root {
  color-scheme: light;
  --bg: #f5f0e7;
  --bg-soft: #efe6d7;
  --surface: rgba(255, 250, 243, 0.86);
  --surface-strong: rgba(255, 248, 240, 0.96);
  --surface-muted: rgba(109, 84, 59, 0.06);
  --ink: #23180f;
  --ink-soft: #675547;
  --line: rgba(69, 48, 28, 0.14);
  --line-strong: rgba(69, 48, 28, 0.22);
  --accent: #7b5534;
  --accent-deep: #5b3d23;
  --accent-soft: #b58b63;
  --accent-green: #4d6b50;
  --danger: #a74848;
  --shadow: 0 24px 64px rgba(57, 35, 20, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(181, 139, 99, 0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(77, 107, 80, 0.18), transparent 22%),
    linear-gradient(180deg, #f6f1e9 0%, #eee4d5 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(123, 85, 52, 0.04) 1px, transparent 1px);
  background-size: 100% 7px;
  opacity: 0.3;
}

.page-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.55;
}

.page-glow-a {
  top: -5rem;
  right: -4rem;
  width: 18rem;
  height: 18rem;
  background: rgba(181, 139, 99, 0.28);
}

.page-glow-b {
  bottom: -7rem;
  left: -5rem;
  width: 22rem;
  height: 22rem;
  background: rgba(77, 107, 80, 0.2);
}

.app-shell {
  position: relative;
  padding: 1.5rem;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.brand-block {
  display: grid;
  gap: 0.65rem;
}

.brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  gap: 1rem;
  align-items: end;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.04;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  max-width: 12ch;
}

h2 {
  font-size: clamp(1.6rem, 2vw, 2.2rem);
}

h3 {
  font-size: 1.15rem;
}

.lede,
.hero-world-premise,
.detail-list,
.ordered-list,
.selected-entity-card,
.reference-list,
.entity-summary-copy,
.scene-card p,
.relationship-copy,
.stack-form,
.field,
.card p {
  color: var(--ink-soft);
}

.lede {
  margin: 0;
  line-height: 1.65;
  font-size: 1rem;
  max-width: 36rem;
}

.topbar-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.view-switcher,
.action-group {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.view-pill,
.button {
  min-height: 2.8rem;
  border-radius: 999px;
  padding: 0.82rem 1.1rem;
  border: 1px solid transparent;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.view-pill {
  background: rgba(255, 250, 243, 0.75);
  border-color: rgba(123, 85, 52, 0.14);
  color: var(--ink);
}

.view-pill.active {
  background: linear-gradient(180deg, rgba(123, 85, 52, 0.9), rgba(91, 61, 35, 0.92));
  color: #fff8ef;
  box-shadow: 0 14px 26px rgba(91, 61, 35, 0.18);
}

.button-primary {
  background: linear-gradient(180deg, rgba(123, 85, 52, 0.96), rgba(91, 61, 35, 1));
  color: #fff7ed;
  box-shadow: 0 16px 28px rgba(91, 61, 35, 0.18);
}

.button-secondary {
  background: rgba(123, 85, 52, 0.08);
  border-color: rgba(123, 85, 52, 0.18);
  color: var(--ink);
}

.button-ghost {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(123, 85, 52, 0.14);
  color: var(--ink);
}

.button-danger {
  background: rgba(167, 72, 72, 0.08);
  border-color: rgba(167, 72, 72, 0.16);
  color: var(--danger);
}

.button:hover,
.view-pill:hover {
  transform: translateY(-1px);
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.card-stack {
  display: grid;
  gap: 1rem;
}

.sidebar,
.inspector {
  position: sticky;
  top: 1rem;
}

.card,
.view-panel {
  background: linear-gradient(180deg, var(--surface), var(--surface-strong));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.card {
  padding: 1.1rem;
}

.hero-panel {
  padding: 1.2rem;
}

.hero-meta {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(16rem, 1fr);
  gap: 1rem;
  align-items: end;
}

.hero-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.summary-card,
.metric-card,
.mini-card,
.entity-card,
.scene-card,
.relation-row,
.insight-row {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(123, 85, 52, 0.12);
}

.summary-label,
.metric-label,
.mini-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.summary-card strong,
.metric-card strong,
.mini-card strong,
.entity-card strong,
.scene-card strong {
  display: block;
  margin-top: 0.35rem;
}

.metric-grid,
.mini-grid,
.overview-grid,
.codex-layout,
.manuscript-layout,
.graph-layout {
  display: grid;
  gap: 1rem;
}

.metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.overview-grid {
  grid-template-columns: 1.15fr 0.85fr;
  margin-top: 1rem;
}

.mini-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.codex-layout,
.manuscript-layout,
.graph-layout {
  margin-top: 1rem;
}

.codex-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.manuscript-layout {
  grid-template-columns: 260px minmax(0, 1fr);
}

.graph-layout {
  grid-template-columns: minmax(0, 1fr) 280px;
}

.card-header,
.section-header,
.toolbar,
.scene-toolbar,
.mention-row,
.relation-toolbar,
.storyline-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.section-header {
  margin-bottom: 0.8rem;
}

.section-copy {
  margin: 0.3rem 0 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.status-chip,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(123, 85, 52, 0.16);
  background: rgba(123, 85, 52, 0.08);
  color: var(--accent-deep);
  font-size: 0.78rem;
}

.chip-muted,
.tag-muted {
  background: rgba(109, 84, 59, 0.06);
  color: var(--ink-soft);
}

.tag-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.field span {
  font-size: 0.76rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(123, 85, 52, 0.16);
  border-radius: var(--radius-md);
  color: var(--ink);
  padding: 0.88rem 0.95rem;
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
.view-pill:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(123, 85, 52, 0.12);
}

textarea {
  resize: vertical;
  min-height: 7rem;
}

.button-full {
  width: 100%;
  margin-top: 1rem;
}

.detail-list,
.reference-list,
.entity-list,
.story-list,
.ordered-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list li,
.reference-list li,
.ordered-list li {
  padding: 0.75rem 0;
  border-top: 1px solid rgba(123, 85, 52, 0.1);
}

#relation-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.relation-delete {
  min-height: 2.2rem;
  padding: 0.45rem 0.8rem;
  white-space: nowrap;
}

.detail-list li:first-child,
.reference-list li:first-child,
.ordered-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.ordered-list {
  counter-reset: interview-step;
}

.ordered-list li {
  counter-increment: interview-step;
  padding-left: 2.2rem;
  position: relative;
}

.ordered-list li::before {
  content: counter(interview-step);
  position: absolute;
  left: 0;
  top: 0.7rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(123, 85, 52, 0.12);
  color: var(--accent-deep);
  font-size: 0.75rem;
}

.toolbar {
  margin-top: 1rem;
}

.grow {
  flex: 1;
}

.entity-list {
  display: grid;
  gap: 0.75rem;
}

.entity-list button,
.story-list button,
.reference-list button {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(123, 85, 52, 0.12);
  color: var(--ink);
  border-radius: var(--radius-lg);
  padding: 0.95rem;
}

.entity-list button.active,
.story-list button.active {
  border-color: rgba(123, 85, 52, 0.26);
  box-shadow: inset 0 0 0 1px rgba(123, 85, 52, 0.16);
  background: rgba(255, 249, 241, 0.96);
}

.story-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.story-list strong,
.entity-title-row strong {
  font-family: Georgia, "Times New Roman", serif;
}

.entity-title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
}

.entity-summary-copy,
.scene-card p,
.relationship-copy {
  margin: 0.45rem 0 0;
  line-height: 1.55;
}

.stack-form {
  margin-top: 0.85rem;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.graph-svg {
  width: 100%;
  min-height: 420px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top, rgba(123, 85, 52, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(255, 252, 247, 0.94), rgba(245, 236, 223, 0.95));
  border: 1px solid rgba(123, 85, 52, 0.12);
}

.graph-node {
  fill: rgba(255, 250, 243, 0.95);
  stroke: rgba(123, 85, 52, 0.42);
  stroke-width: 2;
}

.graph-node.active {
  fill: rgba(181, 139, 99, 0.2);
  stroke: rgba(123, 85, 52, 0.9);
}

.graph-edge {
  stroke: rgba(123, 85, 52, 0.24);
  stroke-width: 2;
}

.graph-label {
  fill: var(--ink);
  font-size: 12px;
  text-anchor: middle;
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
}

.selected-entity-card .description {
  margin-top: 0.85rem;
  line-height: 1.65;
}

.hidden {
  display: none;
}

.empty-state {
  color: var(--ink-soft);
  padding: 0.75rem 0;
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .inspector {
    position: static;
  }
}

@media (max-width: 1024px) {
  .brand-row,
  .hero-meta,
  .overview-grid,
  .codex-layout,
  .manuscript-layout,
  .graph-layout,
  .inline-grid,
  .hero-summary-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 1rem;
  }

  h1 {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
