:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --line: #e5e7f0;
  --ink: #1f2333;
  --muted: #6b7280;
  --brand: #4f46e5;
  --brand-soft: #eef0ff;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* 로그인 */
/* [hidden] 속성이 항상 display 를 이기도록 (overlay 가 안 사라지는 버그 방지) */
[hidden] { display: none !important; }
.login-overlay {
  position: fixed; inset: 0; background: var(--brand);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 28px 24px; width: 300px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.login-card h2 { margin: 0; font-size: 18px; }
.login-card p { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.login-card input { padding: 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.login-card button { padding: 11px; background: var(--brand); color: #fff; border: none; border-radius: 10px; font-size: 15px; cursor: pointer; }
.login-err { color: var(--danger); font-size: 13px; min-height: 16px; }

/* 헤더 */
header {
  background: var(--brand); color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
header h1 { font-size: 19px; margin: 0; }
.head-right { display: flex; align-items: center; gap: 12px; }
.me label { font-size: 13px; opacity: .85; margin-right: 6px; }
.me select { padding: 6px 8px; border-radius: 8px; border: none; font-size: 14px; }
#logout-btn { background: rgba(255,255,255,.18); color: #fff; border: none; padding: 6px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; }

/* 범례 */
.legend { display: flex; gap: 14px; padding: 8px 16px 0; flex-wrap: wrap; }
.dot-label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

nav { display: flex; gap: 4px; padding: 10px 12px 0; overflow-x: auto; }
nav button { border: none; background: transparent; padding: 9px 14px; border-radius: 10px 10px 0 0; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
nav button.active { background: var(--card); color: var(--brand); font-weight: 700; }

main { padding: 12px; max-width: 820px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.form-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 110px; }
input, select, button { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-family: inherit; }
#add-btn { background: var(--brand); color: #fff; border: none; cursor: pointer; flex: 0 0 80px; }
.quick-row #q-text { flex: 1; }
.quick-row #q-btn { flex: 0 0 90px; background: #0ea5e9; color: #fff; border: none; cursor: pointer; }
.quick-sep { text-align: center; font-size: 11px; color: var(--muted); margin: 2px 0 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 10px 2px 0; }

/* 캘린더 */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cal-head strong { font-size: 16px; }
.cal-head button { border: 1px solid var(--line); background: #fff; cursor: pointer; padding: 6px 12px; border-radius: 8px; }
.cal-today-btn { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { margin-bottom: 4px; }
.cal-dowcell { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-cell { min-height: 78px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; background: #fff; cursor: pointer; overflow: hidden; }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-num { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.cal-ev { color: #fff; font-size: 11px; padding: 2px 5px; border-radius: 5px; margin-bottom: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 할일 보드 */
.todo-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.todo-col { background: #fafaff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.todo-colhead { font-weight: 700; font-size: 14px; padding: 4px 6px 8px; border-bottom: 2px solid; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.todo { display: flex; align-items: flex-start; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px; margin-bottom: 6px; }
.todo input[type=checkbox] { width: 18px; height: 18px; margin-top: 1px; flex: 0 0 auto; padding: 0; }
.todo-body { flex: 1; min-width: 0; }
.todo-ttl { font-weight: 600; }
.todo-date { font-size: 11px; color: var(--muted); margin-left: 6px; }
.todo-detail { font-size: 12px; color: var(--muted); }
.todo.done .todo-ttl { text-decoration: line-through; color: var(--muted); }
.todo .del { color: var(--danger); background: none; border: none; cursor: pointer; flex: 0 0 auto; padding: 0 2px; }

/* 히스토리 */
.hist { font-size: 13px; padding: 9px 12px; border-bottom: 1px solid var(--line); line-height: 1.5; }
.hist .tag { font-weight: 700; margin-right: 4px; }
.hist .tag.create { color: #047857; }
.hist .tag.delete { color: var(--danger); }
.hist .at { color: var(--muted); font-size: 11px; }

.empty { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }
.empty.sm { padding: 10px; font-size: 12px; }
