:root {
  --bg: #fff;
  --fg: #1b1d21;
  --muted: #6b7079;
  --line: #e6e7ea;
  --line-soft: #f1f2f4;
  --panel: #f7f7f8;
  --accent: #1f6feb;
  --free: #2e9d63;
  --free-bg: #dff3e7;
  --free-fg: #155c37;
  --danger: #c4322b;
  --hour: 32px;
  --navh: 72px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --fg: #e8e9eb;
    --muted: #979ba3;
    --line: #2c2f34;
    --line-soft: #212327;
    --panel: #1d1f23;
    --accent: #5b9bff;
    --free: #3fb878;
    --free-bg: #173828;
    --free-fg: #9be3bb;
    --danger: #ff6b63;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
a { color: var(--accent); }

.page { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; height: 40px;
  border: 1px solid transparent; border-radius: 8px;
  background: var(--fg); color: var(--bg);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
.button.big { height: 52px; width: 100%; font-size: 17px; }
.button.done { background: var(--free); color: #fff; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
button.link.danger:hover { color: var(--danger); }
input {
  font: inherit; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg);
}
.empty { color: var(--muted); }

/* Home */
.home { max-width: 520px; padding-top: 12vh; }
.home h1 { font-size: 32px; letter-spacing: -0.02em; }
.home .lead { font-size: 19px; margin: 8px 0 24px; }
.steps { padding-left: 20px; margin: 0 0 32px; color: var(--muted); }
.steps li { margin-bottom: 8px; }
.apple {
  display: inline-flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 22px; border-radius: 8px;
  background: #000; color: #fff; text-decoration: none; font-weight: 600; font-size: 17px;
}
@media (prefers-color-scheme: dark) { .apple { background: #fff; color: #000; } }
.apple svg { width: 17px; height: 20px; margin-top: -3px; }
.fine { color: var(--muted); font-size: 14px; margin-top: 16px; }

/* Admin */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 760px; margin: 0 auto; padding: 16px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.admin section { margin-bottom: 48px; }
.admin h2 { font-size: 20px; margin-bottom: 16px; }
.add { display: flex; gap: 8px; margin-bottom: 16px; }
.add input { flex: 1; min-width: 0; }
.add.title { align-items: center; margin-bottom: 40px; }
.add.title label { font-weight: 600; margin-right: 4px; }
.people { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.people li { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 14px; color: var(--free); }
.status.none { color: var(--muted); }
.copy { min-width: 108px; }

.weekhead { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.weekhead h2 { margin: 0; }
.tag { font-size: 13px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; vertical-align: middle; }
.weeknav { display: flex; gap: 4px; }
.weeknav a {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--fg); text-decoration: none; font-size: 20px;
}
.sched-day { padding: 16px 0; border-bottom: 1px solid var(--line); }
.sched-day h3 { font-size: 16px; margin-bottom: 4px; }
.sched-row { display: grid; grid-template-columns: 9rem 1fr; gap: 12px; align-items: center; min-height: 36px; }
.sched-name { font-size: 15px; font-weight: 500; overflow: hidden; }
.sched-name small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.sched-track {
  position: relative; height: 22px; border-radius: 4px; background: var(--panel);
  background-image: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px calc(100% / 4));
}
.sched-track .free { position: absolute; top: 0; bottom: 0; background: var(--free); border-radius: 4px; }
.axis { min-height: 20px; }
.axis-track { position: relative; height: 20px; font-size: 11px; color: var(--muted); }
.axis-track span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.axis-track span:first-child { transform: none; }
.axis-track span:last-child { transform: translateX(-100%); }
@media (max-width: 560px) {
  .sched-row { grid-template-columns: 5.5rem 1fr; gap: 8px; }
  .people li { gap: 10px; }
  .copy { min-width: 0; padding: 0 12px; }
}

/* Fill */
.fill-head { max-width: 760px; margin: 0 auto; padding: 24px 16px 8px; }
.fill-head h1 { font-size: 26px; }
.fill-head .eyebrow { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.fill-head p { margin: 8px 0 0; }
.daynav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px 4px;
}
.pills { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 728px; margin: 0 auto; }
.pills a {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 4px 0 6px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 12px; line-height: 1.2;
}
.pills b { font-size: 17px; color: var(--fg); font-weight: 600; }
.pills a.active { background: var(--fg); color: var(--bg); }
.pills a.active b { color: var(--bg); }
.pills a.has::after {
  content: ""; position: absolute; bottom: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--free);
}
.save { max-width: 728px; margin: 2px auto 0; text-align: center; font-size: 12px; color: var(--danger); }
.save:empty { display: none; }

.days { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.day { padding: 24px 0 16px; scroll-margin-top: var(--navh); border-bottom: 1px solid var(--line); }
.day h2 { font-size: 22px; display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.day h2 span { color: var(--muted); font-weight: 500; }
.grid { display: grid; grid-template-columns: 48px 1fr; padding: 10px 0; }
.hours { position: relative; font-size: 11px; color: var(--muted); }
.hours span { position: absolute; right: 8px; transform: translateY(-50%); white-space: nowrap; }
.track {
  position: relative;
  border: 1px solid var(--line); border-radius: 8px;
  background-color: var(--bg);
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hour), 100% calc(var(--hour) / 2);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: crosshair;
}
.track.arming { background-color: var(--panel); }
.block {
  position: absolute; left: 6px; right: 6px;
  background: var(--free-bg); border: 1.5px solid var(--free); border-radius: 6px;
  color: var(--free-fg); font-size: 13px; font-weight: 600;
}
.block .label { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); white-space: nowrap; pointer-events: none; }
.block.short .label { display: none; }
.block.dragging { box-shadow: 0 4px 14px rgba(0, 0, 0, .15); z-index: 2; }
.handle {
  position: absolute; left: 50%; width: 64px; height: 28px; margin-left: -32px;
  cursor: ns-resize; touch-action: none; z-index: 1;
}
.handle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 36px; height: 8px;
  transform: translate(-50%, -50%);
  background: var(--bg); border: 1.5px solid var(--free); border-radius: 99px;
}
.handle.top { top: -14px; }
.handle.bottom { bottom: -14px; }
.del {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: none; color: var(--free-fg);
  font-size: 20px; line-height: 1; cursor: pointer; touch-action: manipulation;
}
.fill-foot { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }

@media (min-width: 1000px) {
  :root { --hour: 28px; }
  .fill-head, .fill-foot { max-width: 1200px; }
  .pills, .daynav:has(.save:empty) { display: none; }
  .daynav { padding-top: 4px; }
  .days { max-width: 1200px; display: grid; grid-template-columns: 48px repeat(7, 1fr); }
  .day { border: 0; padding-top: 16px; }
  .day h2 { font-size: 16px; flex-wrap: wrap; gap: 4px; }
  .grid { grid-template-columns: 1fr; }
  .day:first-child { grid-column: span 2; }
  .day:first-child .grid { grid-template-columns: 48px 1fr; }
  .day:not(:first-child) .hours { display: none; }
  .day:not(:first-child) { padding-left: 6px; }
  .day:first-child h2 { padding-left: 48px; }
  .block .label { font-size: 12px; left: 6px; }
}
