.history-shell { max-width: 1160px; }
.history-heading { margin: 42px 0 28px; }
.history-heading h1 { margin: 8px 0; font-size: 30px; }
.history-filters,.history-summary { margin-bottom: 22px; }
.history-filter-row { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.history-filter-row + .history-filter-row { margin-top: 16px; }
.history-filter-row label { flex: 1 1 160px; margin: 0; }
.history-filter-row label input,.history-filter-row label select { margin-top: 6px; width: 100%; }
.history-shell select { font: inherit; font-size: 13px; line-height: 1.7; color: var(--ink); background: #ffffffd9; border: 1px solid #dce5ed; border-radius: 10px; padding: 10px 12px; min-width: 0; max-width: 100%; }
.history-shell select:focus-visible { outline: 3px solid #eaf0f5; border-color: #8ba5b9; }
.history-filter-row > button { margin-bottom: 8px; }
.history-presets { display: flex; gap: 16px; flex-wrap: wrap; padding-bottom: 10px; }
.history-metrics { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 12px; margin: 22px 0; }
.history-metric { border-left: 1px solid var(--line); padding-left: 18px; }
.history-metric:first-child { border: 0; padding-left: 0; }
.history-metric strong { display: block; font-size: 27px; font-weight: 400; color: var(--blue-dark); margin-bottom: 5px; }
.history-metric span { font-size: 12px; color: var(--muted); }
.history-analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 34px; }
.history-analysis-grid .panel { min-width: 0; }
.history-analysis-grid h2,.history-summary h2 { font-size: 16px; margin: 0; }
.history-month-controls { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12px; color: var(--blue); }
.history-weekdays,.history-calendar { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 7px; }
.history-weekdays { margin: 20px 0 9px; font-size: 11px; color: var(--muted); text-align: center; }
.history-calendar button { aspect-ratio: 1; padding: 0; border: 1px solid transparent; border-radius: 8px; font-size: 12px; color: #647f91; background: #edf3f7; }
.history-calendar [data-level="1"],.history-legend [data-level="1"] { background: #e1ebf0; }
.history-calendar [data-level="2"],.history-legend [data-level="2"] { background: #b8ceda; }
.history-calendar [data-level="3"],.history-legend [data-level="3"] { background: #86a9bd; color: white; }
.history-calendar [data-level="4"],.history-legend [data-level="4"] { background: #587d94; color: white; }
.history-calendar button[aria-pressed="true"] { outline: 2px solid var(--blue-dark); outline-offset: 2px; }
.history-calendar button:disabled { opacity: .3; cursor: default; }
.history-legend { display: flex; align-items: center; gap: 5px; margin-top: 14px; }
.history-legend i { width: 12px; height: 12px; border-radius: 3px; background: #f3f6f8; }
.history-trend { margin-top: 20px; min-height: 100px; }
.history-trend-row { display: grid; grid-template-columns: 48px minmax(30px,1fr) 130px; gap: 9px; align-items: center; margin: 14px 0; font-size: 11px; color: #7a92a3; }
.history-trend-track { height: 6px; border-radius: 4px; background: #f0f4f6; }
.history-trend-bar { height: 100%; border-radius: 4px; background: #9cb7c8; }
.history-trend-values { text-align: right; line-height: 1.6; }
#trend-grain { width: auto; padding: 5px 9px; font-size: 11px; }
.history-search { display: flex; gap: 10px; margin: 20px 0 12px; }
.history-search input { flex: 1; min-width: 0; }
.history-entry { background: var(--reading-surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 25px 28px; margin: 15px 0; }
.history-entry-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; font-size: 11px; color: #8199aa; }
.history-entry h3 { font-size: 16px; margin: 13px 0 9px; font-weight: 500; }
.history-entry p { font-size: 13px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; color: #6b8190; }
.history-entry > a { display: inline-block; margin-top: 8px; }
.history-status { font-size: 11px; color: #927c75; line-height: 1.8; }
.history-status button { margin-left: 12px; }
#history-user { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#history-more { display: block; margin: 22px auto; }
#history-auth h2 { font-size: 18px; }
@media(max-width:700px) {
  .history-heading { margin-top: 25px; }
  .history-heading h1 { font-size: 25px; }
  .history-analysis-grid { grid-template-columns: 1fr; }
  .history-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 22px 8px; }
  .history-metric { padding-left: 10px; }
  .history-metric:nth-child(4) { border: 0; padding-left: 0; }
  .history-metric strong { font-size: 22px; }
  .history-filter-row { gap: 12px; }
  .history-filter-row label { flex-basis: 110px; min-width: 0; }
  .history-entry { padding: 20px; }
  .history-trend-row { grid-template-columns: 46px minmax(20px,1fr) 120px; gap: 7px; }
}
@media(max-width:480px) {
  .history-shell .brand > span { display: none; }
  #history-user { max-width: 70px; }
  .history-analysis-grid .section-heading { flex-wrap: wrap; gap: 10px; }
  .history-analysis-grid .section-heading h2 { flex-shrink: 0; }
}
