:root {
  --brand: #4a1520;
  --brand-deep: #2a0006;
  --paper: #eeeeee;
  --paper-2: #f7f5f3;
  --ink: #1a1214;
  --muted: #5c4f52;
  --line: #d4cdc8;
  --session: #2e86c1;
  --deadline: #f0b429;
  --hearing: #e74c3c;
  --vacation: #27ae60;
  --text-on-color: #ffffff;
  --text-on-yellow: #14110a;
  --today: rgba(74, 21, 32, 0.08);
  --today-strong: var(--brand);
  --banner: #9b1c2c;
  --ring: var(--brand);
  --cols: 14;
  --lanes: 1;
  --space: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  font-size: clamp(15px, 0.65vw + 12px, 18px);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  --col-min: 0px;
}

.board-pane {
  min-width: 100%;
  width: max(100%, calc(var(--cols) * var(--col-min)));
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.board.is-loading .board-pane {
  opacity: 0.55;
}

.board-status {
  display: none;
  margin: auto;
  padding: 1rem;
  color: var(--muted);
  font-weight: 650;
}

.board.is-loading:not(.has-events) .board-status {
  display: block;
}

.banner {
  flex: 0 0 auto;
  background: var(--banner);
  color: var(--text-on-color);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 0.7rem 1rem;
}

.banner[hidden] {
  display: none !important;
}

.overflow-hint {
  position: fixed;
  right: 0.7rem;
  bottom: 0.6rem;
  z-index: 5;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 10px rgba(42, 0, 6, 0.25);
  font-size: 0.72rem;
  font-weight: 750;
  pointer-events: none;
}

.overflow-hint[hidden] {
  display: none;
}

.top {
  flex: 0 0 auto;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 3px 0 var(--brand);
  padding: 0.65rem 1rem 0.55rem;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.logo {
  display: block;
  height: 56px;
  width: 56px;
  flex: 0 0 auto;
  background: #eeeeee;
  border-radius: 50%;
  border: 1px solid var(--line);
  object-fit: cover;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.week-nav button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--brand);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.week-nav button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.week-nav button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.identity-text {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.identity-text h1 {
  margin: 0.05rem 0 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.clock {
  font-size: 1.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--brand-deep);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink);
}

.badge[hidden] {
  display: none !important;
}

.badge.source-nexus {
  border-color: var(--brand);
  color: var(--brand);
}

.badge.source-fixture {
  border-color: var(--deadline);
  color: var(--text-on-yellow);
}

.last-refresh {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.last-refresh[hidden] {
  display: none !important;
}

.refresh-btn {
  appearance: none;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  min-width: 44px;
  padding: 0.45rem 0.95rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}

.refresh-btn:hover {
  background: var(--brand-deep);
}

.refresh-btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.refresh-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.35rem;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

.legend-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 2px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.swatch.session {
  background: var(--session);
}

.swatch.deadline {
  background: var(--deadline);
}

.swatch.hearing {
  background: var(--hearing);
}

.swatch.vacation {
  background: var(--vacation);
}

body.kiosk .chrome {
  display: none !important;
}

body.kiosk .top-row {
  justify-content: space-between;
}

.headers,
.spans,
.stacks {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}

.headers {
  flex: 0 0 auto;
  background: #f3efec;
  border-bottom: 1px solid var(--line);
}

.day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  padding: 0.4rem 0.15rem 0.45rem;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.day-head:last-child,
.day-stack:last-child,
.col-bg:last-child {
  border-right: none;
}

.weekday {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.day-number {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hoje {
  margin-top: 0.12rem;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--brand);
}

.day-head.is-today,
.col-bg.is-today,
.day-stack.is-today {
  background: var(--today);
}

.day-head.is-today {
  box-shadow: inset 0 -3px 0 var(--today-strong);
}

.day-head.is-today .day-number {
  color: var(--brand);
}

.day-head.is-weekend .weekday,
.day-head.is-weekend .day-number {
  opacity: 0.7;
}

.spans {
  position: relative;
  flex: 0 0 auto;
  grid-template-rows: repeat(var(--lanes), minmax(2.2rem, auto));
  gap: 0.3rem 0.3rem;
  padding: 0.4rem 0.28rem;
  max-height: 28vh;
  overflow: auto;
  background: #faf8f6;
  border-bottom: 1px solid var(--line);
}

.col-bg {
  grid-row: 1 / span var(--lanes);
  border-right: 1px solid var(--line);
  z-index: 0;
}

.span-bar {
  z-index: 1;
  display: block;
  min-width: 0;
  padding: 0.22rem 0.5rem;
  border-radius: 3px;
  font-weight: 700;
  overflow: hidden;
}

.span-content {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: max-content;
  max-width: min(100%, calc(100vw - 2rem));
  will-change: transform;
}

.event-status {
  flex: 0 0 auto;
  padding: 0.08rem 0.3rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.span-bar.session {
  background: var(--session);
  color: var(--text-on-color);
}

.span-bar.vacation {
  background: var(--vacation);
  color: var(--text-on-color);
}

.kind {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0.92;
}

.span-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.card .event-status {
  margin-left: auto;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.span-bar .assignee,
.card .assignee {
  flex: 0 0 auto;
  margin-left: 0;
  font-size: 0.78em;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.35rem;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.16);
}

.stacks {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  align-items: stretch;
  background: var(--paper);
}

.day-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem 0.28rem 0.65rem;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.38rem 0.45rem;
  border-radius: 3px;
  min-width: 0;
}

.card.deadline {
  background: var(--deadline);
  color: var(--text-on-yellow);
}

.card.hearing {
  background: var(--hearing);
  color: var(--text-on-color);
}

.card.deadline-today {
  box-shadow: inset 4px 0 0 var(--brand);
}

.card-flag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

@media (max-width: 1799px) {
  .board {
    --col-min: 152px;
  }
}

@media (max-width: 1100px) {
  .top-row {
    flex-wrap: wrap;
  }

  .top-meta {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .last-refresh {
    display: none;
  }
}

@media (max-width: 720px) {
  .logo {
    height: 44px;
    width: 44px;
  }

  .identity-text h1 {
    font-size: 1.05rem;
  }

  .clock {
    font-size: 1.2rem;
  }

  .legend {
    font-size: 0.78rem;
    gap: 0.45rem 0.85rem;
  }

  .day-number {
    font-size: 1.15rem;
  }
}

@media (max-height: 700px) {
  .logo {
    height: 44px;
    width: 44px;
  }

  .identity-text h1 {
    font-size: 1.1rem;
  }

  .clock {
    font-size: 1.3rem;
  }

  .day-number {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .refresh-btn {
    transition: none;
  }
}
