:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #172026;
  --muted: #62707c;
  --line: #d9dee3;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --accent: #0b6b57;
  --accent-2: #9b3d2e;
  --focus: #1c5fd7;
  --shadow: 0 18px 40px rgba(23, 32, 38, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
}

#statusLine {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 10px;
}

button,
select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

button {
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: #aeb8c2;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.stat {
  background: var(--surface);
  padding: 14px 28px;
}

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 134px);
}

.rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 20px;
  overflow: auto;
  max-height: calc(100vh - 134px);
}

.rail h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 0;
}

.run,
.draft {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface);
}

.run strong,
.draft strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.run p,
.draft p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.draft p {
  max-height: 104px;
  overflow: auto;
}

.board {
  padding: 20px 24px 32px;
  min-width: 0;
}

.monthNav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.monthNav button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #e9f4f0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.event {
  display: grid;
  grid-template-rows: auto auto minmax(74px, 1fr) auto;
  min-height: 190px;
  max-height: 238px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.event:hover {
  border-color: #9ba8b3;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(23, 32, 38, 0.08);
}

.event:focus-visible {
  outline: 3px solid rgba(28, 95, 215, 0.25);
  border-color: var(--focus);
}

.event .date {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.event h3 {
  font-size: 16px;
  line-height: 1.24;
  margin-bottom: 10px;
}

.event .summary {
  color: #394751;
  font-size: 13px;
  line-height: 1.38;
  overflow: auto;
  padding-right: 4px;
}

.pillRow {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.pill.primary {
  background: #e9f4f0;
  color: var(--accent);
}

.pill.warn {
  background: #f8eee9;
  color: var(--accent-2);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 32, 38, 0.38);
  padding: 28px;
  z-index: 10;
}

.detail {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 38px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.detailHead {
  padding: 24px 68px 18px 24px;
  border-bottom: 1px solid var(--line);
}

.detailHead span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.detailHead h2 {
  font-size: 24px;
  line-height: 1.15;
}

.detailBody {
  overflow: auto;
  padding: 22px 24px 28px;
  display: grid;
  gap: 18px;
}

.detailBody h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.detailBody p,
.detailBody pre {
  font-size: 14px;
  line-height: 1.5;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 280px;
  overflow: auto;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.meta p {
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .rail {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .topbar,
  .board,
  .rail {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
