.history-page[hidden], .history-page [hidden] { display: none !important; }
.history-page { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: max(12px, env(safe-area-inset-top)) 20px max(8px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, #02071920, #02071890 20%, #020716b8 60%, #08062345); }
/* Keep one shared title, background canvas and footer in their Home positions. */
html[data-page='history'] .app-shell > :not(.space-scene):not(.brand):not(.cosmic-footer):not(.history-page) { visibility: hidden; pointer-events: none; }
html[data-page='history'] .brand { z-index: 9; pointer-events: none; }
html[data-page='history'] .space-scene-fg { visibility: hidden; }
.history-page :focus-visible { outline: 2px solid #aaf8ff; outline-offset: 3px; }
.history-page button, .history-page input { font: inherit; }
.history-page button, .history-back { -webkit-tap-highlight-color: transparent; cursor: pointer; color: #dbecff; }
.history-page svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
/* Reserve space beneath the shared title without changing its grid geometry. */
.history-masthead { position: relative; flex: 0 0 17cqh; min-height: 42px; }
.history-back { position: absolute; top: 2px; left: 0; }
.history-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; padding: 0 2px 3px; }
.history-eyebrow { margin: 0 0 5px; font-size: 10px; letter-spacing: .24em; color: #82a8dc; }
.history-heading h2 { font-size: clamp(24px, 5.6cqw, 30px); line-height: 1; letter-spacing: .14em; font-weight: 700; text-align: left; color: #e7f8ff; text-shadow: 0 0 16px #3679d7; }
.history-heading h2:focus { outline: none; }
.history-source { border: 1px solid #6d73bb70; background: #101333b3; border-radius: 4px; padding: 5px 7px; color: #b9b9e7; font-size: 10px; letter-spacing: .08em; white-space: nowrap; }
.history-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid #417cb56e; border-radius: 12px; background: #030c24e6; box-shadow: 0 0 18px #1b43cd24; }
.history-tabs button { display: flex; justify-content: center; align-items: center; gap: 9px; min-height: 43px; padding: 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #8da9d1; font-size: 13px; font-weight: 600; letter-spacing: .08em; transition: background .2s, color .2s, box-shadow .2s; }
.history-tabs button[aria-selected='true'] { color: #eaffff; border-color: #59caffaa; background: linear-gradient(135deg, #14659c, #173784 62%, #502b87); box-shadow: inset 0 1px 10px #72dfff30, 0 0 14px #2f90f128; text-shadow: 0 0 10px #78c9ff; }
.history-panel { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #477abb; border-radius: 16px 5px 16px 5px; background: linear-gradient(140deg, #040f26f5, #03091aee 68%, #130b31ef); box-shadow: inset 0 1px #9ccfff42, 0 0 20px #2046cb25; }
.history-panel {
  container-type: size;
  --calendar-toolbar-height: 40px;
  --calendar-hint-height: 42px;
  --calendar-header-height: 38px;
  --calendar-date-width: 57px;
  --calendar-row-height: calc((100cqh - var(--calendar-toolbar-height) - var(--calendar-hint-height) - var(--calendar-header-height)) / 6);
  /* Both tabs have the same outer panel size. Use the tighter Calendar cells
     to size every result, rather than each tab's different scroll viewport. */
  --history-result-size: max(12px, min(36px, calc((100cqw - var(--calendar-date-width)) / 6 - 4px), calc(var(--calendar-row-height) - 4px)));
  --history-result-font: min(18px, calc(var(--history-result-size) * .6));
}
.history-toolbar { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 9px 14px; border-bottom: 1px solid #37649765; background: linear-gradient(100deg, #0e284980, #10153280); }
.history-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #35589b70 transparent; }
#recent-results {
  --recent-day-heading: 42px;
  --recent-column-heading: 32px;
  --recent-row-height: calc((100cqh - var(--recent-day-heading) - var(--recent-column-heading)) / 6);
}
#calendar-results {
  /* Feed refreshes and month changes must not start another scroll animation. */
  scroll-behavior: auto;
}
.history-day { margin: 0; height: 100cqh; display: grid; grid-template-rows: var(--recent-day-heading) minmax(0, 1fr); }
.history-day + .history-day { box-shadow: inset 0 1px #6483d057; }
.history-day-heading { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 0; padding: 0 16px; background: linear-gradient(90deg, #1333547d, #0f193b8a); border-bottom: 1px solid #2143697d; }
.history-day-heading time { font-size: 14px; font-weight: 600; letter-spacing: .015em; color: #dfedff; }
.history-day-heading span { font-size: 11px; letter-spacing: .08em; color: #95b9dd; }
.history-draw-table { width: 100%; height: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-variant-numeric: tabular-nums; }
.history-draw-table th { height: var(--recent-column-heading); padding: 0 18px; color: #839fc7; font-size: 11px; letter-spacing: .14em; text-align: left; font-weight: 500; }
.history-draw-table th:last-child { text-align: right; }
.history-draw-table td { height: var(--recent-row-height); border-top: 1px solid #192c4d7d; padding: 0 18px; font-size: 14px; color: #cbd7ed; }
.history-draw-table tr:nth-child(even) td { background: #10234a1f; }
.history-draw-table td:last-child { text-align: right; }
.history-result { display: inline-grid; place-items: center; width: var(--history-result-size); height: var(--history-result-size); vertical-align: middle; border: 1px solid #5294e5b0; border-radius: 50%; color: #bfefff; font-size: var(--history-result-font); font-weight: 600; line-height: 1; background: radial-gradient(circle at 40% 30%, #06162e, #010411 63%, #17103e); box-shadow: inset -1px -1px 4px #8654dd66, 0 0 9px #457cfa2b; text-shadow: 0 0 8px #41c6ff7d; }
.history-result.is-pending { border-color: #31496765; color: #7586a3; box-shadow: none; text-shadow: none; }
.history-month-toolbar { flex: 0 0 var(--calendar-toolbar-height); min-height: 0; justify-content: space-between; padding: 0 8px; }
.history-month-toolbar h3 { margin: 0; font-size: clamp(14px, 3.5cqw, 17px); letter-spacing: .04em; text-align: center; font-weight: 600; color: #d9eeff; }
.history-month-button { display: grid; place-items: center; width: 38px; height: calc(var(--calendar-toolbar-height) - 2px); padding: 0; border: 0; border-radius: 0; background: transparent; appearance: none; }
.history-month-button:hover:enabled { color: #aaf8ff; }
.history-month-button:disabled { cursor: default; opacity: .3; }
.history-calendar { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.history-calendar th { position: sticky; top: 0; z-index: 1; height: var(--calendar-header-height); padding: 0; background: #101e3b; border-bottom: 1px solid #355e90; color: #98bcdf; font-weight: 500; font-size: min(12px, 3.3cqw); white-space: nowrap; }
.history-calendar th:first-child { width: var(--calendar-date-width); font-size: 10px; letter-spacing: .1em; }
/* Reserve the sticky heading, then fit exactly six dates in the remaining height. */
.history-calendar tbody tr { height: var(--calendar-row-height); }
.history-calendar td { height: var(--calendar-row-height); padding: 0; text-align: center; border-bottom: 1px solid #24395a70; }
.history-calendar td + td { border-left: 1px solid #24395a47; }
.history-calendar tr:nth-child(even) td { background: #0f214039; }
.history-calendar .is-today td { background: #11477738; border-bottom-color: #388eb59c; }
.history-calendar .is-future { opacity: .35; }
.history-calendar-date { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 0; height: calc(var(--calendar-row-height) - 1px); width: 100%; padding: 0; border: 0; line-height: 1; background: transparent; }
.history-calendar-date strong { font-size: min(15px, calc(var(--calendar-row-height) * .65)); font-weight: 600; color: #d9e9ff; }
.history-calendar-date small { font-size: 9px; color: #8ba0c1; letter-spacing: .05em; }
.is-today .history-calendar-date strong { color: #77e8ff; }
.history-calendar-date:hover:enabled { background: #23548765; }
.history-calendar-date:disabled { cursor: default; }
.history-calendar-hint { flex: 0 0 var(--calendar-hint-height); display: flex; flex-wrap: wrap; align-content: center; gap: 3px 5px; justify-content: space-between; margin: 0; padding: 4px 12px; background: #07132b; border-top: 1px solid #314a733d; color: #93afd3; font-size: 10px; }
.history-calendar-hint span { color: #78869f; }
.history-empty { padding: 40px 22px; text-align: center; }
.history-empty svg { width: 32px; height: 32px; color: #668bba; margin-bottom: 12px; }
.history-empty h3 { margin: 0 0 10px; font-size: 17px; color: #d7e7ff; font-weight: 500; }
.history-empty p { margin: 0; color: #849dbe; font-size: 13px; line-height: 1.7; }
.history-footer { position: relative; flex: 0 0 clamp(22px, 4.5cqh, 54px); margin: -7px -20px -8px; overflow: hidden; pointer-events: none; }
@container (max-height: 340px) { .history-calendar-date small { display: none; } }
@container app (max-width: 360px) { .icon-history { right: 12px; } .history-page { padding-left: 12px; padding-right: 12px; gap: 9px; } .history-panel { --calendar-date-width: 44px; } .history-toolbar { padding-left: 10px; padding-right: 10px; } .history-tabs button { font-size: 12px; gap: 7px; } }
@container app (max-width: 280px) { .history-tabs button { flex-direction: column; gap: 2px; padding: 4px; } }
@media (max-height: 650px) { .history-page { gap: 8px; } .history-eyebrow { display: none; } .history-heading h2 { font-size: 22px; } .history-footer { flex-basis: 18px; } }
@media (max-height: 450px) {
  .history-footer, .history-heading { display: none; }
  .history-panel { --calendar-toolbar-height: 34px; --calendar-hint-height: 30px; --calendar-header-height: 30px; }
  .history-calendar-hint { padding: 3px 8px; font-size: 9px; }
}
