:root {
  --workspace-bg: #e8f1fe;
  --calendar-ink: #14253d;
  --calendar-subtitle: #455a72;
  --calendar-primary: #0958b5;
  --calendar-accent: #79a8dc;
  --calendar-selected: #dcebff;
  --calendar-selected-ink: #0a4d9f;
  --calendar-head: #d8e7fe;
  --calendar-subtle: #f7f9fc;
  --calendar-gridline: #e5ecf5;
  --heat-color: #1365bc;
  --heat-zero: #edf4fc;
  --heat-polar: #fff;
  --card-shadow: 0 4px 15px #2438560a;
  --hero-bg: linear-gradient(109deg, #0c48ae 8%, #1659c7 47%, #102c69 100%);
  --hero-ink: #fff;
  --hero-accent: #c7edff;
  --hero-shadow: 0 11px 25px #113e9630;
  --calendar-border: #cbdcf1;
  --calendar-action-bg: #114fbb;
  --calendar-action-hover-brightness: .9;
}

:root[data-calendar-theme="dark"] {
  --workspace-bg: #09152e;
  --calendar-surface: #112440;
  --calendar-modal: #0a1932;
  --calendar-ink: #eff6fd;
  --calendar-subtitle: #bbcde0;
  --calendar-border: #294770;
  --calendar-control-border: #3b5c88;
  --calendar-primary: #82c0ff;
  --calendar-accent: #82b9ed;
  --calendar-selected: #274f83;
  --calendar-selected-ink: #dbeeff;
  --calendar-head: #1a3762;
  --calendar-subtle: #142946;
  --calendar-muted-surface: #182e43;
  --calendar-gridline: #263d5e;
  --calendar-hover: #1c3a62;
  --heat-color: #63b4ff;
  --heat-zero: #19334e;
  --heat-polar: #071828;
  --card-shadow: 0 4px 15px #030a1326;
  --hero-bg: linear-gradient(106deg, #123474 4%, #164894 51%, #082346 100%);
  --hero-ink: #f5f8fd;
  --hero-accent: #a9e6ff;
  --hero-shadow: 0 9px 24px #0003;
  --timeline-tint-base: #203451;
  --calendar-action-bg: #175fc8;
  --calendar-action-hover-brightness: 1.14;
}

.calendar-site { min-height: 100vh; background: var(--workspace-bg); color: var(--calendar-ink); }
.calendar-shell { width: calc(100% - 56px); margin-inline: auto; }
.dircom-header { position: relative; z-index: 10; padding-top: 14px; }
.dircom-header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.dircom-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-inline-start: auto;
}

.dircom-toolbar .calendar-button {
  min-height: 44px;
  padding: 8px 17px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  box-shadow: 0 4px 10px #0b2e6624;
}
.dircom-toolbar .dircom-export {
  border-color: #0a55bb;
  background: linear-gradient(115deg, #1261cf, #0848ab);
  color: #fff;
}
.dircom-toolbar .calendar-toggle {
  border-color: #315681;
  background: #16345b;
  color: #fff;
}
.dircom-toolbar .calendar-button:hover { filter: brightness(1.13); }
.dircom-toolbar .calendar-button:focus-visible {
  outline: 2px solid var(--calendar-primary);
  outline-offset: 3px;
}
.dircom-toolbar .calendar-toggle-track {
  width: 34px;
  height: 19px;
  border-color: #7fa4d1;
  background: #41658d;
}
.dircom-toolbar .calendar-toggle[aria-checked="true"] .calendar-toggle-track {
  border-color: #4cb4ff;
  background: #087aca;
}
[data-calendar-theme="dark"] .dircom-toolbar .dircom-export {
  border-color: #81c7ff;
  background: linear-gradient(115deg, #9dd7ff, #65b6fa);
  color: #081e3e;
}
[data-calendar-theme="dark"] .dircom-toolbar .calendar-toggle[aria-checked="true"] {
  border-color: #b9d5f1;
  background: #eef6ff;
  color: #142e50;
}

.dircom-page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(18px, 4vw, 60px);
  min-height: 174px;
  margin: 0 0 8px;
  padding: clamp(19px, 2.35vw, 34px) clamp(22px, 3.25vw, 47px);
  border: 1px solid var(--calendar-border);
  border-radius: 23px;
  background: var(--hero-bg);
  box-shadow: var(--hero-shadow);
  color: var(--hero-ink);
}

.dircom-year {
  margin: 0 0 5px;
  color: var(--hero-accent);
  font-size: clamp(16px, 1.65vw, 24px);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.dircom-page-title h1 {
  margin: 0;
  font-size: clamp(31px, 4vw, 56px);
  font-weight: 800;
  letter-spacing: -.055em;
  line-height: 1.02;
  text-wrap: balance;
}

.dircom-deck { margin: 9px 0 0; font-size: clamp(13px, 1.18vw, 16px); line-height: 1.38; }
.dircom-project-total {
  flex: none;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 4px;
  border-radius: 9px;
  color: inherit;
  cursor: pointer;
}
.dircom-project-total strong {
  color: var(--hero-accent);
  font-size: clamp(57px, 7vw, 96px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.08em;
  line-height: .9;
}
.dircom-project-label { font-size: clamp(14px, 1.65vw, 23px); font-weight: 750; line-height: 1.2; }
.dircom-project-total:hover .dircom-project-label { text-decoration: underline; text-underline-offset: .15em; }
.dircom-project-total:focus-visible { outline: 2px solid var(--hero-accent); outline-offset: 3px; }

.dircom-navigation { min-width: 0; }
.dircom-view-switch { display: flex; flex-wrap: wrap; gap: 4px; }
.dircom-navigation .calendar-button { min-height: 35px; padding: 5px 11px; }
.dircom-view-switch .calendar-button { border-color: transparent; background: transparent; }
.dircom-view-switch .calendar-button[aria-pressed="true"],
.timeline-expand {
  border-color: var(--calendar-action-bg);
  background: var(--calendar-action-bg);
  color: #fff;
}
.dircom-view-switch .calendar-button[aria-pressed="true"]:hover,
.timeline-expand:hover {
  border-color: var(--calendar-action-bg);
  background: var(--calendar-action-bg);
  filter: brightness(var(--calendar-action-hover-brightness));
}
.dircom-view-switch .calendar-button:hover:not([aria-pressed="true"]) { background: var(--calendar-hover); }
.dircom-filter-dock {
  position: sticky;
  top: 0;
  z-index: 25;
  margin-top: 2px;
  padding-top: 6px;
}
.dircom-filter-dock .dircom-calendar-filters {
  position: relative;
  top: auto;
  padding: 9px 12px;
  border: 1px solid var(--calendar-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--calendar-head) 50%, var(--calendar-surface));
  backdrop-filter: blur(10px);
  box-shadow: var(--card-shadow);
}
.dircom-filter-dock .dircom-calendar-filters :is(.calendar-filter-fields, .global-choices) { max-width: none; }
.dircom-filter-dock .calendar-filter-summary, .dircom-filter-dock .calendar-filter-field input { border-radius: 8px; }
.dircom-filter-dock .calendar-toggle[aria-checked="true"] { color: var(--calendar-selected-ink); background: var(--calendar-selected); }
.dircom-filter-fab.calendar-button, .dircom-filter-dialog { display: none; }
.calendar-period-icon { display: none; }

.calendar-workspace { padding-block: 12px 23px; }
.calendar-workspace :is(.calendar-timeline, .calendar-lines, .calendar-heatmap) {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--calendar-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--calendar-surface) 94%, transparent);
  box-shadow: var(--card-shadow);
}
.calendar-workspace .calendar-section-heading { margin-bottom: 10px; }
.calendar-workspace .calendar-section-heading h2 { font-size: 20px; letter-spacing: -.025em; }
.calendar-workspace .calendar-section-heading p { font-size: 12px; }
.calendar-workspace .timeline-caption { margin: 0 0 9px; }

.timeline-viewport, .calendar-fullscreen .timeline-viewport { --rail-width: 0px; }
.calendar-workspace .calendar-timeline > .timeline-viewport { max-height: 440px; --project-width: clamp(218px, 22vw, 312px); --month-width: 58px; }
.timeline-viewport .timeline-header { grid-template-rows: 32px; }
.timeline-header > .timeline-column-title { grid-row: 1; align-items: center; padding-bottom: 0; }
.timeline-header .timeline-month { grid-row: 1; }
.timeline-group { border-bottom: 1px solid var(--calendar-border); }
.timeline-group::before { display: none; }
.timeline-group-title { top: 33px; width: 100%; padding: 0 14px; background: var(--institution-band); color: #fff; }
.timeline-brand { position: sticky; left: 14px; display: inline-flex; align-items: center; height: 55px; }
.timeline-brand img {
  display: block;
  height: 38px;
  width: auto;
  max-width: min(236px, calc(100cqw - 34px));
  object-fit: contain;
  object-position: left center;
  image-rendering: auto;
}
.timeline-project-name { background: color-mix(in srgb, var(--institution-band) 15%, var(--timeline-tint-base)); }
.calendar-workspace .timeline-project { min-height: 32px; }
.timeline-project:not(:hover, :focus-within) {
  background: color-mix(in srgb, var(--institution-band) 3%, var(--calendar-surface));
}
.timeline-project:nth-child(even):not(:hover, :focus-within) {
  background: color-mix(in srgb, var(--institution-band) 1.65%, var(--calendar-surface));
}
.timeline-bar { border-radius: 8px; }
.timeline-viewport:not(.timeline-colors-by-status) .timeline-bar {
  background: color-mix(in srgb, var(--institution-band) 29%, var(--timeline-tint-base));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--institution-band) 39%, var(--timeline-tint-base));
}

.calendar-analytics { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.calendar-analytics .calendar-section-heading h2 { font-size: clamp(20px, 1.85vw, 26px); }
.calendar-analytics .calendar-section-heading p { font-size: 13px; }
.calendar-workspace .institution-chart { height: clamp(345px, 34vw, 480px); padding: 0; border: 0; background: transparent; }
.heatmap-scroll { overflow-x: auto; }
.heatmap-table { width: 100%; min-width: 355px; border-collapse: separate; border-spacing: 4px; table-layout: fixed; font-size: 13px; }
.heatmap-table th { padding: 0 0 3px; color: var(--calendar-subtitle); font-weight: 650; white-space: nowrap; }
.heatmap-table th[scope="row"], .heatmap-table th[scope="col"]:first-child { text-align: left; padding-inline: 3px; }
.heatmap-table th[scope="col"] { font-size: 12px; }
.heatmap-table th[title] span { display: inline-block; padding: 3px 0; border-bottom: 2px solid var(--matrix-institution); }
.heatmap-table td { padding: 0; text-align: center; }
.heat-cell {
  display: block;
  width: 100%;
  min-height: 33px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--heat-color) var(--heat-level), var(--heat-zero));
  color: var(--calendar-ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
}
.heat-cell[data-contrast="true"] { color: var(--heat-polar); }
.heat-cell:disabled { color: var(--calendar-subtitle); cursor: default; }
.heat-cell:enabled:hover, .heat-cell:focus-visible { outline: 2px solid var(--calendar-primary); outline-offset: 1px; }
.heat-total { font-weight: 740; }
.heatmap-key { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-top: 8px; color: var(--calendar-subtitle); font-size: 10px; }
.heatmap-gradient { width: 66px; height: 5px; border-radius: 9px; background: linear-gradient(90deg, var(--heat-zero), var(--heat-color)); }

@media (max-width: 620px) {
  .calendar-shell { width: calc(100% - 26px); }
  .dircom-toolbar .calendar-button { padding-inline: 12px; }
  .dircom-page-title { flex-wrap: wrap; align-items: flex-start; min-height: 0; gap: 13px; padding: 17px; border-radius: 18px; }
  .dircom-page-title h1 { text-wrap: initial; }
  .dircom-project-total { display: flex; align-items: baseline; gap: 8px; padding: 2px; }
  .dircom-project-total strong { font-size: 47px; }
  .dircom-navigation .calendar-button { padding-inline: 7px; font-size: 11px; }
  .calendar-workspace .calendar-timeline > .timeline-viewport { --project-width: 143px; max-height: 390px; }
  .timeline-brand { height: 43px; }
  .timeline-brand img { height: 28px; }
  .calendar-workspace :is(.calendar-timeline, .calendar-lines, .calendar-heatmap) { padding: 12px; }
  .calendar-workspace .institution-chart { height: 290px; }
  .heatmap-table { border-spacing: 3px; font-size: 12px; }
  .heatmap-table th[scope="col"] { font-size: 10px; white-space: normal; overflow-wrap: anywhere; }
  .heat-cell { min-height: 30px; font-size: 12px; }
}

@media (max-width: 640px) {
  :root:has(.dircom-filter-dialog[open]) { overflow: hidden; }
  .dircom-filter-dock { position: static; margin-top: 0; padding-top: 0; }
  .dircom-filter-dock .dircom-calendar-filters { display: none; }
  .calendar-workspace { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }

  .dircom-filter-dock {
    --glass-highlight: #ffffff94;
    --glass-rim: #ffffffd9;
    --glass-shadow: 0 13px 35px #0b2d6340, inset 0 1px 1px #ffffffa0;
  }
  [data-calendar-theme="dark"] .dircom-filter-dock {
    --glass-highlight: #74afff36;
    --glass-rim: #a0c7fc6e;
    --glass-shadow: 0 13px 35px #030b19a3, inset 0 1px 1px #bbd8ff50;
  }

  .dircom-filter-dock .dircom-filter-fab.calendar-button {
    position: fixed;
    z-index: 25;
    inset-inline-end: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: inline-flex;
    min-height: 48px;
    padding-inline: 22px;
    border: 1px solid var(--glass-rim);
    border-radius: 28px;
    background: var(--calendar-head);
    background: linear-gradient(145deg, var(--glass-highlight), transparent 75%),
      color-mix(in srgb, var(--calendar-head) 74%, transparent);
    backdrop-filter: blur(20px) saturate(165%);
    box-shadow: var(--glass-shadow);
    color: var(--calendar-ink);
    font-size: 14px;
    font-weight: 750;
  }

  .dircom-filter-dock .dircom-filter-fab:hover {
    border-color: var(--calendar-accent);
  }

  .dircom-filter-dock .dircom-filter-fab:focus-visible,
  .dircom-filter-dialog .calendar-button:focus-visible {
    outline: 2px solid var(--calendar-primary);
    outline-offset: 2px;
  }

  .dircom-filter-dialog[open] {
    position: fixed;
    inset: auto 0 calc(12px + env(safe-area-inset-bottom, 0px));
    display: block;
    width: min(480px, calc(100% - 24px));
    max-width: none;
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom, 0px));
    margin: 0 auto;
    padding: 0;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--glass-rim);
    border-radius: 24px;
    background: var(--calendar-surface);
    background: linear-gradient(150deg, var(--glass-highlight), transparent 68%),
      color-mix(in srgb, var(--calendar-surface) 88%, transparent);
    backdrop-filter: blur(28px) saturate(160%);
    box-shadow: var(--glass-shadow);
    color: var(--calendar-ink);
  }

  .dircom-filter-dialog::backdrop { background: #06193865; }
  [data-calendar-theme="dark"] .dircom-filter-dialog::backdrop { background: #02071380; }

  .dircom-filter-sheet { padding: 0 16px 16px; }
  .dircom-filter-sheet-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 -16px 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--calendar-border);
    background: color-mix(in srgb, var(--calendar-surface) 92%, transparent);
    backdrop-filter: blur(16px);
  }
  .dircom-filter-sheet-header h2 { margin: 0; font-size: 18px; font-weight: 750; }
  .dircom-filter-dialog .calendar-filter-fields { margin-top: 0; row-gap: 9px; align-items: stretch; }
  .dircom-filter-dialog :is(.calendar-filter-field, .calendar-filter-picker) { grid-column: 1 / -1; }
  .dircom-filter-dialog :is(.calendar-filter-summary, .calendar-filter-field input, .global-choice select) { min-height: 44px; font-size: 16px; }
  .dircom-filter-dialog .calendar-button { min-height: 44px; }
  .dircom-filter-dialog .global-choices { grid-template-columns: minmax(0, 1fr); }
  .dircom-filter-dialog :is(.calendar-filter-options, .calendar-period-panel) {
    position: static;
    width: 100%;
    min-width: 0;
    max-height: none;
    margin-top: 4px;
  }
  .dircom-filter-dialog .calendar-filter-options input { min-height: auto; }
  .dircom-filter-dialog .calendar-filter-options label { min-height: 36px; white-space: normal; }
}

.timeline-expand-short { display: none; }

@media (max-width: 620px) {
  .dircom-header { padding-top: 10px; }
  .dircom-page-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "year total" "title title" "deck deck";
    align-items: center;
    gap: 5px 8px;
    padding: 12px 14px 14px;
    border-radius: 17px;
  }
  .dircom-page-title > div { display: contents; }
  .dircom-year { grid-area: year; margin: 0; font-size: 13px; }
  .dircom-page-title h1 { grid-area: title; font-size: clamp(23px, 6.8vw, 34px); }
  .dircom-deck { grid-area: deck; margin: 0; font-size: 12px; }
  .dircom-project-total {
    grid-area: total;
    gap: 5px;
    align-items: center;
    padding: 4px 7px;
    border: 1px solid #dceaff40;
    border-radius: 8px;
    background: #e4f2ff16;
  }
  .dircom-project-total strong { font-size: 22px; letter-spacing: -.04em; }
  .dircom-project-label { font-size: 10px; }
  .dircom-header-actions { gap: 6px; }
  .dircom-navigation { width: 100%; }
  .dircom-view-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--calendar-border);
    border-radius: 11px;
    background: var(--calendar-surface);
  }
  .dircom-navigation .calendar-button { min-height: 40px; padding: 2px 3px; text-align: center; }
  .dircom-toolbar { gap: 6px; }
  .dircom-toolbar .calendar-button { padding: 5px 10px; border-radius: 8px; font-size: 11px; }
  .calendar-workspace { padding-top: 8px; }
  .calendar-workspace .calendar-timeline { padding: 9px; }
  .calendar-timeline .timeline-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    align-items: center;
  }
  .calendar-workspace .timeline-heading h2 { font-size: 17px; }
  .calendar-workspace .timeline-heading p { font-size: 10px; }
  .timeline-expand-label { display: none; }
  .timeline-expand-short { display: inline; }
  .timeline-expand { min-height: 44px; padding-inline: 8px; font-size: 11px; }
  .calendar-workspace .calendar-timeline > .timeline-viewport {
    --project-width: clamp(118px, 34vw, 144px);
    --month-width: 48px;
  }
  .timeline-project-name { font-size: 11px; }
  .timeline-bar { padding-inline: 1px; font-size: 8px; }
  .dircom-filter-dock .dircom-filter-fab.calendar-button { min-height: 44px; padding-inline: 17px; font-size: 12px; }
}

@media (max-width: 620px) {
  .dircom-filter-dock .dircom-filter-fab.calendar-button {
    min-height: 50px;
    padding-inline: 24px;
    border-color: #a8d5ffc9;
    background: linear-gradient(158deg, #66aeff6b, #0c4fb12b 48%, #062d7866),
      color-mix(in srgb, #1058bd 94%, transparent);
    box-shadow: 0 8px 22px #063b8270, inset 0 1px 2px #e0f2ffa6;
    color: white;
    font-size: 14px;
  }

  [data-calendar-theme="dark"] .dircom-filter-dock .dircom-filter-fab.calendar-button {
    border-color: #c7e9ffbd;
    background: linear-gradient(157deg, #e4f6ffb5, #82c7ff47 57%, #4698df60),
      color-mix(in srgb, #86caff 94%, transparent);
    box-shadow: 0 8px 23px #03132eaa, inset 0 1px 2px #ffffffa8;
    color: #102c50;
  }
}

.timeline-colors-by-status .timeline-bar {
  color: #fff;
  box-shadow: inset 0 0 0 1px #101e4626;
}
.timeline-colors-by-status .timeline-bar:hover { box-shadow: inset 0 0 0 1px #ffffffb3; }
.calendar-status-legend li > span { width: 11px; height: 11px; border: 0; }

@media (max-width: 620px) {
  .dircom-page-title {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "year total" "title total" "deck total";
    gap: 5px 9px;
  }
  .dircom-project-total {
    display: grid;
    justify-items: center;
    min-width: 83px;
    border: 0;
    background: none;
    padding: 0;
    gap: 5px;
    text-align: center;
  }
  .dircom-project-total strong { font-size: clamp(40px, 12.5vw, 62px); line-height: 1; }
  .dircom-project-label { font-size: 10px; white-space: nowrap; }
  .dircom-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    width: 100%;
    margin: 0;
  }
  .dircom-toolbar .calendar-button { width: 100%; justify-content: center; }
  .calendar-status-legend { gap: 5px 8px; font-size: 10px; }
}
