:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #15171a;
  --muted: #6b6f76;
  --faint: #9a9ea5;
  --line: #e7e4de;
  --chip: #efede8;
  --accent: #15171a;
  --accent-ink: #ffffff;
  --late: #c2410c;
  --ok: #15803d;
  --run: #2563eb;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 1px 1px rgba(20, 20, 20, .03);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --card: #181b20;
    --ink: #eceef1;
    --muted: #9097a1;
    --faint: #6b717b;
    --line: #262a31;
    --chip: #22262d;
    --accent: #eceef1;
    --accent-ink: #0f1115;
    --late: #fb923c;
    --ok: #4ade80;
    --run: #60a5fa;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --card: #181b20; --ink: #eceef1; --muted: #9097a1; --faint: #6b717b; --line: #262a31;
  --chip: #22262d; --accent: #eceef1; --accent-ink: #0f1115; --late: #fb923c; --ok: #4ade80; --run: #60a5fa;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

/* header */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 4px; }
.head h1 { font-size: 30px; line-height: 1.1; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.head .sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.head .tools { display: flex; gap: 8px; flex: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; padding: 0; box-shadow: var(--shadow);
}
.icon-btn svg { width: 20px; height: 20px; }
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--muted); padding: 6px 0; font-size: 15px; }

.summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.pill { background: var(--chip); color: var(--ink); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 500; }
.pill.late { color: var(--late); }

/* sections */
.sec { margin-top: 22px; }
.sec > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px;
  font-weight: 600; display: flex; justify-content: space-between; align-items: baseline;
}
.sec > h2 .n { font-weight: 500; }
.sub-h { font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.list { display: flex; flex-direction: column; gap: 8px; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 12px 12px 10px; display: grid; grid-template-columns: 34px 1fr auto; gap: 2px 8px; align-items: start;
}
.card.done .title { color: var(--faint); text-decoration: line-through; }
.card.compact { padding: 9px 12px 9px 10px; }
.check {
  width: 26px; height: 26px; margin: 1px 0 0 2px; border-radius: 50%; border: 2px solid var(--faint); background: none;
  display: grid; place-items: center; padding: 0;
}
.check svg { width: 14px; height: 14px; opacity: 0; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check.on svg { opacity: 1; }
.check.other { border-style: dashed; }
.body { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.card, .sheet, .info, .jn { overflow-wrap: anywhere; word-break: break-word; }
.next {
  font-size: 14px; color: var(--muted); margin-top: 4px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.next b { color: var(--ink); font-weight: 600; margin-right: 2px; }
.play {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  display: grid; place-items: center; padding: 0;
}
.play svg { width: 14px; height: 14px; margin-left: 2px; }
.play.on { background: var(--run); border-color: var(--run); color: #fff; }
.play.on svg { margin-left: 0; }
.paused { color: var(--muted); font-weight: 600; }
.linkbtn.muted { color: var(--muted); font-weight: 500; margin-top: 6px; }
h2.st { font-size: 22px; line-height: 1.25; margin: 8px 0 12px; letter-spacing: -.01em; }
dl.ctx { margin: 0 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 12px; }
dl.ctx dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-top: 10px; }
dl.ctx dd { margin: 2px 0 0; font-size: 15.5px; line-height: 1.4; }
details.more { margin: 4px 0 6px; }
details.more summary { color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px 0; }
details.more p { margin: 4px 0 0; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.linkbtn { display: block; margin: 14px auto 0; border: 0; background: none; color: var(--late); font-size: 14px; font-weight: 600; padding: 8px; }
.row1 { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; }
.pname { font-weight: 600; color: var(--ink); }
.due.late { color: var(--late); font-weight: 600; }
.title { font-size: 16px; line-height: 1.32; margin-top: 3px; overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.meta .who { color: var(--ink); }
.run { color: var(--run); font-weight: 600; }
.side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px;
  font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; border-radius: 12px; }
.btn.danger { color: var(--late); }
.btn:disabled { opacity: .5; }
.handoff { margin-top: 6px; font-size: 14px; display: grid; gap: 3px; }
.handoff b { font-weight: 600; }

.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; font-size: 15px; }

/* project cards */
.pcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: block; width: 100%; text-align: left; border-left: 5px solid var(--c);
}
.pcard h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.pcard p { margin: 4px 0 8px; color: var(--muted); font-size: 14px; }
.pcard .counts { display: flex; gap: 6px; flex-wrap: wrap; }
.info { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px; }
.info p, .info li { font-size: 15px; }
.info ul { padding-left: 18px; margin: 8px 0; }
.info dl { margin: 10px 0; }
.info dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-top: 10px; }
.info dd { margin: 2px 0 0; font-size: 15px; }
.tbl { overflow-x: auto; margin: 10px 0; }
.tbl table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.tbl th { background: var(--chip); font-weight: 600; }
.kd { display: grid; grid-template-columns: 86px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.kd:first-child { border-top: 0; }
.kd .d { font-weight: 600; }
.kd.past { color: var(--faint); }

/* close */
.choice { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.choice button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 11px; font-size: 13.5px; font-weight: 600;
}
.choice button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.choice input[type="date"] { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--bg); font-size: 14px; }
textarea.note, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; line-height: 1.4;
}
textarea.note { min-height: 140px; resize: vertical; }
.jn { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 14.5px; }
.jn .when { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.jn p { margin: 0; white-space: pre-wrap; }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
}
.tabs button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  color: var(--faint); font-size: 11px; font-weight: 600; position: relative;
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--ink); }
.tabs .badge {
  position: absolute; top: 2px; left: calc(50% + 6px); background: var(--late); color: #fff; border-radius: 999px;
  font-size: 10.5px; min-width: 17px; height: 17px; line-height: 17px; padding: 0 4px; text-align: center;
}

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px);
}
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 4px 0 12px; font-size: 21px; letter-spacing: -.01em; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field.row { display: flex; gap: 10px; }
.field.row > div { flex: 1; min-width: 0; }
.field select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.choice button[data-k="park"] { color: var(--muted); }
.quick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 10px; font-size: 13.5px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.actions .wide { grid-column: 1 / -1; }
.hint { font-size: 14px; color: var(--muted); }
.setting { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.setting h3 { margin: 0 0 6px; font-size: 16px; }
.setting p { margin: 0 0 10px; color: var(--muted); font-size: 14.5px; }
.status-on { color: var(--ok); font-weight: 600; }

/* login */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.login h1 { font-size: 34px; margin: 0; letter-spacing: -.02em; }
.login input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; font-size: 20px; letter-spacing: .2em; }
.err { color: var(--late); font-size: 14px; min-height: 1.2em; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 12px); z-index: 20;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
