:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --surface-2: #f4f3f0;
  --line: #e7e5e0;
  --line-strong: #d6d3cc;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #85837d;
  --commit: #2a78d6;
  --commit-soft: #cde2fb;
  --first: #eb6834;
  --focus: #2a78d6;
  --weekend: rgba(0, 0, 0, 0.022);
  --hover-col: rgba(42, 120, 214, 0.07);
  --shadow: 0 8px 28px rgba(20, 20, 18, 0.12), 0 1px 3px rgba(20, 20, 18, 0.08);

  --label-w: 168px;
  --row-h: 36px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #2c2c2a;
    --line-strong: #3a3a37;
    --ink: #f5f4f0;
    --ink-2: #c3c2b7;
    --ink-3: #8a8980;
    --commit: #3987e5;
    --commit-soft: #1d3656;
    --first: #d95926;
    --focus: #6da7ec;
    --weekend: rgba(255, 255, 255, 0.025);
    --hover-col: rgba(57, 135, 229, 0.12);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413;
  --surface: #1a1a19;
  --surface-2: #232321;
  --line: #2c2c2a;
  --line-strong: #3a3a37;
  --ink: #f5f4f0;
  --ink-2: #c3c2b7;
  --ink-3: #8a8980;
  --commit: #3987e5;
  --commit-soft: #1d3656;
  --first: #d95926;
  --focus: #6da7ec;
  --weekend: rgba(255, 255, 255, 0.025);
  --hover-col: rgba(57, 135, 229, 0.12);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.page { max-width: 1180px; margin: 0 auto; padding: 72px 32px 48px; }

/* Hero */
.hero { margin-bottom: 40px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero h1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; font-weight: 650; }
.tagline { font-size: 18px; color: var(--ink-2); margin: 12px 0 18px; max-width: 40em; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: 14px; color: var(--ink-2); background: var(--surface);
}
.links a:hover { color: var(--ink); border-color: var(--line-strong); }
.theme-toggle {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 48px; }
.stat { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.stat-label { font-size: 13px; color: var(--ink-3); }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12.5px; color: var(--ink-3); }

/* Section heads */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
h2 { font-size: 20px; margin: 0; letter-spacing: -0.01em; font-weight: 620; }
.sub { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 4px 12px; border-radius: 7px;
  font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Legend */
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.key { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.key-pushed { background: var(--commit); }
.key-local { background: var(--commit-soft); box-shadow: inset 0 0 0 1.5px var(--commit); }
.key-first { background: var(--first); }
.legend-size { gap: 4px !important; }
.key-size { display: inline-block; border-radius: 50%; background: var(--ink-3); opacity: .55; }
.key-size.s1 { width: 5px; height: 5px; }
.key-size.s2 { width: 8px; height: 8px; }
.key-size.s3 { width: 12px; height: 12px; margin-right: 3px; }

/* Grid */
.grid-wrap {
  position: relative; overflow-x: auto; overscroll-behavior-x: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  scrollbar-width: thin;
}
.grid { position: relative; min-width: 100%; }
.g-row { display: flex; height: var(--row-h); position: relative; }
.g-label {
  position: sticky; left: 0; z-index: 3; flex: 0 0 var(--label-w); width: var(--label-w);
  display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px;
  background: var(--surface); border-right: 1px solid var(--line);
  font-size: 14px; white-space: nowrap; overflow: hidden;
}
.linkish { all: unset; cursor: pointer; }
.linkish:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.g-label button {
  all: unset; cursor: pointer; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.g-label button:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.g-label button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.g-label .lock { color: var(--ink-3); flex: none; display: inline-flex; }
.g-track { position: relative; flex: none; height: 100%; }
.g-row + .g-row .g-track::before { content: ""; position: absolute; left: 0; right: 0; top: 0; border-top: 1px solid var(--line); opacity: .6; }
.g-row.is-hover .g-label { color: var(--ink); font-weight: 560; }

.g-axis { height: 44px; }
.g-axis .g-label { font-size: 12px; color: var(--ink-3); align-items: flex-end; padding-bottom: 8px; }
.g-total { height: 44px; border-bottom: 1px solid var(--line); }
.g-total .g-label { font-size: 12px; color: var(--ink-3); }

.bg-col { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.bg-col.weekend { background: var(--weekend); }
.bg-col.today { border-left: 1px dashed var(--first); opacity: .7; }
.hover-col { position: absolute; top: 0; bottom: 0; background: var(--hover-col); pointer-events: none; z-index: 1; display: none; }

.tick { position: absolute; bottom: 8px; font: 11px/1 var(--mono); color: var(--ink-3); transform: translateX(-50%); white-space: nowrap; }
.month { position: absolute; top: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; padding-left: 4px; border-left: 1px solid var(--line-strong); line-height: 14px; }

.bar { position: absolute; bottom: 6px; background: var(--ink-3); opacity: .45; border-radius: 2px 2px 0 0; pointer-events: none; }
.bar.is-hot { opacity: .8; }

.dot {
  position: absolute; top: 50%; padding: 0; border: 0; cursor: pointer; z-index: 2;
  transform: translate(-50%, -50%); background: transparent;
  display: grid; place-items: center;
}
.dot i {
  display: block; border-radius: 50%;
  background: var(--commit);
  box-shadow: 0 0 0 2px var(--surface);
  transition: transform .12s ease;
}
.dot.local i { background: var(--commit-soft); box-shadow: inset 0 0 0 1.5px var(--commit), 0 0 0 2px var(--surface); }
.dot.mixed i { background: conic-gradient(var(--commit) 0 var(--pp), var(--commit-soft) 0); box-shadow: inset 0 0 0 1.5px var(--commit), 0 0 0 2px var(--surface); }
.dot.first i { background: var(--first); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--first) 35%, transparent); }
.dot.first.local i { background: color-mix(in srgb, var(--first) 30%, var(--surface)); box-shadow: inset 0 0 0 1.5px var(--first), 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--first) 30%, transparent); }
.dot:hover i, .dot:focus-visible i { transform: scale(1.18); }
.dot.is-selected i { outline: 2px solid var(--ink); outline-offset: 2px; }
.dot:focus-visible { outline: none; }
.dot:focus-visible i { outline: 2px solid var(--focus); outline-offset: 2px; }
.offleft {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  font: 11px/1 var(--mono); color: var(--ink-3); white-space: nowrap; pointer-events: none;
}
.flag {
  position: absolute; top: 1px; transform: translateX(-50%);
  font: 600 9.5px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-2); pointer-events: none; z-index: 2; white-space: nowrap;
}

/* Tooltip */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--bg); border-radius: 8px; padding: 7px 10px;
  font-size: 12.5px; line-height: 1.4; box-shadow: var(--shadow); max-width: 280px;
}
.tip b { font-weight: 600; }
.tip .muted { opacity: .7; }

/* Detail panel */
.detail { margin-top: 14px; }
.detail:empty { display: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-title { font-size: 16px; font-weight: 600; margin: 0; }
.panel-title .when { color: var(--ink-3); font-weight: 450; margin-left: 6px; }
.panel-meta { font-size: 13px; color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.panel-close { border: 0; background: var(--surface-2); border-radius: 999px; width: 26px; height: 26px; cursor: pointer; color: var(--ink-2); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.pill.first { background: color-mix(in srgb, var(--first) 16%, var(--surface)); color: var(--ink); }

.commits { list-style: none; margin: 0; padding: 0; }
.commits li { display: grid; grid-template-columns: 58px 12px 1fr auto; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.commits li:first-child { border-top: 0; }
.commits time { font: 12.5px var(--mono); color: var(--ink-3); }
.commits .mk { width: 8px; height: 8px; border-radius: 50%; background: var(--commit); align-self: center; }
.commits .mk.local { background: var(--commit-soft); box-shadow: inset 0 0 0 1.5px var(--commit); }
.commits .mk.first { background: var(--first); }
.commits .msg { min-width: 0; overflow-wrap: anywhere; }
.commits .msg a { text-decoration: none; }
.commits .msg a:hover { text-decoration: underline; }
.commits .delta { font: 12px var(--mono); color: var(--ink-3); white-space: nowrap; }
.commits .delta .add { color: #0ca30c; }
.commits .delta .del { color: #d03b3b; }
.day-sep { font-size: 12px; color: var(--ink-3); padding: 12px 0 2px !important; border-top: 0 !important; display: block !important; font-weight: 600; }
.private-note { display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-size: 14px; padding: 4px 0; }
.bars-mini { display: flex; gap: 3px; align-items: flex-end; height: 24px; }
.bars-mini span { width: 6px; border-radius: 2px 2px 0 0; background: var(--commit); }
.bars-mini span.local { background: var(--commit-soft); box-shadow: inset 0 0 0 1px var(--commit); }

.proj-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 6px 0 14px; }
.proj-facts div { font-size: 13px; color: var(--ink-3); }
.proj-facts b { display: block; font-size: 15px; color: var(--ink); font-weight: 550; }
.proj-first { font-size: 14px; color: var(--ink-2); border-left: 3px solid var(--first); padding: 4px 0 4px 12px; margin-bottom: 4px; }

/* Project cards */
.projects { margin-top: 56px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card p { margin: 0; color: var(--ink-2); font-size: 14px; flex: 1; }
.card-meta { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); align-items: center; }
.card-links { display: flex; gap: 12px; font-size: 13px; }
.status { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.status.active::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #0ca30c; margin-right: 5px; vertical-align: 1px; }
.spark { display: block; width: 100%; height: 22px; }

.foot { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  :root { --label-w: 112px; --row-h: 32px; }
  .page { padding: 40px 16px 32px; }
  .hero h1 { font-size: 32px; }
  .tagline { font-size: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-value { font-size: 22px; }
  .g-label { padding: 0 8px 0 12px; font-size: 13px; }
  .commits li { grid-template-columns: 46px 10px 1fr; }
  .commits .delta { grid-column: 3; }
  .panel { padding: 14px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
