:root {
  --ink: #201913;
  --muted: #675f56;
  --paper: #f7f1e7;
  --paper-deep: #eadfcf;
  --line: #d4c4ae;
  --accent: #8b2f2b;
  --accent-2: #1f6c73;
  --olive: #596b3d;
  --gold: #b98036;
  --white: #fffaf1;
  --shadow: 0 18px 48px rgba(49, 34, 17, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(90deg, rgba(32, 25, 19, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 25, 19, 0.06) 1px, transparent 1px),
    #efe3d0;
  background-size: 44px 44px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.reader-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.library-rail,
.token-inspector {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-color: rgba(93, 73, 51, 0.22);
  background: rgba(255, 250, 241, 0.82);
  backdrop-filter: blur(18px);
}

.library-rail {
  border-right: 1px solid rgba(93, 73, 51, 0.22);
  padding: 22px 18px;
}

.token-inspector {
  border-left: 1px solid rgba(93, 73, 51, 0.22);
  padding: 26px 22px;
}

.brand-mark {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark svg {
  color: var(--accent);
}

.brand-mark strong,
.brand-mark span {
  display: block;
}

.brand-mark strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.brand-mark span,
.eyebrow,
.source-note,
.context-cards span,
.morph-list dt {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.passage-tabs {
  display: grid;
  gap: 10px;
}

.passage-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.62);
  color: var(--ink);
  cursor: pointer;
  padding: 13px;
  text-align: left;
}

.passage-tab span,
.passage-tab strong {
  display: block;
}

.passage-tab strong {
  margin-top: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
}

.passage-tab.active {
  border-color: rgba(139, 47, 43, 0.38);
  background: #fff8ec;
  box-shadow: 0 10px 24px rgba(88, 50, 22, 0.09);
}

.source-note {
  display: flex;
  gap: 9px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(93, 73, 51, 0.2);
  line-height: 1.55;
  text-transform: none;
}

.source-note p {
  margin: 0;
}

.reading-stage {
  padding: 34px clamp(22px, 4vw, 58px);
}

.passage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.passage-header h1 {
  margin: 5px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.2rem);
  font-weight: 600;
  line-height: 0.98;
}

.passage-header p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.status-pill,
.edit-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid rgba(31, 108, 115, 0.24);
  background: #e6f0ee;
  color: #164d54;
  white-space: nowrap;
}

.status-pill {
  padding: 9px 12px;
  font-size: 0.84rem;
}

.latin-panel {
  min-height: 320px;
  border: 1px solid rgba(93, 73, 51, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(139, 47, 43, 0.08), transparent 42%),
    var(--white);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 54px);
}

.sentence {
  margin: 0 0 22px;
  border-left: 3px solid transparent;
  padding: 5px 0 5px 17px;
  color: rgba(32, 25, 19, 0.68);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3.1vw, 3rem);
  line-height: 1.65;
}

.sentence.selected {
  border-left-color: var(--gold);
  color: var(--ink);
}

.token {
  margin: 0 4px 7px 0;
  border: 0;
  border-bottom: 2px solid rgba(139, 47, 43, 0.2);
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 2px 2px 0;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.1;
}

.token:hover,
.token.active {
  background: #f1dcc0;
  border-bottom-color: var(--accent);
  color: #551b19;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
}

.analysis-panel {
  border: 1px solid rgba(93, 73, 51, 0.22);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.82);
  box-shadow: 0 12px 32px rgba(49, 34, 17, 0.08);
  padding: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.panel-title h2,
.inspector-section h3 {
  margin: 0;
  font-size: 1rem;
}

.translation {
  border-left: 3px solid var(--accent-2);
  margin: 0 0 12px;
  padding-left: 12px;
  color: #164d54;
  font-weight: 700;
}

.dependency-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.dependency-strip span {
  display: grid;
  min-width: 112px;
  border: 1px solid rgba(89, 107, 61, 0.25);
  border-radius: 8px;
  background: #f0f3e9;
  padding: 9px;
}

.dependency-strip small {
  color: var(--olive);
}

.dependency-strip em {
  color: var(--muted);
  font-style: normal;
}

.map-board {
  position: relative;
  height: 170px;
  overflow: hidden;
  border: 1px solid rgba(93, 73, 51, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 70%, rgba(31, 108, 115, 0.26) 0 12%, transparent 13%),
    radial-gradient(circle at 60% 35%, rgba(89, 107, 61, 0.24) 0 18%, transparent 19%),
    radial-gradient(circle at 45% 56%, rgba(185, 128, 54, 0.22) 0 14%, transparent 15%),
    linear-gradient(135deg, #d7c7ad, #f7ecd9);
}

.map-board::before,
.map-board::after {
  content: "";
  position: absolute;
  inset: 18px 30px;
  border: 1px dashed rgba(32, 25, 19, 0.18);
  transform: rotate(-9deg);
}

.map-board::after {
  inset: 38px 80px 28px 54px;
  transform: rotate(15deg);
}

.map-pin {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #fff8ec;
  color: var(--accent);
  box-shadow: 0 7px 18px rgba(32, 25, 19, 0.22);
  transform: translate(-50%, -50%);
}

.context-cards {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.context-cards article {
  border-left: 3px solid var(--gold);
  background: rgba(255, 255, 255, 0.45);
  padding: 10px 12px;
}

.context-cards h3,
.context-cards p {
  margin: 3px 0 0;
}

.timeline {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 18px 82px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 0.9rem;
}

.timeline strong {
  color: var(--ink);
}

.inspector-header {
  border-bottom: 1px solid rgba(93, 73, 51, 0.22);
  margin-bottom: 18px;
  padding-bottom: 18px;
}

.inspector-header h2 {
  margin: 4px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  line-height: 1;
}

.inspector-header p,
.analysis-panel p,
.inspector-section p {
  color: var(--muted);
  line-height: 1.55;
}

.morph-list {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.morph-list div {
  border: 1px solid rgba(93, 73, 51, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.72);
  padding: 10px 12px;
}

.morph-list dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.inspector-section {
  border-top: 1px solid rgba(93, 73, 51, 0.18);
  padding: 16px 0 0;
  margin-top: 16px;
}

.inspector-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.translation-box {
  border: 1px solid rgba(31, 108, 115, 0.22);
  border-radius: 8px;
  background: #e9f0ec;
  padding: 14px;
}

.edit-button {
  justify-content: center;
  width: 100%;
  margin-top: 18px;
  padding: 12px 14px;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .reader-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .token-inspector {
    position: static;
    grid-column: 1 / -1;
    height: auto;
    border-top: 1px solid rgba(93, 73, 51, 0.22);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .reader-shell,
  .analysis-grid {
    display: block;
  }

  .library-rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(93, 73, 51, 0.22);
  }

  .passage-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .reading-stage {
    padding: 22px 14px;
  }

  .passage-header {
    display: block;
  }

  .status-pill {
    margin-top: 16px;
  }

  .analysis-panel {
    margin-top: 14px;
  }

  .sentence {
    padding-left: 11px;
  }
}
