/* =============================================================
   하루정리 — 화면 꾸미기
   색은 모두 아래 변수에서 정하고, 다크 모드에서 다시 정합니다.
   ============================================================= */

:root {
  color-scheme: light dark;
  --bg: #F3EEE5;
  --card: #FFFFFF;
  --card-2: #F8F4ED;
  --text: #2A251F;
  --text-2: #5C5348;
  --text-3: #6E655A;
  --line: #E6DED2;
  --line-strong: #CDC2B2;
  --accent: #2C6B5A;
  --on-accent: #FFFFFF;
  --danger: #A32D2D;
  --danger-bg: #FCEBEB;
  --warn: #BA7517;
  --warn-text: #633806;
  --warn-bg: #FAEEDA;
  --ok: #3B6D11;
  --shadow: 0 1px 2px rgba(70, 50, 20, .06), 0 4px 14px rgba(70, 50, 20, .06);
  --radius: 18px;
  --radius-s: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "맑은 고딕", sans-serif;
  --axis: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1815;
    --card: #26231F;
    --card-2: #2F2B26;
    --text: #F3EEE6;
    --text-2: #CFC6B9;
    --text-3: #A9A094;
    --line: #3A352F;
    --line-strong: #544C43;
    --accent: #7FCDB3;
    --on-accent: #0E2A22;
    --danger: #F09595;
    --danger-bg: #4A1B1B;
    --warn: #EF9F27;
    --warn-text: #FAC775;
    --warn-bg: #412402;
    --ok: #97C459;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
  }
}

/* ---------- 프로젝트·상태 색 ----------
   --p-bg: 칩 바탕, --p-fg: 칩 글자, --p-strong: 진한 표시, --p-bar: 타임라인 막대 */
.pc-teal   { --p-bg: #E1F5EE; --p-fg: #085041; --p-strong: #1D9E75; --p-bar: #9FE1CB; }
.pc-pink   { --p-bg: #FBEAF0; --p-fg: #72243E; --p-strong: #D4537E; --p-bar: #F4C0D1; }
.pc-blue, .st-doing { --p-bg: #E6F1FB; --p-fg: #0C447C; --p-strong: #378ADD; --p-bar: #B5D4F4; }
.pc-amber, .st-waiting { --p-bg: #FAEEDA; --p-fg: #633806; --p-strong: #BA7517; --p-bar: #FAC775; }
.pc-purple { --p-bg: #EEEDFE; --p-fg: #3C3489; --p-strong: #7F77DD; --p-bar: #CECBF6; }
.pc-green, .st-done { --p-bg: #EAF3DE; --p-fg: #27500A; --p-strong: #639922; --p-bar: #C0DD97; }
.pc-coral  { --p-bg: #FAECE7; --p-fg: #712B13; --p-strong: #D85A30; --p-bar: #F5C4B3; }
.pc-gray, .st-todo { --p-bg: #F1EFE8; --p-fg: #444441; --p-strong: #888780; --p-bar: #D3D1C7; }

@media (prefers-color-scheme: dark) {
  .pc-teal   { --p-bg: #0B3B30; --p-fg: #9FE1CB; --p-strong: #5DCAA5; --p-bar: #085041; }
  .pc-pink   { --p-bg: #4B1528; --p-fg: #F4C0D1; --p-strong: #ED93B1; --p-bar: #72243E; }
  .pc-blue, .st-doing { --p-bg: #0C2F52; --p-fg: #B5D4F4; --p-strong: #85B7EB; --p-bar: #0C447C; }
  .pc-amber, .st-waiting { --p-bg: #412402; --p-fg: #FAC775; --p-strong: #EF9F27; --p-bar: #633806; }
  .pc-purple { --p-bg: #26215C; --p-fg: #CECBF6; --p-strong: #AFA9EC; --p-bar: #3C3489; }
  .pc-green, .st-done { --p-bg: #173404; --p-fg: #C0DD97; --p-strong: #97C459; --p-bar: #27500A; }
  .pc-coral  { --p-bg: #4A1B0C; --p-fg: #F5C4B3; --p-strong: #F0997B; --p-bar: #712B13; }
  .pc-gray, .st-todo { --p-bg: #353531; --p-fg: #D3D1C7; --p-strong: #B4B2A9; --p-bar: #444441; }
}

/* ---------- 기본 ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 전체 틀: 위 내용 + 아래 탭바 ---------- */

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.main {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top) + 14px) max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left));
}
body.sheet-open .main { overflow: hidden; }
.view { max-width: 720px; margin: 0 auto; }

.nav {
  flex: none;
  display: flex;
  align-items: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.nav-brand { display: none; }
.nav-item {
  flex: 1;
  position: relative;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 13px;
  color: var(--text-2);
}
.nav-item svg { width: 26px; height: 26px; }
.nav-item[aria-current="page"] { color: var(--accent); font-weight: 700; }
.nav-add {
  flex: none;
  order: 0;
  width: 58px;
  height: 58px;
  margin: 0 6px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
}
.nav-add svg { width: 30px; height: 30px; stroke-width: 2.4; }
.nav-add-label { display: none; }

.sync-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}
.nav .sync-dot { position: absolute; top: 8px; left: calc(50% + 10px); box-shadow: 0 0 0 2px var(--card); }
.sync-dot.is-ok { background: var(--ok); }
.sync-dot.is-syncing { background: var(--accent); }
.sync-dot.is-offline { background: var(--text-3); }
.sync-dot.is-error { background: var(--danger); }

/* ---------- 공통 부품 ---------- */

.view-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin: 0 0 16px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head .small-btn { margin-left: auto; }
.count { color: var(--text-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.empty { color: var(--text-2); margin: 4px 0; }
.help { color: var(--text-2); font-size: 15px; margin: 0 0 12px; }
.error-text { color: var(--danger); }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
.icon-btn.flat { box-shadow: none; background: var(--card-2); }
.small-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  font-size: 15px;
  white-space: nowrap;
}
.link-btn {
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 10px 4px;
  margin: -10px 0;
  font-size: 15px;
}
.btn {
  min-height: 50px;
  padding: 0 18px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  background: var(--card);
  font-size: 17px;
  font-weight: 600;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-danger-text { background: none; border-color: transparent; color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 13px;
  line-height: 1.6;
  background: var(--p-bg, var(--card-2));
  color: var(--p-fg, var(--text-2));
  white-space: nowrap;
}
.chip-plain { background: var(--card-2); color: var(--text-2); }
.chip-danger { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.chip-warn { background: var(--warn-bg); color: var(--warn-text); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--p-strong); flex: none; display: inline-block; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 12px 4px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 5px; height: 14px; border-radius: 2px; }
.legend svg { width: 15px; height: 15px; }
.lg-danger { background: var(--danger); }
.lg-warn { background: var(--warn); }
.lg-bar { width: 18px !important; height: 8px !important; border-radius: 4px !important; background: var(--line-strong); }
.lg-today { width: 14px !important; border-radius: 4px !important; background: var(--danger-bg); border: 1px solid var(--danger); }

.seg {
  display: inline-flex;
  padding: 3px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--line);
}
.seg button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-size: 15px;
  color: var(--text-2);
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.seg-full { display: flex; margin: 0 0 16px; }
.seg-full button { flex: 1; }

/* ---------- 오늘: 날짜 머리 ---------- */

.day-head { flex-wrap: nowrap; }
.day-title { flex: 1; text-align: center; min-width: 0; }
.day-title h1 { font-size: 22px; }
.day-title p { margin: 2px 0 0; color: var(--text-2); font-size: 15px; }

/* ---------- 오늘: 시간표 ---------- */

.schedule-wrap { padding: 10px 0 4px; }
.schedule { position: relative; }
.hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.hour span {
  position: absolute;
  top: -10px;
  left: 0;
  padding-right: 6px;
  background: var(--card);
  font-size: 13px;
  line-height: 20px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.ev {
  position: absolute;
  left: calc(var(--axis) + (100% - var(--axis)) * var(--col) / var(--cols));
  width: calc((100% - var(--axis)) / var(--cols) - 4px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  padding: 4px 10px;
  border: 0;
  border-left: 4px solid var(--p-strong);
  border-radius: 4px 10px 10px 4px;
  background: var(--p-bg);
  color: var(--p-fg);
  text-align: left;
  line-height: 1.3;
}
.ev strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev small { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.is-short { flex-direction: row; align-items: center; gap: 8px; padding-top: 0; padding-bottom: 0; }
.ev.is-short small { flex: none; order: -1; font-variant-numeric: tabular-nums; }
.now {
  position: absolute;
  left: calc(var(--axis) - 4px);
  right: 0;
  border-top: 2px solid var(--danger);
  z-index: 2;
  pointer-events: none;
}
.now::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

/* ---------- 오늘: 체크리스트 ---------- */

.checklist { margin-bottom: 16px; }
.checklist .card-head { padding: 0 4px; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex;
  align-items: stretch;
  min-height: 58px;
  background: var(--card);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
}
.task.is-overdue { box-shadow: inset 5px 0 0 var(--danger), var(--shadow); }
.task.is-rolled { box-shadow: inset 5px 0 0 var(--warn), var(--shadow); }
.check { flex: none; width: 58px; border: 0; background: none; display: grid; place-items: center; }
.check .box {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: transparent;
}
.check .box svg { width: 20px; height: 20px; stroke-width: 3; }
.check[aria-checked="true"] .box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 10px 14px 10px 0;
  border: 0;
  background: none;
  text-align: left;
}
.task-title { font-size: 17px; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.task.is-done .task-title { text-decoration: line-through; color: var(--text-3); }

/* ---------- 전체: 거르기 ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters select {
  min-height: 44px;
  max-width: 100%;
  padding: 0 36px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887f73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.toggle {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  font-size: 15px;
}
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }

/* ---------- 전체: 표 ---------- */

.group { margin-bottom: 20px; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; font-size: 17px; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 6px; padding-right: 8px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main {
  flex: 1;
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 4px 10px 16px;
  border: 0;
  background: none;
  text-align: left;
}
.row-title { overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--text-2); }
.row.is-done .row-title { text-decoration: line-through; color: var(--text-3); }
.row-due { flex: none; font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.row-due.is-overdue { color: var(--danger); font-weight: 700; }
.status { flex: none; min-height: 44px; min-width: 78px; padding: 0; border: 0; background: none; display: grid; place-items: center end; }
.status .chip { font-size: 14px; padding: 4px 12px; border: 1px solid var(--p-strong); }

/* ---------- 전체: 타임라인 ---------- */

.tl-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tl-range { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; }
.tl-nav .small-btn { margin-left: auto; }
.tl {
  --lw: 0px; /* 폰: 이름은 막대 위 줄에 따로 씀 */
  position: relative;
  padding: 8px 8px 8px 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  touch-action: pan-y;
  overflow: hidden;
}
.tl-row {
  display: grid;
  grid-template-columns: var(--lw) repeat(var(--n), minmax(0, 1fr));
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
}
.tl-row > * { grid-row: 2; }
.tl-row > .tl-label { grid-row: 1; grid-column: 1 / -1; padding-top: 6px; }
.tl-days > * { grid-row: 1; }
.tl-days { min-height: 42px; border-top: 0; text-align: center; color: var(--text-2); }
.tl-day { display: flex; flex-direction: column; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.tl-day small { font-size: 12px; }
.tl-day b { font-size: 12px; font-weight: 600; }
.tl-day.is-weekend { color: var(--text-3); }
.tl-day.is-today b { color: var(--danger); font-weight: 800; }
.tl-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line-strong);
  font-size: 15px;
  font-weight: 700;
}
.tl-label { grid-column: 1; padding-right: 8px; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tl-events .tl-label { color: var(--text-2); }
.tl-bar { height: 12px; margin: 0 2px; border-radius: 6px; background: var(--p-bar); border: 1px solid var(--p-strong); }
.tl-due { justify-self: center; z-index: 1; font-size: 16px; line-height: 1; color: var(--p-strong); }
.tl-due.is-overdue { color: var(--danger); }
.tl-work { justify-self: center; font-size: 11px; color: var(--p-strong); }
.tl-task.is-done .tl-label { text-decoration: line-through; color: var(--text-3); }
.tl-task.is-done .tl-bar { background: none; border-style: dashed; }
.tl-ev {
  justify-self: stretch;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--p-strong);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}
.tl-ev svg { width: 17px; height: 17px; }
/* 오늘 날짜 세로 띠 (글자를 가리지 않도록 내용 뒤에 깔림) */
.tl-now {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: calc(12px + var(--lw) + (100% - 20px - var(--lw)) * var(--i) / var(--n));
  width: calc((100% - 20px - var(--lw)) / var(--n));
  border-radius: 8px;
  background: var(--danger-bg);
  pointer-events: none;
  z-index: 0;
}
.tl-row, .tl-group { position: relative; z-index: 1; }
.tl-legend { margin-bottom: 8px; }
.tl + .tl-legend + .help, .tl-legend ~ .help { margin: 6px 4px 0; font-size: 14px; }

/* ---------- 설정 ---------- */

.plist { list-style: none; margin: 0 -16px; padding: 0; }
.prow {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
}
.pname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.prow svg { width: 18px; height: 18px; color: var(--text-3); }
.sync-status { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: 700; }
.code-box {
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card-2);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 18px;
  letter-spacing: .04em;
  word-break: keep-all; /* 4글자 묶음이 중간에서 끊기지 않게 */
}
details.join { margin-top: 4px; }
details summary, details.more summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸"; margin-right: 8px; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
#join-form { padding-top: 8px; }

/* ---------- 추가/수정 시트 ---------- */

.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(25, 18, 10, .42); }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--card);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .18);
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 5px; margin: 4px auto 8px; border-radius: 3px; background: var(--line-strong); }
.sheet-head { display: flex; align-items: center; margin-bottom: 14px; }
.sheet-head h2 { flex: 1; font-size: 21px; }

.field { display: block; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend, .field > label {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
}
.field small { font-weight: 400; color: var(--text-3); }
.field input:not([type="radio"]):not([type="checkbox"]), .field textarea, .new-project {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card-2);
  font-size: 17px; /* 16px 이상이어야 아이폰에서 화면이 확대되지 않습니다 */
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { resize: vertical; min-height: 88px; }
input[type="date"], input[type="time"] { text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
.new-project { margin-top: 10px; }
.date-row { display: flex; gap: 8px; align-items: center; }
.date-row input { flex: 1; min-width: 0; }
.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { margin: -10px 0 14px; font-size: 14px; color: var(--danger); }
.field .field-error { margin: 6px 0 0; }
.field-error:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { position: relative; display: inline-flex; }
.chip-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip-opt span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--p-bg, var(--card-2));
  color: var(--p-fg, var(--text));
  font-size: 16px;
}
.chip-opt:not([class*="pc-"]):not([class*="st-"]) span { border-color: var(--line-strong); background: var(--card); }
.chip-opt input:checked + span { border-color: var(--text); font-weight: 700; }
.chip-opt input:checked + span::before { content: "✓"; margin-right: 6px; }
.chip-opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch span { width: 46px; height: 46px; padding: 0; border-radius: 50%; background: var(--p-strong); justify-content: center; }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--text); border-color: transparent; }
.swatch input:checked + span::before { content: "✓"; margin: 0; color: #fff; font-size: 20px; }

.switch-row { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: -4px 0 8px; font-size: 16px; }
.switch-row input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); flex: none; }
details.more { margin-bottom: 8px; }
details.more[open] summary { margin-bottom: 8px; }

.sheet-actions {
  position: sticky;
  bottom: calc(-16px - env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  margin: 8px 0 0;
  padding: 10px 0 calc(4px + env(safe-area-inset-bottom));
  background: var(--card);
}
.sheet-actions .btn-primary { flex: 1; }

/* ---------- 알림 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
.toast button {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  white-space: nowrap;
}

/* ---------- 컴퓨터 등 넓은 화면 ---------- */

@media (min-width: 900px) {
  .app { flex-direction: row; }
  .nav {
    order: -1;
    width: 220px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 28px 16px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .nav-brand { display: block; order: -2; padding: 0 12px 18px; font-size: 21px; font-weight: 800; }
  .nav-add {
    order: -1;
    width: auto;
    height: 50px;
    margin: 0 0 14px;
    padding: 0 16px;
    border-radius: var(--radius-s);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
  }
  .nav-add svg { width: 22px; height: 22px; }
  .nav-add-label { display: inline; }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 50px; padding: 0 12px; font-size: 16px; }
  .nav-item svg { width: 22px; height: 22px; }
  .nav-item[aria-current="page"] { background: var(--card-2); }
  .nav .sync-dot { position: static; margin-left: auto; box-shadow: none; }
  .main { padding: 32px 36px; }
  .view { max-width: 1240px; }
  .today-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .day-head { max-width: 560px; }
  .tl { --lw: 180px; }
  .tl-row > *, .tl-row > .tl-label { grid-row: 1; padding-top: 0; }
  .tl-row > .tl-label { grid-column: 1; }
  .tl-day b { font-size: 14px; }
  .tl-ev { min-height: 44px; }
  .sheet {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(560px, 92vw);
    max-height: 88vh;
    transform: translate(-50%, -50%);
    border-radius: 22px;
    padding: 12px 24px 20px;
    animation: none;
  }
  .sheet-handle { display: none; }
  .sheet-actions { bottom: -20px; padding-bottom: 8px; }
  .toast { bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  details summary::before { transition: none; }
}
