#historyView {
  --history-ink: #183b36;
  --history-paper: #fffdf8;
}

.history-intro {
  padding: clamp(18px, 3vw, 34px);
  color: white;
  background: linear-gradient(135deg, #174f47, #276b58 62%, #a65a2a);
  border-radius: 20px;
  box-shadow: 0 16px 34px rgba(20, 65, 56, .16);
}

.history-intro .small { color: #e2f2e9; }
.history-featured { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:18px; }
.history-featured-label { width:100%; font-size:.76rem; font-weight:850; letter-spacing:.08em; text-transform:uppercase; color:#dbeee4; }
.history-anchor-chip { min-height:36px; padding:7px 11px; color:#123d36; background:#fffdf8; border-color:rgba(255,255,255,.45); font-size:.84rem; }
.history-anchor-chip:hover { background:#ffe1aa; }
.history-toolbar { box-shadow: 0 8px 22px rgba(27, 63, 56, .08); }
.history-toolbar label[for="historySearch"] { align-self: center; }
.history-toolbar input:focus-visible,
.history-toolbar select:focus-visible,
.history-list-button:focus-visible,
.history-layer-trail button:focus-visible,
.history-controls button:focus-visible {
  outline: 3px solid #f2a64d;
  outline-offset: 3px;
}

.history-list-panel { box-shadow: 0 10px 26px rgba(26, 58, 52, .08); }
.history-list-button { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:4px 10px; border:1px solid #d9e2d6; background:#fffdf8; }
.history-list-button:hover { border-color:#6d987b; background:#f4f8ee; }
.history-list-title { font-weight:780; line-height:1.25; }
.history-list-meta { color:var(--muted); font-size:.72rem; white-space:nowrap; }
.history-list-button.selected .history-list-meta { color:#e5f3e9; }
.history-detail-heading h2 { color: var(--history-ink); line-height: 1.15; }
.history-mode-tabs { display:flex; flex-wrap:wrap; gap:7px; margin:0 0 18px; padding-bottom:12px; border-bottom:1px solid var(--line); }
.history-mode-tabs button { background:#f2f5ed; color:var(--history-ink); border-color:#c9d6c8; }
.history-mode-tabs button.selected { background:var(--history-ink); color:white; border-color:var(--history-ink); }
.history-review-note { margin:0 0 18px; padding:10px 13px; background:#fff3d9; border-left:4px solid #c9791b; border-radius:6px; font-size:.9rem; }
.history-overview { font-size: 1.04rem; line-height: 1.65; margin: 18px 0; }
.history-reader-section, .history-timeline, .history-remember, .history-sources-open { padding:20px 0; border-top:1px solid var(--line); }
.history-reader-section:first-of-type { border-top:0; }
.history-reader-section h3, .history-timeline h3, .history-remember h3, .history-sources-open h3 { color:var(--history-ink); margin-bottom:10px; }
.history-reader-section p, .history-timeline p { max-width:73ch; line-height:1.7; }
.history-reader-controls { display:flex; justify-content:flex-end; margin:-4px 0 14px; }
.history-reader-controls button { min-height:36px; font-size:.84rem; }
.history-reader-section ul { padding-left:22px; line-height:1.65; }
.history-timeline { background:#f4f7ec; padding:18px 20px; margin:18px 0; border:1px solid var(--line); border-radius:12px; }
.history-remember { margin:18px 0; padding:18px 20px; background:#e8f0e2; border-radius:12px; border:1px solid #c8d7c3; }
.history-remember p { font-weight:750; margin-bottom:0; }
.history-sources-open { margin-top:8px; }
.history-sources-open article { padding:13px 0; border-top:1px solid #ddcfb8; }
.history-sources-open h4 { margin:0 0 4px; font-size:1rem; }
.history-sources-open a { color:#175b49; text-decoration-thickness:2px; text-underline-offset:3px; }
.place-history-link { margin-top:18px; padding:16px; background:#f0f5e9; border:1px solid #c9d8c4; border-radius:14px; }
.place-history-link h3 { margin:4px 0 6px; color:#183b36; font-size:1.04rem; }
.place-history-link p:not(.eyebrow) { margin:0 0 10px; font-size:.9rem; }
.history-place-button { width:100%; margin-top:7px; text-align:left; color:#183b36; background:#fffdf8; border-color:#b9cdb7; font-size:.86rem; }
.history-place-button:hover { background:#ffe2a8; }
.history-controls button:disabled { opacity: .45; cursor: not-allowed; }

.history-active-layer {
  position: relative;
  margin: 14px 0 18px;
  padding: 18px 20px 18px 24px;
  background: var(--history-paper);
  border: 1px solid #dcccae;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(79, 59, 29, .07);
}

.history-active-layer::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: #c15112;
  border-radius: 12px 0 0 12px;
}

.history-active-layer h3 { margin: 3px 0; }
.history-active-layer p:last-child { margin-bottom: 0; }
.history-layer-trail li { transition: transform .15s ease, box-shadow .15s ease; }
.history-layer-trail li:has(button.selected) { box-shadow: 0 5px 14px rgba(151, 86, 31, .15); transform: translateY(-2px); }
.history-layer-dot { transition: r .15s ease, fill .15s ease; }

.history-vocabulary {
  margin-top: 20px;
  padding: 18px 20px;
  background: #f4f7ec;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-vocabulary dl { display: grid; grid-template-columns: minmax(110px, .35fr) 1fr; gap: 8px 18px; margin: 0; }
.history-vocabulary dt { font-weight: 850; color: var(--history-ink); }
.history-vocabulary dd { margin: 0; color: var(--muted); }
.history-activity { margin: 16px 0 0; padding: 14px 16px; background: white; border-radius: 9px; font-weight: 750; }

.history-sources {
  margin-top: 22px;
  padding: 0 18px 12px;
  background: #f7f2e8;
  border: 1px solid #ddcfb8;
  border-radius: 12px;
}

.history-sources summary { padding: 16px 0; color: var(--history-ink); font-weight: 850; cursor: pointer; }
.history-sources article { padding: 13px 0; border-top: 1px solid #ddcfb8; }
.history-sources h4 { margin: 0 0 4px; font-size: 1rem; }
.history-sources article p { margin: 5px 0 0; }
.history-sources a { color: #175b49; text-decoration-thickness: 2px; text-underline-offset: 3px; }

@media (max-width: 720px) {
  .history-intro { border-radius: 14px; }
  .history-toolbar { display: grid; grid-template-columns: 1fr; }
  .history-toolbar > * { width: 100%; }
  .history-featured { gap:6px; }
  .history-anchor-chip { flex:1 1 auto; }
  .history-mode-tabs { display:grid; grid-template-columns:repeat(2, 1fr); }
  .history-reader-controls { justify-content:stretch; }
  .history-reader-controls button { width:100%; }
  .history-vocabulary dl { grid-template-columns: 1fr; gap: 4px; }
  .history-vocabulary dd { margin-bottom: 9px; }
  .history-controls { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .history-layer-trail li,
  .history-layer-dot { transition: none; }
}
