:root {
  --bg: #f7f5f0;
  --panel: #ffffff;
  --fg: #1d2327;
  --muted: #5f6b73;
  --line: #e2ddd3;
  --accent: #0b6e8a;
  --warn: #9a5b00;
  --s1: #b8c2c8;
  --s2: #8fb3c2;
  --s3: #5e9bb3;
  --s4: #2f7f9c;
  --s5: #0b6e8a;
  --s6: #2e7d4f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171a;
    --panel: #1b2226;
    --fg: #e8ecee;
    --muted: #9aa7ae;
    --line: #2d373c;
    --accent: #5cc2e0;
    --warn: #e0a84a;
    --s1: #4a565c;
    --s2: #3f6a7b;
    --s3: #3f84a0;
    --s4: #4fa0bf;
    --s5: #5cc2e0;
    --s6: #6cc08e;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12171a;
  --panel: #1b2226;
  --fg: #e8ecee;
  --muted: #9aa7ae;
  --line: #2d373c;
  --accent: #5cc2e0;
  --warn: #e0a84a;
  --s1: #4a565c;
  --s2: #3f6a7b;
  --s3: #3f84a0;
  --s4: #4fa0bf;
  --s5: #5cc2e0;
  --s6: #6cc08e;
  color-scheme: dark;
}

.theme-toggle {
  position: absolute;
  top: 24px;
  right: 16px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  outline: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.6;
}

.wrap {
  position: relative;
  max-width: 1200px;
  margin-inline: auto;
  padding: 32px 16px 48px;
}

.hero {
  padding-right: 7rem;
}

.hero h1 {
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 3.25rem);
  margin: 0 0 8px;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.lede {
  color: var(--muted);
  margin: 0;
  max-width: 48rem;
}

h2 {
  font-size: 1.15rem;
  margin: 40px 0 4px;
}

.note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tile .lbl,
.tile .sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.tile b {
  font-family: "Noto Serif TC", "Songti TC", serif;
  font-weight: 500;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 28px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips button {
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
}

.chips button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

#q {
  font: inherit;
  font-size: 0.9rem;
  flex: 1 1 14rem;
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
}

.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(10rem, 1fr));
  align-items: start;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 8rem;
}

.col h3 {
  font-size: 0.85rem;
  margin: 0 0 8px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.col h3 span {
  color: var(--muted);
  font-weight: 400;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 4px solid var(--stage, var(--s1));
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.card:hover,
.card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.card .nm {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}

.card .meta {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.bar {
  display: block;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--stage, var(--accent));
}

.timeline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.trow {
  display: grid;
  grid-template-columns: minmax(8rem, 16rem) 1fr;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
  padding: 3px 0;
}

.trow .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.track {
  position: relative;
  height: 14px;
}

.track i {
  position: absolute;
  left: 0;
  top: 3px;
  height: 8px;
  border-radius: 4px;
  background: var(--stage, var(--s3));
}

.track em {
  position: absolute;
  top: -3px;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--muted);
  padding-left: 6px;
  font-variant-numeric: tabular-nums;
}

.axis {
  display: flex;
  justify-content: space-between;
  width: 88%;
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 4px;
}

dialog {
  max-width: min(36rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--fg);
  padding: 24px;
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

dialog h3 {
  margin: 4px 0 12px;
  font-size: 1.2rem;
}

dialog dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 0.85rem;
  margin: 0 0 12px;
}

dialog dt {
  color: var(--muted);
}

dialog dd {
  margin: 0;
}

.close {
  float: right;
  font-size: 1.4rem;
  line-height: 1;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
}

.risk {
  color: var(--warn);
  font-size: 0.9rem;
}

.src {
  font-size: 0.85rem;
  color: var(--muted);
}

a {
  color: var(--accent);
}

.foot {
  margin-top: 48px;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.empty {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 960px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow-x: visible;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding-top: 20px;
  }

  .theme-toggle {
    top: 16px;
  }

  /* The toggle sits beside the eyebrow and title, so the lede can use the full width. */
  .hero {
    padding-right: 0;
  }

  .tiles {
    gap: 8px;
    margin-top: 20px;
  }

  .tile {
    padding: 12px;
  }

  .tile b {
    font-size: 1.6rem;
  }

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

  .col {
    min-height: 0;
  }

  /* Stack name above its bar so long names stay readable. */
  .trow {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 6px 0;
  }

  .trow .nm {
    white-space: normal;
    line-height: 1.4;
  }

  .trow > span:empty {
    display: none;
  }

  /* 16px keeps iOS Safari from zooming in when the field gets focus. */
  #q {
    font-size: 1rem;
    flex-basis: 100%;
  }

  dialog {
    padding: 20px;
  }
}

/* Larger hit areas for touch screens. */
@media (pointer: coarse) {
  .chips {
    gap: 8px;
  }

  .chips button,
  .theme-toggle {
    min-height: 36px;
    padding-inline: 14px;
  }

  #q {
    min-height: 44px;
  }

  .trow .nm {
    min-height: 32px;
  }

  .close {
    min-width: 44px;
    min-height: 44px;
    margin: -12px -12px 0 0;
  }
}
