:root {
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --bg-soft: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-mute: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--primary); }

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

input[type="text"], input[type="password"], input[type="url"],
input[type="date"], input[type="number"], select, textarea {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}
input[type="color"] {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  background: none;
  cursor: pointer;
}

button {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:hover { background: var(--bg-soft); }
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}
button.danger:hover { background: rgba(239,68,68,.1); }
button.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-dim);
  cursor: pointer;
}
button.link-button:hover { color: var(--text); }

/* 상단바 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--text-dim); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); }
.inline-form { margin: 0; display: inline; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* 섹션 */
.dash-section { margin-bottom: 36px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.count {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.muted { color: var(--text-dim); }

/* 평면 task list (대시보드용) */
.task-flat { list-style: none; margin: 0; padding: 0; }
.task-flat li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
.check { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; }
.title { flex: 1; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 500; }
.badge.urgent { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge.important { background: rgba(245,158,11,.15); color: #fcd34d; }

.proj-tag {
  display: inline-block;
  background: color-mix(in srgb, var(--c) 25%, transparent);
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.due {
  font-size: 12px;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

/* 프로젝트 그리드 */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.project-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, var(--primary));
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .12s, border-color .12s;
}
.project-card:hover { transform: translateY(-1px); border-color: var(--accent); }
.project-card.status-hold { opacity: .7; }
.project-card.status-done { opacity: .5; }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.status-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
}
.project-card h3 { margin: 4px 0 0; font-size: 16px; font-weight: 600; color: var(--text); }
.client { font-size: 12px; color: var(--text-dim); }
.progress { font-size: 12px; color: var(--text-dim); margin-top: auto; }

/* 모달 */
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  color: var(--text);
  width: min(420px, 90vw);
}
.modal::backdrop { background: rgba(15,23,42,.7); backdrop-filter: blur(4px); }
.modal form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px;
  color: var(--text-dim);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* 프로젝트 상세 */
.project-detail { display: flex; flex-direction: column; gap: 20px; }
.project-header {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, var(--primary));
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.title-edit {
  background: transparent;
  border: 1px solid transparent;
  font-size: 22px;
  font-weight: 700;
  padding: 4px 8px;
  margin: -4px 0 8px -8px;
  width: 100%;
  min-width: 0;
}
.title-edit:hover, .title-edit:focus { border-color: var(--border); background: var(--bg); }
.project-header .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.project-header .meta input, .project-header .meta select { background: var(--bg); }

.project-body {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .project-body { grid-template-columns: 1fr; }
}

.tasks-pane, .notes-pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.task-add, .note-add {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.task-add input[name="title"] { flex: 1; min-width: 160px; }
.note-add { flex-direction: column; }
.note-add textarea { width: 100%; min-height: 70px; resize: vertical; }

.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-item.done .task-title { color: var(--text-mute); text-decoration: line-through; }
.task-item .drag-handle {
  cursor: grab;
  color: var(--text-mute);
  user-select: none;
  padding: 0 4px;
}
.task-title {
  flex: 1; background: transparent; border: 1px solid transparent;
}
.task-title:hover, .task-title:focus { border-color: var(--border); background: var(--bg); }
.due-input { width: 130px; background: var(--bg); }
.prio-select { background: var(--bg); }
.prio-select.prio-2 { color: #fca5a5; }
.prio-select.prio-1 { color: #fcd34d; }

.note-list { list-style: none; margin: 0; padding: 0; }
.note-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.note-meta {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-mute);
  margin-bottom: 4px;
}
.note-body { white-space: pre-wrap; word-break: break-word; }

/* 설정 */
.settings-page { max-width: 640px; }
.settings-page h1 { font-size: 20px; margin-bottom: 16px; }
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
legend { padding: 0 8px; font-weight: 600; }
fieldset label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
fieldset label:last-child { margin-bottom: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 100px; }
.check-inline { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; color: var(--text); }
.form-actions { margin-top: 8px; }
.test-notify-form { margin-top: 20px; display: flex; gap: 12px; align-items: center; }

/* 로그인 */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: min(360px, 100%);
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card p { margin: 0 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }

.alert {
  background: rgba(239,68,68,.1);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.alert.success {
  background: rgba(34,197,94,.1);
  color: #86efac;
  border-color: rgba(34,197,94,.3);
}

.head-right .danger {
  border: 1px solid var(--border);
  padding: 6px 12px;
}

@media (max-width: 640px) {
  .container { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar nav { gap: 12px; }
  .project-header { flex-direction: column; }
  .head-right { width: 100%; display: flex; justify-content: flex-end; }
}
