/* 최소 스타일. 진짜 디자인은 Codex 시안으로 바뀔 예정이라, 모양보다 안 깨지는 것을 우선한다. */
:root {
  --bg: #f6f3ec; --card: #fff; --fg: #222; --muted: #777; --line: #ddd8cc; --accent: #3B5BDB; --danger: #c92a2a;
  --c-jangdang: #3B5BDB; --c-gajae: #E8590C; --c-minse-m: #AE3EC9; --c-minse-e: #2F9E44;
  --tab-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17181b; --card: #222428; --fg: #eceae4; --muted: #9a9a9a; --line: #3a3d42; --accent: #7c93f0; --danger: #ff8787;
    --c-jangdang: #7c93f0; --c-gajae: #ff9a5c; --c-minse-m: #d28bea; --c-minse-e: #69d17c; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); overflow-x: hidden; }
body { font: 16px/1.5 Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; }
[hidden] { display: none !important; }
h2 { margin: 0; font-size: 1.4rem; }
h3 { margin: 1.2rem 0 .4rem; font-size: 1rem; color: var(--muted); }
h4 { margin: 0 0 .3rem; font-size: 1rem; }
button, .btn, input, select, textarea { font: inherit; color: inherit; }
button, .btn { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
input[type=text], input[type=search], input[type=date], select, textarea { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
label { display: block; margin: .6rem 0; }
.hint { color: var(--muted); font-size: .9rem; }
.plain { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; margin: .6rem 0; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on, #nav button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.bar { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); margin-right: 6px; flex: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #2f9e44; }
.dot.off { background: #aaa; }
.switch { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.switch input { width: 22px; height: 22px; }
.tag { font-size: .8rem; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.tag.us { color: var(--accent); border-color: var(--accent); }

/* 로그인 */
#signin { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center; }

/* 앱 틀: 휴대폰은 아래 탭 */
#main { padding: 16px 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); max-width: 960px; margin: 0 auto; }
#nav { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--card); border-top: 1px solid var(--line); }
#nav button { flex: 1; border: 0; border-radius: 0; min-height: var(--tab-h); }
#acct { display: none; }
@media (min-width: 820px) {
  #app { display: flex; }
  #nav { position: sticky; top: 0; flex-direction: column; width: 180px; height: 100vh; padding: 16px 12px; gap: 6px; border-top: 0; border-right: 1px solid var(--line); }
  #nav button { flex: none; justify-content: flex-start; border-radius: 8px; min-height: 44px; }
  #acct { display: block; margin-bottom: 12px; font-weight: 600; }
  #main { flex: 1; min-width: 0; padding-bottom: 24px; margin: 0; max-width: none; }
}

/* 할 일 */
.todo { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.todo-check { width: 24px; height: 24px; flex: none; }
.todo-body { flex: 1; min-width: 0; border: 0; background: none; justify-content: flex-start; flex-direction: column; align-items: flex-start; text-align: left; padding: 4px 0; }
.todo.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .85rem; color: var(--muted); }
.todo-meta .overdue { color: var(--danger); }
.dday-n { font-size: 1.3rem; }

/* 일정 */
.event { display: flex; align-items: center; padding: 3px 0; }
.day-title { margin: .8rem 0 .2rem; }
#cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
#cal-grid .dow { background: var(--card); text-align: center; padding: 4px 0; font-size: .85rem; }
.cell { background: var(--card); min-height: 72px; padding: 2px; overflow: hidden; }
.cell.other { opacity: .45; }
.cell.today .cell-n { background: var(--accent); color: #fff; border-radius: 50%; padding: 0 5px; }
.cell.sat .cell-n { color: #4263eb; }
.cell.sun .cell-n, .cell.hol .cell-n { color: var(--danger); }
.cell-n { font-size: .8rem; }
.cell-items li { font-size: .7rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--c, var(--muted)); padding-left: 2px; margin-top: 1px; }
.cell-items li.todo-mark { border-left-color: transparent; }

/* 급식 */
.meal-dishes li { font-size: .95rem; }
.meal-dishes sup, .allergy { color: var(--muted); font-size: .7rem; opacity: .8; margin-left: 2px; }

/* 메모 */
.memo-body { margin: 0 0 .5rem; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* 할 일 편집 창: 휴대폰은 아래에서 올라오는 시트 */
.modal { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 14px 14px 0 0; }
@media (min-width: 820px) { .modal { align-items: center; } .sheet { border-radius: 14px; } }

#toast { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); background: #333; color: #fff; padding: 8px 16px; border-radius: 20px; max-width: 90vw; }
@media (min-width: 820px) { #toast { bottom: 24px; } }

/* 공휴일 */
.holiday { color: var(--danger); }
.holiday .bar { background: var(--danger); }
