:root {
  --red: #c5050c;            /* UW Badger Red — accent */
  --ink: #1a1a1a;
  --muted: #5b6066;
  --hint: #8a9099;
  --line: #e6e8eb;
  --line-strong: #d3d7dc;
  --surface: #ffffff;
  --page: #f3f4f6;
  --today: #fbfaf7;

  --busy-bg: #e4eefb;
  --busy-br: #bcd6f5;
  --busy-tx: #16467f;

  --ooo-bg: #fdeccd;
  --ooo-br: #f4d79a;
  --ooo-tx: #8a5300;

  --btn-bg: #ffffff;
  --btn-hover: #f6f7f9;
  --btn-hover-br: #c2c7cd;
  --overlay-bg: rgba(255, 255, 255, .78);

  --gutter: 54px;
  --hour: 46px;
  --hours: 9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eaed;
    --muted: #9aa0a6;
    --hint: #7c828a;
    --line: #2a2d31;
    --line-strong: #3a3e44;
    --surface: #1b1d1f;
    --page: #121315;
    --today: #221f17;

    --busy-bg: #16314f;
    --busy-br: #28507f;
    --busy-tx: #bcd6f5;

    --ooo-bg: #3e2f12;
    --ooo-br: #6b531f;
    --ooo-tx: #f4d79a;

    --btn-bg: #26292c;
    --btn-hover: #2f3236;
    --btn-hover-br: #4a4e54;
    --overlay-bg: rgba(18, 19, 21, .80);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.card {
  max-width: 920px;
  margin: 32px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
}

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.id { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 10px; display: block; }
.name { font-size: 20px; font-weight: 600; margin: 0; line-height: 1.1; }
.sub { font-size: 13px; color: var(--muted); margin: 3px 0 0; }

.ctrls { display: flex; align-items: center; gap: 8px; }
.iconbtn, .btn {
  height: 34px;
  border: 1px solid var(--line-strong);
  background: var(--btn-bg);
  border-radius: 9px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  transition: background .12s, border-color .12s;
}
.iconbtn { width: 34px; font-size: 20px; }
.btn { padding: 0 14px; font-weight: 500; }
.iconbtn:hover, .btn:hover { background: var(--btn-hover); border-color: var(--btn-hover-br); }

.legend { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 13px; height: 13px; border-radius: 4px; border: 1px solid; }
.sw.busy { background: var(--busy-bg); border-color: var(--busy-br); }
.sw.ooo { background: var(--ooo-bg); border-color: var(--ooo-br); }
.sw.free { background: var(--surface); border-color: var(--line-strong); }
.range { font-weight: 500; color: var(--ink); }
.upd { margin-left: auto; color: var(--hint); display: inline-flex; align-items: center; gap: 6px; }
.upd::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #37b24d; }
.upd.loading::before { background: var(--hint); }
.upd.err { color: var(--red); }
.upd.err::before { background: var(--red); }

.week { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }

.head { display: grid; grid-template-columns: var(--gutter) repeat(5, 1fr); background: var(--surface); }
.corner { border-bottom: 1px solid var(--line); }
.dh { padding: 8px 0; text-align: center; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dh small { display: block; font-size: 11px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.dh b { font-size: 16px; font-weight: 600; }
.dh.today { background: var(--today); }
.dh.today .num {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%;
  background: var(--red); color: #fff; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; margin-top: 2px;
}

.body-wrap { position: relative; }
.body { display: grid; grid-template-columns: var(--gutter) repeat(5, 1fr); }
.gutter { position: relative; height: calc(var(--hour) * var(--hours)); }
.gutter span { position: absolute; right: 8px; font-size: 11px; color: var(--hint); transform: translateY(-7px); }
.col { position: relative; height: calc(var(--hour) * var(--hours)); border-left: 1px solid var(--line); }
.col.today { background: var(--today); }
.hl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }

.ev {
  position: absolute; left: 3px; right: 3px;
  border-radius: 7px; padding: 3px 7px; overflow: hidden;
  font-size: 11.5px; line-height: 1.25; z-index: 2; border: 1px solid;
}
.ev b { font-weight: 600; display: block; }
.ev span { display: block; opacity: .78; }
.ev.busy { background: var(--busy-bg); border-color: var(--busy-br); color: var(--busy-tx); }
.ev.ooo { background: var(--ooo-bg); border-color: var(--ooo-br); color: var(--ooo-tx); }
.ev.allday { z-index: 1; }

.now { position: absolute; left: var(--gutter); right: 0; height: 0; border-top: 2px solid var(--red); z-index: 5; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -5px; top: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; background: var(--overlay-bg); color: var(--muted);
  font-size: 13px; font-weight: 500;
}
.overlay[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line-strong); border-top-color: var(--red);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .card { margin: 0; border-radius: 0; border-left: 0; border-right: 0; padding: 14px; }
  .sub { display: none; }
}
