:root {
  color-scheme: light;
  --background: 48 30% 96%;
  --foreground: 30 8% 10%;
  --card: 45 25% 93%;
  --muted: 45 22% 90%;
  --muted-foreground: 40 6% 39%;
  --accent: 217 84% 46%;
  --accent-foreground: 0 0% 98%;
  --border: 45 18% 85%;
  --night: 30 8% 10% / 0.16;
  --day: 30 8% 10% / 0.045;
  --work: 217 84% 46% / 0.26;
  --font-jb: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-space: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --meta: 260px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: 30 8% 8%;
    --foreground: 45 25% 90%;
    --card: 30 7% 11%;
    --muted: 30 6% 15%;
    --muted-foreground: 40 8% 62%;
    --accent: 217 90% 63%;
    --accent-foreground: 30 8% 8%;
    --border: 30 6% 20%;
    --night: 0 0% 0% / 0.45;
    --day: 45 25% 90% / 0.06;
    --work: 217 90% 63% / 0.3;
  }
}
*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: hsl(var(--background)); color: hsl(var(--foreground));
  font: 400 15.5px/1.55 var(--font-jb);
}
a { color: hsl(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 20px 48px; }
.page-transition { animation: page-enter 420ms cubic-bezier(0.22, 1, 0.36, 1) backwards; }
@keyframes page-enter { from { opacity: 0; transform: translateY(10px); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
@media (prefers-reduced-motion: reduce) { .page-transition { animation: none; } * { transition: none !important; } }

.top { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid hsl(var(--border)); }
.brand { color: inherit; font-weight: 600; font-size: 15.5px; }
.brand:hover { text-decoration: none; }
.glyph { color: hsl(var(--accent)); font-weight: 400; }
.tag { color: hsl(var(--muted-foreground)); font-size: 12.5px; }
.hero { padding: 36px 0 22px; }
.hero-headline { font-family: var(--font-space); font-size: clamp(2.1rem, 6vw, 4rem); line-height: 1.04; letter-spacing: -0.02em; font-weight: 700; margin: 0 0 12px; }
.lede { margin: 0; color: hsl(var(--muted-foreground)); font-size: 13.5px; max-width: 60ch; }
.section-heading { font-family: var(--font-space); font-size: clamp(1.35rem, 2.2vw, 1.7rem); letter-spacing: -0.01em; font-weight: 700; margin: 0 0 14px; }
.section-heading::before { content: "■ "; color: hsl(var(--accent)); font-weight: 400; }

button, input, select { font: inherit; font-size: 13.5px; color: inherit; }
button {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); padding: 7px 12px; cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}
button:hover { background: hsl(var(--muted)); border-color: hsl(var(--foreground) / 0.3); }
button.primary { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); border-color: hsl(var(--accent)); }
input, select { background: hsl(var(--background)); border: 1px solid hsl(var(--border)); padding: 7px 10px; }
:focus-visible { outline: 1px solid hsl(var(--accent)); outline-offset: 1px; }
kbd { font: inherit; font-size: 11px; border: 1px solid hsl(var(--border)); padding: 0 5px; margin-right: 3px; background: hsl(var(--card)); }

.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 320px; }
.search input { width: 100%; padding-right: 36px; }
.search .hint { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; color: hsl(var(--muted-foreground)); }
#results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 0; list-style: none; background: hsl(var(--background)); border: 1px solid hsl(var(--border)); max-height: 340px; overflow: auto; }
#results li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 22px; cursor: pointer; font-size: 13.5px; }
#results li .r2 { color: hsl(var(--muted-foreground)); font-size: 12.5px; white-space: nowrap; }
#results li[aria-selected="true"] { background: hsl(var(--muted)); }
#results li[aria-selected="true"]::before { content: "▸"; color: hsl(var(--accent)); position: absolute; left: 8px; }
#results li.empty { color: hsl(var(--muted-foreground)); cursor: default; }
.datebar { display: flex; gap: 6px; }
.datebar input { min-width: 150px; }

.board { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); user-select: none; -webkit-user-select: none; }
.row { display: grid; grid-template-columns: var(--meta) 1fr; border-bottom: 1px solid hsl(var(--border)); min-height: 74px; }
.row:last-child { border-bottom: 0; }
.row.home .name::after { content: " · home"; color: hsl(var(--accent)); font-weight: 400; font-size: 11px; }
.meta { padding: 9px 12px; border-right: 1px solid hsl(var(--border)); display: flex; flex-direction: column; gap: 2px; min-width: 0; position: relative; }
.name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 48px; }
.sub { color: hsl(var(--muted-foreground)); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.now small { font-size: 11px; color: hsl(var(--muted-foreground)); font-weight: 400; letter-spacing: 0; margin-left: 6px; }
.tools { position: absolute; right: 6px; top: 6px; display: flex; gap: 2px; }
.tools button { padding: 1px 6px; font-size: 11px; background: transparent; border-color: transparent; color: hsl(var(--muted-foreground)); }
.tools button:hover { border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.hours { display: flex; align-items: center; gap: 4px; font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.hours select { padding: 1px 2px; font-size: 11px; }

.strip { position: relative; cursor: crosshair; touch-action: pan-y; overflow: hidden; }
.cells { position: absolute; inset: 22px 0 0 0; display: flex; }
.cells i { flex: 1 1 0; display: block; background: hsl(var(--day)); }
.cells i.night { background: hsl(var(--night)); }
.cells i.work { background: hsl(var(--work)); }
.cells i.hr { box-shadow: inset 1px 0 0 hsl(var(--foreground) / 0.08); }
.cells i.mid { box-shadow: inset 2px 0 0 hsl(var(--foreground) / 0.5); }
.overlap-row .cells, .overlap-row .sel { top: 8px; }
.ticks { position: absolute; left: 0; right: 0; top: 0; height: 22px; font-size: 11px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.ticks span.mid { color: hsl(var(--foreground)); font-weight: 600; transform: none; padding-left: 3px; }
.ticks span.mid.end { transform: translateX(-100%); padding: 0 3px 0 0; }
.ticks span.first { transform: none; padding-left: 3px; }
.cursor { position: absolute; top: 0; bottom: 0; left: var(--cur, 0%); width: 2px; margin-left: -1px; background: hsl(var(--accent)); pointer-events: none; z-index: 3; }
.sel { position: absolute; top: 22px; bottom: 0; left: var(--sel-l, 0%); width: var(--sel-w, 0%); background: hsl(var(--accent) / 0.22); outline: 1px solid hsl(var(--accent)); outline-offset: -1px; pointer-events: none; z-index: 2; }
.board:not(.has-sel) .sel { display: none; }
.nowline { position: absolute; top: 22px; bottom: 0; width: 0; border-left: 1px dashed hsl(var(--foreground) / 0.55); pointer-events: none; z-index: 2; }
.overlap-row { min-height: 54px; }
#overlapCells i { background: hsl(var(--foreground) / 0.04); }
#overlapCells i[data-l] { background: hsl(var(--accent) / var(--a)); }
.empty-board { padding: 28px; color: hsl(var(--muted-foreground)); font-size: 13.5px; }

.keys { color: hsl(var(--muted-foreground)); font-size: 11px; margin: 10px 0 34px; line-height: 2; }
.plan { border-top: 1px solid hsl(var(--border)); padding-top: 26px; }
.planbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.planbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.planbar label input, .planbar label select { color: hsl(var(--foreground)); }
.note { font-size: 12.5px; color: hsl(var(--muted-foreground)); margin: 12px 0; min-height: 1.4em; }
.slot { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); font-size: 13.5px; }
.slot .line { display: grid; grid-template-columns: minmax(120px, 1.3fr) 1.4fr 1fr; gap: 12px; padding: 9px 12px; border-bottom: 1px solid hsl(var(--border)); }
.slot .line:last-child { border-bottom: 0; }
.slot .t { font-weight: 600; font-variant-numeric: tabular-nums; }
.slot .m { color: hsl(var(--muted-foreground)); font-size: 12.5px; }
.slot .warn { color: hsl(var(--muted-foreground)); }
.slot .ok::before { content: "✓ "; color: hsl(var(--accent)); }
.slot .empty { padding: 14px 12px; color: hsl(var(--muted-foreground)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.foot { margin-top: 48px; padding-top: 14px; border-top: 1px solid hsl(var(--border)); font-size: 11px; color: hsl(var(--muted-foreground)); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); opacity: 0; background: hsl(var(--foreground)); color: hsl(var(--background)); padding: 8px 14px; font-size: 12.5px; transition: opacity 180ms, transform 180ms; pointer-events: none; z-index: 50; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .wrap { padding: 14px 12px 40px; }
  .row { grid-template-columns: 1fr; }
  .meta { border-right: 0; border-bottom: 1px solid hsl(var(--border)); flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 10px; padding: 7px 10px; }
  .meta .name { padding-right: 0; }
  .tools { top: 4px; }
  .strip { min-height: 58px; }
  .ticks span.odd, .ticks span.nm { display: none; }
  .slot .line { grid-template-columns: 1fr; gap: 2px; }
  .overlap-row .meta { display: none; }
  .overlap-row .strip { min-height: 40px; }
}
