.history-page { min-height: 100vh; background: var(--paper); }
.history-page [hidden] { display: none !important; }
.history-wrap { width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.history-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px 0; border-bottom: 1px solid var(--rule); }
.history-header .brand { color: var(--ink) !important; }
.history-header nav { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; gap: 8px 20px; font-size: .9rem; }
.history-header a { text-decoration: none; max-width: 100%; overflow-wrap: anywhere; }
.history-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 36px 0 12px; }
.history-heading h1 { color: var(--ink); font-size: clamp(2rem, 4vw, 3rem); line-height: 1.15; letter-spacing: -.04em; margin: 8px 0; }
.history-kicker { color: var(--link); font: 700 .72rem var(--mono); letter-spacing: .08em; margin: 0; }
.history-intro { color: var(--muted); margin: 10px 0; }
.history-notice { color: var(--muted); min-height: 1.6em; font-size: .85rem; overflow-wrap: anywhere; }
.history-notice.error { color: var(--red); }
.history-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 16px 0 24px; font-size: .85rem; }
.history-toolbar label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.history-toolbar select { background: var(--surface); color: var(--ink); border: 1px solid var(--rule); padding: 8px; border-radius: 8px; font: inherit; }
.history-checkbox { cursor: pointer; }
.history-checkbox input { width: 17px; height: 17px; accent-color: var(--brand); }
.history-count { color: var(--muted); margin-left: auto; font: .8rem var(--mono); }
.history-layout { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.6fr); gap: 24px; align-items: start; padding-bottom: 60px; }
.history-sidebar { min-width: 0; padding: 0; }
.history-list { display: grid; gap: 10px; }
.wake-list-item { display: block; width: 100%; text-align: left; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 12px; padding: 18px; cursor: pointer; font: inherit; }
.wake-list-item:hover { border-color: var(--brand); }
.wake-list-item[aria-current="true"] { border-color: var(--brand); box-shadow: inset 3px 0 var(--brand); background: var(--brand-soft); }
.wake-item-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.wake-item-agent { font: 600 .75rem var(--mono); overflow-wrap: anywhere; color: var(--muted); }
.wake-item-question { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: .98rem; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.wake-item-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted); font-size: .75rem; }
.wake-state { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 20px; background: var(--surface-alt); color: var(--muted); font: 700 .68rem var(--mono); white-space: nowrap; }
.wake-state.pending { color: var(--link); background: var(--brand-soft); }
.wake-state.acked { color: #a65b00; background: rgba(229,147,18,.14); }
.wake-state.resolved { color: #19803a; background: rgba(47,179,87,.13); }
.wake-state.hibernated { color: var(--muted); }
.history-detail { min-width: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; padding: 28px; }
.history-detail h2 { font-size: 1.35rem; line-height: 1.5; overflow-wrap: anywhere; margin: 16px 0; text-align: left; }
.history-detail h3 { font-size: 1rem; margin: 26px 0 14px; }
.history-detail p { overflow-wrap: anywhere; }
.history-detail-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; }
.history-detail-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.history-room-link { color: var(--link); font-size: .85rem; }
.history-chain { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.history-hop { border: 1px solid var(--rule); padding: 8px 10px; border-radius: 8px; font-size: .8rem; overflow-wrap: anywhere; }
.history-hop.active { border-color: var(--brand); background: var(--brand-soft); }
.history-decision { background: rgba(47,179,87,.08); border: 1px solid rgba(47,179,87,.3); padding: 16px; border-radius: 10px; margin: 20px 0; }
.history-decision h3 { margin: 0 0 8px; }
.history-decision p { margin: 8px 0 0; }
.history-note { white-space: pre-wrap; font-size: .9rem; }
.history-receipt { display: block; font-size: .7rem; overflow-wrap: anywhere; margin-top: 14px; color: var(--muted); }
.history-info { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.history-warning { color: #a65b00; background: rgba(229,147,18,.1); padding: 12px; border-radius: 8px; font-size: .85rem; }
.history-events { list-style: none; padding: 0; margin: 20px 0 0; }
.history-event { position: relative; padding: 0 0 24px 28px; border-left: 1px solid var(--rule); margin-left: 5px; }
.history-event:last-child { border-left-color: transparent; padding-bottom: 0; }
.history-event::before { content: ""; position: absolute; left: -5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px var(--surface); }
.history-event.delivery_succeeded::before, .history-event.resolved::before { background: var(--green); }
.history-event.delivery_failed::before { background: var(--red); }
.history-event.escalated::before, .history-event.dispatch_started::before { background: var(--brand); }
.history-event.acknowledged::before, .history-event.delivery_skipped::before { background: var(--amber); }
.history-event-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; font-size: .85rem; }
.history-event time { color: var(--muted); font-size: .73rem; }
.history-event p { color: var(--muted); font-size: .85rem; line-height: 1.6; margin: 6px 0 0; }
.history-event-target { display: block; font: .73rem var(--mono); color: var(--muted); margin-top: 6px; }
.history-empty { text-align: center; color: var(--muted); padding: 48px 18px; }
.history-empty h2 { color: var(--ink); }
.history-empty-icon { color: var(--brand); font-size: 2rem; }
.history-empty .btn-solid { display: inline-block; margin-top: 12px; text-decoration: none; }
.history-more { display: block; width: 100%; margin-top: 16px; }
.history-back { display: none; }
.history-page button:focus-visible, .history-page a:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
@media (prefers-color-scheme: dark) { .wake-state.resolved { color: #7cdb98; } .wake-state.acked, .history-warning { color: #f4bf69; } }
@media (max-width: 720px) {
  .history-wrap { width: calc(100% - 32px); }
  .history-header { padding: 20px 0; flex-wrap: wrap; gap: 14px; }
  .history-header nav { gap: 8px 16px; }
  .history-heading { padding-top: 24px; }
  .history-layout { grid-template-columns: 1fr; gap: 20px; }
  .history-toolbar { gap: 16px; }
  .history-count { width: 100%; margin-left: 0; }
  .history-detail { padding: 20px; }
  .history-toolbar select { font-size: 16px; }
  .history-back { display: inline-block; }
  .history-page button, .history-header a { min-height: 44px; }
}
