:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e1e0d9;
  --ring: rgba(11, 11, 11, 0.1);
  --primary: #0b0b0b;
  --on-primary: #ffffff;
  --danger: #c43434;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);

  /* group colors (validated categorical slots) */
  --sleep: #4a3aa7;
  --food: #eb6834;
  --health: #1baf7a;
  --work: #2a78d6;
  --etc: #e87ba4;

  --radius: 18px;
  --tabbar-h: 64px;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #96948d;
    --line: #2c2c2a;
    --ring: rgba(255, 255, 255, 0.1);
    --primary: #ffffff;
    --on-primary: #0b0b0b;
    --danger: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sleep: #9085e9;
    --food: #d95926;
    --health: #199e70;
    --work: #3987e5;
    --etc: #d55181;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #96948d;
  --line: #2c2c2a;
  --ring: rgba(255, 255, 255, 0.1);
  --primary: #ffffff;
  --on-primary: #0b0b0b;
  --danger: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sleep: #9085e9;
  --food: #d95926;
  --health: #199e70;
  --work: #3987e5;
  --etc: #d55181;
}

.g-sleep { --c: var(--sleep); }
.g-food { --c: var(--food); }
.g-health { --c: var(--health); }
.g-work { --c: var(--work); }
.g-etc { --c: var(--etc); }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.locked { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.3; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  padding-top: env(safe-area-inset-top);
}

.muted { color: var(--muted); }

/* ---------- top ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 12px; }
.hello { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sub { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; }
.page-title { margin: 0; font-size: 24px; letter-spacing: -0.02em; }

.daynav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 16px;
  padding: 4px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--ring);
}

.daynav-label {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  min-height: 40px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--ink-2);
}
.icon-btn:not(:disabled):hover { background: var(--surface-2); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 18px; height: 18px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11px;
  font-weight: 700;
}
.pill.sm { padding: 1px 6px; font-size: 10px; background: var(--surface-2); color: var(--ink-2); vertical-align: 2px; }

section { margin-bottom: 24px; }

.sec-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sec-title .count { color: var(--muted); font-weight: 600; margin-left: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 0 0 1px var(--ring);
}

/* ---------- badge (emoji in a tinted circle) ---------- */

.badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  background: color-mix(in srgb, var(--c, var(--muted)) 18%, var(--surface));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c, var(--muted)) 40%, transparent);
}
.badge.sm { width: 24px; height: 24px; font-size: 13px; }
.badge.lg { width: 52px; height: 52px; font-size: 26px; }

/* ---------- running timers ---------- */

.running { display: grid; gap: 8px; }

.run-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 4px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 45%, transparent);
}

.run-main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 4px 8px; text-align: left; min-width: 0; }
.run-text { display: grid; flex: 1; min-width: 0; }
.run-name { font-weight: 700; }
.run-since { font-size: 13px; color: var(--ink-2); }
.run-clock { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.run-stop {
  flex: none;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

/* ---------- pinned summary ---------- */

.pins {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 16px;
  margin: 0 -16px 24px;
  padding: 2px 16px 4px;
  scrollbar-width: none;
}
.pins::-webkit-scrollbar { display: none; }

.pin {
  flex: none;
  display: grid;
  gap: 6px;
  width: 148px;
  padding: 14px;
  text-align: left;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--ring);
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
}
.pin::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--c);
}
.pin-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pin-main { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.pin-main .muted { font-size: 15px; font-weight: 600; }
.pin-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- quick-record grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 6px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--ring);
}

.tile {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 8px 2px;
  border-radius: 14px;
  transition: transform 0.12s ease;
}
.tile:hover { background: var(--surface-2); }
.tile:active { transform: scale(0.95); }
.tile-name { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.tile.is-running .badge {
  background: var(--c);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c);
  animation: pulse 2s ease-in-out infinite;
}
.tile-live {
  position: absolute;
  top: 2px;
  right: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 10px;
  font-weight: 700;
}
.tile-add .badge { --c: var(--muted); background: var(--surface-2); color: var(--ink-2); font-size: 22px; box-shadow: inset 0 0 0 1.5px var(--line); }

@keyframes pulse {
  50% { box-shadow: 0 0 0 3px var(--surface), 0 0 0 8px color-mix(in srgb, var(--c) 30%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .tile.is-running .badge { animation: none; }
}

/* ---------- chips ---------- */

.chips {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--ring);
  font-size: 13px;
  color: var(--ink-2);
}
.chip b { color: var(--ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- timeline ---------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--ring);
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 24px;
  bottom: 24px;
  left: calc(14px + 66px + 10px + 18px - 1px);
  width: 2px;
  background: var(--line);
}

.tl-item {
  display: grid;
  grid-template-columns: 66px 36px 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  position: relative;
}
.tl-item:hover { background: var(--surface-2); }
.tl-time { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 8px; white-space: nowrap; }
.tl-time small { display: block; font-size: 11px; color: var(--muted); margin-top: -6px; }
.tl-body { display: grid; padding-top: 1px; min-width: 0; }
.tl-name { font-weight: 700; }
.tl-detail { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-memo { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }

.empty {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--ring);
}
.card .empty { box-shadow: none; padding: 16px; }

/* ---------- stats: day pattern ---------- */

.pattern { display: grid; gap: 6px; }

.pat-row { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 8px; }
.pat-label { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pat-row.is-today .pat-label { color: var(--ink); font-weight: 700; }

.pat-track {
  position: relative;
  height: 26px;
  border-radius: 6px;
  background:
    linear-gradient(to right, transparent calc(25% - 0.5px), var(--line) calc(25% - 0.5px), var(--line) calc(25% + 0.5px), transparent calc(25% + 0.5px)),
    linear-gradient(to right, transparent calc(50% - 0.5px), var(--line) calc(50% - 0.5px), var(--line) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to right, transparent calc(75% - 0.5px), var(--line) calc(75% - 0.5px), var(--line) calc(75% + 0.5px), transparent calc(75% + 0.5px)),
    var(--surface-2);
}

.pat-ticks { position: relative; height: 16px; }
.pat-ticks span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pat-ticks span:first-child { transform: none; }
.pat-ticks span:last-child { transform: translateX(-100%); }

.seg {
  position: absolute;
  top: 4px;
  bottom: 4px;
  min-width: 3px;
  border-radius: 4px;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--surface-2);
  cursor: pointer;
}
.pt {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px var(--surface-2);
  cursor: pointer;
}
.seg::after, .pt::after { content: ""; position: absolute; inset: -6px -3px; }
.seg.tip-active, .pt.tip-active { box-shadow: 0 0 0 2px var(--ink); z-index: 1; }

.legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--ink-2);
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }

.sum-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sum-table th, .sum-table td { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.sum-table tr:last-child th, .sum-table tr:last-child td { border-bottom: 0; }
.sum-table thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.sum-table th[scope="row"], .sum-table thead th:first-child { text-align: left; }
.sum-table th[scope="row"] { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sum-table small { color: var(--muted); font-size: 11px; }

.tip {
  position: fixed;
  z-index: 50;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: var(--shadow);
}

/* ---------- more ---------- */

.cat-list { list-style: none; margin: 0 0 12px; padding: 0; }
.cat-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-info { flex: 1; display: grid; min-width: 0; margin-left: 4px; }
.cat-name { font-weight: 600; }
.cat-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hint { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.footnote { text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */

.btn-primary, .btn-secondary, .btn-ghost, .btn-hero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 700;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-secondary { background: var(--surface-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 10px; background: var(--surface-2); }
.danger { color: var(--danger); }
.block { width: 100%; }

.btn-hero {
  width: 100%;
  min-height: 60px;
  font-size: 18px;
  background: var(--primary);
  color: var(--on-primary);
}
.btn-hero::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px var(--on-primary);
}

/* ---------- bottom sheet ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 30; }
.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.2s ease; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 520px;
  max-height: 92dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}
.sheet::before {
  content: "";
  display: block;
  width: 40px;
  height: 5px;
  margin: 0 auto 8px;
  border-radius: 3px;
  background: var(--line);
}
.sheet-root.open .scrim { opacity: 1; }
.sheet-root.open .sheet { transform: none; }

.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet-title { flex: 1; display: grid; }
.sheet-title b { font-size: 19px; letter-spacing: -0.02em; }
.sheet-title small { font-size: 13px; color: var(--muted); }

.sheet-form { display: grid; gap: 14px; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.live { display: grid; gap: 10px; justify-items: center; }
.live-clock { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }

.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
fieldset.field > legend { float: left; width: 100%; }
fieldset.field > legend + * { clear: both; }

.field input, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink); }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field-row:has(.emoji-field) { grid-template-columns: 76px 1fr; }
.emoji-field input { text-align: center; font-size: 24px; padding: 6px; }

.amount-row { display: flex; flex-wrap: wrap; gap: 6px; }
.amount-row input { flex: 1 1 120px; }
.chip-btn {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip-btn:hover { background: var(--surface-2); }

.seg-ctl { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg-opt input, .group-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt > span {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
}
.seg-opt input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--ring); }
.seg-opt input:focus-visible + span, .group-opt input:focus-visible + span { outline: 2px solid var(--ink); }

.group-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.group-opt > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.group-opt input:checked + span { background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--c); }

.sheet-form[data-kind="timer"] .instant-only { display: none; }
.instant-only { display: grid; gap: 14px; }

.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--primary); }

.form-error { margin: 0; color: var(--danger); font-size: 14px; font-weight: 600; }

.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .btn-primary { flex: 1; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 -1px 0 var(--line);
}
.tabbar button {
  flex: 1;
  max-width: 173px;
  height: var(--tabbar-h);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.tabbar button[aria-current="page"] { color: var(--ink); }
.tabbar button[aria-current="page"] svg { stroke-width: 2.5; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  width: fit-content;
  margin: 0 auto;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 16px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateY(12px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button {
  flex: none;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--on-primary);
  background: color-mix(in srgb, var(--on-primary) 16%, transparent);
  font-weight: 700;
}

/* ---------- sync ---------- */

.sync-chip {
  max-width: 55%;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--ring);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sync-chip[data-state="error"] { color: var(--danger); }
.sync-chip.static { display: inline-block; max-width: 100%; white-space: normal; padding: 6px 12px; background: var(--surface-2); box-shadow: none; }
.sync-line { margin: 0 0 10px; }
.sync-form { display: grid; gap: 12px; margin-bottom: 12px; }
.hint b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }

.howto { font-size: 13px; color: var(--ink-2); }
.howto summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.howto ol { margin: 6px 0 10px; padding-left: 20px; display: grid; gap: 6px; }
.howto b { color: var(--ink); }

/* ---------- todos ---------- */

.badge.xs { width: 18px; height: 18px; font-size: 10px; margin-right: 4px; vertical-align: -4px; box-shadow: none; }
.todo-badge { --c: var(--ink-2); font-size: 24px; }
.todo-badge svg { width: 26px; height: 26px; }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 10px 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--ring);
  font-size: 13px;
  color: var(--ink-2);
}
.notice.on { background: color-mix(in srgb, var(--health) 10%, var(--surface)); }
.notice-actions { display: flex; gap: 4px; flex: none; }
.btn-primary.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; flex: none; }

.todo-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 4px 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--ring);
}
.sheet .todo-list { box-shadow: none; background: var(--surface-2); }

.todo-row { display: flex; align-items: flex-start; gap: 4px; padding: 0 8px 0 6px; }
.todo-row + .todo-row { border-top: 1px solid var(--line); }
.due-row { align-items: center; padding: 4px 12px 4px 6px; }

.todo-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 48px;
  color: transparent;
}
.todo-check svg {
  width: 24px;
  height: 24px;
  padding: 3px;
  border-radius: 50%;
  stroke-width: 3;
  box-shadow: inset 0 0 0 2px var(--line);
  transition: background 0.15s ease, color 0.15s ease;
}
.todo-check:hover svg { box-shadow: inset 0 0 0 2px var(--muted); }
.todo-row.is-done .todo-check { color: var(--on-primary); }
.todo-row.is-done .todo-check svg { background: var(--primary); box-shadow: none; }

.todo-main { flex: 1; display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 12px 0; text-align: left; min-width: 0; }
.todo-time { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 2px; white-space: nowrap; }
.todo-body { display: grid; gap: 2px; min-width: 0; }
.todo-title { font-weight: 700; overflow-wrap: anywhere; }
.todo-meta { font-size: 12px; color: var(--muted); }
.todo-meta .sep { margin: 0 5px; }
.todo-memo { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.todo-row.is-done .todo-title { color: var(--muted); text-decoration: line-through; }
.todo-row.is-late .todo-time { color: var(--danger); font-weight: 700; }

.add-todo { margin-top: 2px; }

.all-todos summary { cursor: pointer; margin: 0; list-style: none; }
.all-todos summary::-webkit-details-marker { display: none; }
.all-todos summary::after { content: "펼치기"; float: right; font-size: 12px; font-weight: 600; color: var(--muted); }
.all-todos[open] summary::after { content: "접기"; }
.all-list { list-style: none; margin: 10px 0 0; padding: 0; }
.all-list li + li { border-top: 1px solid var(--line); }
.all-todo { width: 100%; display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 10px 0; text-align: left; }

.seg-ctl.three { grid-template-columns: repeat(3, 1fr); }
.field-row.two { grid-template-columns: 1fr 1fr; }
.sheet-form[data-repeat="daily"] .field-row.two,
.sheet-form[data-repeat="weekly"] .field-row.two { grid-template-columns: 1fr; }
.sheet-form:not([data-repeat="none"]) .repeat-none-only { display: none; }
.sheet-form:not([data-repeat="weekly"]) .repeat-weekly-only { display: none; }

.day-opts { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-opt input { position: absolute; opacity: 0; pointer-events: none; }
.day-opt span {
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.day-opt input:checked + span { background: var(--primary); color: var(--on-primary); }
.day-opt input:focus-visible + span { outline: 2px solid var(--ink); }

.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 16px;
}
.field-hint { font-size: 12px; color: var(--muted); }
.notice > button, .notice-actions button { flex: none; white-space: nowrap; }
