:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --accent: #3b6cf6;
  --p1: #e5484d;
  --p2: #f59e0b;
  --p3: #22a06b;
  --overdue: #d92d20;
  --soon: #d97706;
  --radius: 10px;
  --content: 1200px; /* 넓은 화면에서 내용 최대 너비 */
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  min-width: 960px;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- 입력 요소 ---- */
input:not([type]), input[type="text"], input[type="password"], input[type="date"], select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(59 108 246 / 0.15);
}
.btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(0.95); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f3f4f6; }
.btn.danger { color: var(--overdue); border-color: #f4c7c3; }
.btn.danger:hover { background: #fef3f2; }
.btn.small { padding: 4px 8px; font-size: 13px; }

/* ---- 상단 바 ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; }
.add-form { flex: 1; display: flex; gap: 8px; }
.add-form #add-title { flex: 1; min-width: 0; }
.save-status { margin-left: auto; color: var(--muted); font-size: 13px; }
.save-status.error { color: var(--overdue); }

/* ---- 태그 ---- */
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px 24px 0; }
.tag-bar:empty { display: none; }
.tag-bar-label { font-size: 13px; color: var(--muted); margin-right: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag.clickable { cursor: pointer; }
.tag.clickable:hover { filter: brightness(0.96); }
.tag.active { border-color: currentColor; font-weight: 600; }
.tag.all { background: #eef0f3; color: var(--muted); cursor: pointer; font-family: inherit; }
.tag.all.active { color: var(--text); }
.tag-x { border: none; background: none; padding: 0 0 0 2px; cursor: pointer; color: inherit; opacity: 0.6; font-size: 14px; line-height: 1; }
.tag-x:hover { opacity: 1; }
/* ---- 2열 ---- */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 16px 24px 48px; align-items: start; }
/* 넓은 화면: 상단 바·태그·목록을 최대 var(--content) 너비로 가운데 정렬 */
.topbar, .tag-bar, .columns { padding-inline: max(24px, calc((100% - var(--content)) / 2)); }
.column { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; }
.column > h2 { font-size: 16px; margin: 0 0 4px; }
.group { margin-top: 12px; }
.group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 2px;
  border-bottom: 1px solid var(--line);
}
.group-title { display: inline-flex; align-items: center; gap: 6px; }
.group.overdue .group-title { color: var(--overdue); }
.group.soon .group-title { color: var(--soon); }
.sub-label { font-weight: 400; color: var(--faint); font-size: 12px; }
.count { margin-left: auto; font-weight: 400; }
.prio-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.prio-dot.p1 { background: var(--p1); }
.prio-dot.p2 { background: var(--p2); }
.prio-dot.p3 { background: var(--p3); }
.badge { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 4px; }
.badge.overdue { background: #fde8e7; color: var(--overdue); }

.list, .done-list { list-style: none; margin: 0; padding: 4px 0; border-radius: 8px; transition: background 0.15s; }
.list { min-height: 36px; }
.list:empty::after { content: '비어 있음'; display: block; padding: 7px 10px; color: #c4c8cf; font-size: 13px; }
body[data-drag="priority"] #col-priority .list,
body[data-drag="due"] #col-due .list { background: #f6f8ff; outline: 1px dashed #c7d2fe; outline-offset: -1px; }
body[data-drag] .list:empty::after { content: '여기로 끌어 놓기'; color: #8ea2f5; }

/* ---- 할 일 항목 ---- */
.item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 8px;
  border-left: 3px solid transparent;
  background: #fff;
}
.item:hover { background: #f8f9fb; }
.item[draggable="true"] { cursor: grab; }
.item.dragging { opacity: 0.45; background: #eef2ff; }
.item.p1 { border-left-color: var(--p1); }
.item.p2 { border-left-color: var(--p2); }
.item.p3 { border-left-color: var(--p3); }
.item.done { border-left-color: transparent; }
.item.done .item-title { text-decoration: line-through; color: var(--faint); }
.item.done .item-meta { opacity: 0.6; }
.item-body { flex: 1; min-width: 0; }
.item-title { color: inherit; text-decoration: none; word-break: break-word; cursor: pointer; }
.item-title:hover { color: var(--accent); text-decoration: underline; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--muted); align-items: center; }
.due.overdue { color: var(--overdue); font-weight: 600; }
.due.soon { color: var(--soon); font-weight: 600; }
.prio-tag { font-weight: 600; }
.prio-tag.p1 { color: var(--p1); }
.prio-tag.p2 { color: var(--p2); }
.prio-tag.p3 { color: var(--p3); }
.done-group .group-head { color: var(--faint); }

/* ---- 동그란 완료 버튼 ---- */
.check {
  flex: none;
  position: relative;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #b6bbc4;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.check:hover { border-color: var(--accent); }
.check::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid transparent;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check:hover::after { border-color: var(--accent); }
.check.checked { background: var(--accent); border-color: var(--accent); }
.check.checked::after { border-color: #fff; }
/* ---- 세부 화면 ---- */
.detail-page { --content: 820px; }
.detail {
  max-width: var(--content);
  margin: 24px auto 48px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head .check { width: 26px; height: 26px; margin: 0; }
.detail-head .check::after { left: 7px; top: 2px; width: 7px; height: 13px; }
.detail .title-input {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
  border-color: transparent;
  padding: 6px 8px;
}
.detail .title-input:hover { border-color: var(--line); }
.detail .title-input:focus { border-color: var(--accent); }
.detail.is-done .title-input { text-decoration: line-through; color: var(--faint); }
.done-note { margin: 6px 0 0 38px; font-size: 13px; color: var(--muted); }
.detail-fields { display: flex; gap: 24px; margin: 18px 0 0 38px; align-items: center; flex-wrap: wrap; }
.detail-fields label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.field { margin-top: 24px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.tag-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(59 108 246 / 0.15); }
.tag-editor input { flex: 1; min-width: 160px; border: none; box-shadow: none; padding: 2px 4px; }
.tag-editor input:focus { box-shadow: none; }
textarea { width: 100%; min-height: 220px; resize: vertical; line-height: 1.6; }

.subs { list-style: none; margin: 0; padding: 0; }
.sub { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 6px; }
.sub:hover { background: #f8f9fb; }

.sub input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.sub .sub-text { flex: 1; border-color: transparent; padding: 5px 6px; background: transparent; }
.sub .sub-text:hover { border-color: var(--line); }
.sub .sub-text:focus { border-color: var(--accent); background: #fff; }
.sub.done .sub-text { text-decoration: line-through; color: var(--faint); }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--faint); font-size: 18px; padding: 0 8px; line-height: 1; }
.icon-btn:hover { color: var(--overdue); }
#sub-form { margin-top: 6px; }
#sub-input { width: 100%; }
.detail-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---- 로그인 ---- */
.auth-page { min-height: 100vh; display: grid; place-items: center; min-width: 0; }
.auth-card {
  width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-card h1 { margin: 0; font-size: 20px; }
.auth-card p { margin: 0; }
.auth-card .btn { justify-content: center; }
.error { color: var(--overdue); font-size: 13px; min-height: 18px; }

/* ---- 알림 ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }