:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --line: #e4e2dc;
  --text: #1c1d20;
  --muted: #6b6d73;
  --soft: #f0efeb;
  --urgent: #c9302c;
  --urgent-bg: #fdecea;
  --warn: #8a5a00;
  --focus: #2f5bd3;

  --me: #2f5bd3;       --me-bg: #e9eefc;
  --cowork: #0e7c70;   --cowork-bg: #e3f4f1;
  --cc: #7b3fd0;       --cc-bg: #f1eafc;
  --event: #5c5f66;    --event-bg: #eeeeec;

  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --card: #1f2024; --line: #2e3036; --text: #eceae6; --muted: #9a9ca3;
    --soft: #26282d; --urgent: #ff7b72; --urgent-bg: #3a1f1f; --warn: #e3b25a; --focus: #8fb0ff;
    --me: #8fb0ff;      --me-bg: #1f2a45;
    --cowork: #5fd3c3;  --cowork-bg: #16332f;
    --cc: #c3a2ff;      --cc-bg: #2c2240;
    --event: #b3b5bb;   --event-bg: #2a2b30;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a; --card: #1f2024; --line: #2e3036; --text: #eceae6; --muted: #9a9ca3;
  --soft: #26282d; --urgent: #ff7b72; --urgent-bg: #3a1f1f; --warn: #e3b25a; --focus: #8fb0ff;
  --me: #8fb0ff;      --me-bg: #1f2a45;
  --cowork: #5fd3c3;  --cowork-bg: #16332f;
  --cc: #c3a2ff;      --cc-bg: #2c2240;
  --event: #b3b5bb;   --event-bg: #2a2b30;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 120px; }
.muted { color: var(--muted); }
.boot { padding-top: 30vh; text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* 머리 */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.today { font-size: 14px; }
.seen { margin: 6px 0 14px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.seen b { font-weight: 600; }

/* 담당 필터 */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 18px; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { border-color: var(--text); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.chip .n { color: var(--muted); font-weight: 400; }

/* 섹션 */
section { margin-top: 26px; }
section > h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; letter-spacing: 0.02em; }
.empty { font-size: 14px; color: var(--muted); padding: 10px 2px; }

/* 카드 */
.card {
  --c: var(--me); --cb: var(--me-bg);
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: var(--radius); margin-bottom: 8px; overflow: hidden;
}
.card.o-cowork { --c: var(--cowork); --cb: var(--cowork-bg); }
.card.o-cc { --c: var(--cc); --cb: var(--cc-bg); }
.card.o-event { --c: var(--event); --cb: var(--event-bg); }
.card.closed { opacity: 0.72; }
.line { display: flex; align-items: flex-start; }
.head { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 12px 14px 12px 4px; cursor: pointer; display: block; }

/* 체크박스 */
.check {
  flex: none; width: 26px; height: 26px; margin: 11px 8px 0 12px; padding: 0; border-radius: 8px;
  border: 2px solid var(--c); background: var(--card); cursor: pointer; display: grid; place-items: center;
}
.check svg { width: 18px; height: 18px; fill: none; stroke: var(--card); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check.on { background: var(--c); }
.check.on svg { opacity: 1; }
.check.x { border-style: dashed; opacity: 0.6; }
.check.ev { border: 0; background: none; cursor: default; position: relative; }
.check.ev::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--c); }
.ask { font-size: 12px; font-weight: 600; border: 1px solid var(--c); color: var(--c); border-radius: 6px; padding: 0 6px; }

/* 날짜 묶음 */
.day { margin-top: 14px; }
.day-head {
  width: 100%; display: flex; align-items: baseline; gap: 8px; background: none; border: 0;
  padding: 8px 2px; cursor: pointer; text-align: left; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.chev { width: 14px; color: var(--muted); font-size: 13px; flex: none; }
.day-title { font-weight: 700; font-size: 15px; }
.rel { font-size: 12px; font-weight: 600; color: var(--muted); }
.rel.hot { color: var(--urgent); }
.day-sum { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.day.late .day-title { color: var(--urgent); }
.confirm-title { margin: 0; font-weight: 600; }
.row1 { display: flex; gap: 10px; align-items: flex-start; }
.title { flex: 1; font-weight: 600; line-height: 1.4; }
.closed .title { text-decoration: line-through; text-decoration-thickness: 1px; }
.due { flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--muted); padding-top: 1px; }
.due.hot { color: var(--urgent); background: var(--urgent-bg); border-radius: 6px; padding: 1px 7px; }
.due.soon { color: var(--warn); }
.row2 { margin-top: 4px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.badge { font-size: 12px; font-weight: 600; color: var(--c); background: var(--cb); border-radius: 6px; padding: 1px 7px; }
.tent { font-size: 12px; border: 1px dashed var(--muted); border-radius: 6px; padding: 0 6px; }
.logn { font-size: 12px; }

.body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.note { white-space: pre-wrap; font-size: 14px; margin: 12px 0 0; }
.ref { margin-top: 8px; color: var(--muted); word-break: break-all; }
.log { list-style: none; margin: 12px 0 0; padding: 0; font-size: 14px; }
.log li { padding: 8px 10px; background: var(--soft); border-radius: 8px; margin-bottom: 6px; }
.log .meta { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
.log .who-me { color: var(--me); } .log .who-cowork { color: var(--cowork); } .log .who-cc { color: var(--cc); }

textarea, input[type="text"], input[type="password"], input[type="datetime-local"], select {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 76px; resize: vertical; margin-top: 12px; display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px;
  cursor: pointer; font-size: 14px;
}
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.edit label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }

details.done-list > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; }
details.done-list > summary::-webkit-details-marker { display: none; }
details.done-list[open] > summary { margin-bottom: 8px; }

/* 추가 버튼 · 시트 */
.fab {
  position: fixed; right: max(16px, calc(50vw - 344px)); bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg);
  font-size: 28px; line-height: 1; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
.sheet { padding: 18px 16px 16px; display: grid; gap: 12px; }
.sheet h3 { margin: 0; font-size: 17px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg input:checked + label { border-color: var(--text); font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 600; }

.foot { margin-top: 40px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dev { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.dev:last-child { border-bottom: 0; }

/* 등록 화면 */
.enroll { max-width: 380px; margin: 16vh auto 0; display: grid; gap: 14px; }
.enroll h1 { margin: 0; font-size: 22px; }
.err { color: var(--urgent); font-size: 14px; min-height: 1.5em; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100vw - 32px); z-index: 10;
}
.banner { background: var(--urgent-bg); color: var(--urgent); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
