/* ============================================================
   업무일지 - 스타일시트
   디자인: 미니멀 업무 도구 (Linear/Notion 풍)
   ============================================================ */

/* ===== 1. 토큰 ===== */
:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --surface2: #f8f9fb;
  --border: #e4e7ec;
  --text: #191f28;
  --muted: #6b7684;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04);

  /* 상태 색 */
  --st-todo: #6b7280;   --st-todo-bg: #f3f4f6;
  --st-doing: #2563eb;  --st-doing-bg: #dbeafe;
  --st-done: #059669;   --st-done-bg: #d1fae5;
  --st-late: #dc2626;   --st-late-bg: #fee2e2;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface2: #1d212a;
  --border: #262b35;
  --text: #e7eaee;
  --muted: #8b94a1;
  --accent: #3b82f6;
  --accent-soft: #1e2a47;

  --st-todo: #9ca3af;   --st-todo-bg: #272b33;
  --st-doing: #60a5fa;  --st-doing-bg: #1e2a47;
  --st-done: #34d399;   --st-done-bg: #11342a;
  --st-late: #f87171;   --st-late-bg: #421b1e;
}

/* ===== 2. 베이스 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 속성이 display 지정 클래스보다 항상 우선하도록 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 28px; height: 28px; }

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

/* ===== 3. 공통 컴포넌트 ===== */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  color: var(--text);
  min-height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: auto; cursor: pointer; }
textarea.input { resize: vertical; min-height: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  min-height: 40px;
  font-weight: 600;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--st-late-bg); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: none; background: transparent;
  border-radius: 9px;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }

/* 세그먼트 */
.seg {
  display: flex; gap: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.seg-btn {
  flex: 1;
  min-height: 34px;
  padding: 6px 10px;
  border: none; background: none;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.seg-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* 상태 배지 */
.badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  white-space: nowrap;
  flex: none;
}
.badge.st-todo  { background: var(--st-todo-bg);  color: var(--st-todo); }
.badge.st-doing { background: var(--st-doing-bg); color: var(--st-doing); }
.badge.st-done  { background: var(--st-done-bg);  color: var(--st-done); }
.badge.st-late  { background: var(--st-late-bg);  color: var(--st-late); }
button.badge { cursor: pointer; }

/* 카테고리 칩 */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* 우선순위 깃발 */
.flag { display: inline-flex; flex: none; }
.flag .icon { width: 14px; height: 14px; }
.flag-high { color: #dc2626; }
.flag-mid  { color: #f59e0b; }
.flag-low  { color: #9ca3af; }

/* D-day */
.dday {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.dday.danger { background: var(--st-late-bg); border-color: transparent; color: var(--st-late); }

/* 카드 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 700;
  color: var(--muted);
  margin: 22px 0 10px;
}
.section-title .icon { width: 15px; height: 15px; }
.section-title .count { font-weight: 600; color: var(--muted); }

/* 빈 상태 */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}
.empty .icon { width: 40px; height: 40px; opacity: .45; }

/* 스켈레톤 */
.skel {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-row { height: 52px; margin-bottom: 8px; }
.skel-card { height: 110px; }

/* ===== 4. 헤더 ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  height: 56px;
  padding: 0 16px;
}
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); }
.logo-mark { width: 26px; height: 26px; border-radius: 7px; flex: none; }
.logo-text { font-size: 15px; font-weight: 700; }

.header-tabs { display: none; gap: 4px; margin: 0 auto; }
.header-tab {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none;
  border-radius: 9px;
  padding: 8px 14px;
  min-height: 38px;
  color: var(--muted);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.header-tab:hover { background: var(--surface2); color: var(--text); }
.header-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.header-tab .icon { width: 16px; height: 16px; }

.header-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.sync-label { font-size: 12px; color: var(--muted); white-space: nowrap; margin-right: 4px; }

#btn-refresh.spinning .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 5. 메인 레이아웃 ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.view-title { font-size: 20px; font-weight: 700; }

/* ===== 6. 오늘 뷰 ===== */
.today-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px;
}
.today-date { font-size: 22px; font-weight: 700; }
.today-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.today-ring { flex: none; }
.ring { display: block; }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 5; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset .4s;
}
.ring-fg.done { stroke: var(--st-done); }
.ring-text { font-size: 12px; font-weight: 700; fill: var(--text); }

.quick-add {
  display: grid;
  grid-template-columns: 1fr 142px auto 150px 110px auto;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  margin-bottom: 6px;
}
.quick-add .input { background: var(--surface2); border-color: transparent; }
.quick-add .input:focus { background: var(--surface); border-color: var(--accent); }

/* 업무 행 (스와이프 배경을 위한 래퍼 포함) */
.swipe-wrap { position: relative; margin-bottom: 8px; }
.swipe-bg {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  display: none; align-items: center;
  color: #fff;
}
.swipe-wrap.sw-right .swipe-bg-l { display: flex; }
.swipe-wrap.sw-left  .swipe-bg-r { display: flex; }
.swipe-bg-l { background: rgba(16,185,129,.5); justify-content: flex-start; padding-left: 20px; }
.swipe-bg-r { background: rgba(59,130,246,.5); justify-content: flex-end; padding-right: 20px; }
.swipe-wrap.sw-past .swipe-bg-l { background: #10b981; }
.swipe-wrap.sw-past .swipe-bg-r { background: #3b82f6; }
.swipe-bg .icon { width: 20px; height: 20px; }

.task-row {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 9px 12px;
  min-height: 52px;
  transition: border-color .15s, opacity .25s;
}
.task-row:hover { border-color: var(--accent); }

.check-btn {
  width: 30px; height: 30px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.6px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
  transition: all .15s;
}
.check-btn:hover { border-color: var(--st-done); color: var(--st-done); }
.check-btn .icon { width: 15px; height: 15px; }
.check-btn.anim-check { animation: checkPop .15s ease; }
@keyframes checkPop {
  0% { transform: scale(.7); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.task-row.is-done .check-btn { background: var(--st-done); border-color: var(--st-done); color: #fff; }

.task-main {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
  cursor: pointer;
  min-height: 34px;
}
.task-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row.is-done { opacity: .62; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-date-tag { font-size: 12px; color: var(--st-late); font-weight: 600; flex: none; }
.note-mark { color: var(--muted); display: inline-flex; flex: none; }
.note-mark .icon { width: 14px; height: 14px; }

.overdue-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--st-late);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin: 16px 0 4px;
}
.overdue-wrap .section-title { margin: 0 0 10px; color: var(--st-late); }
.overdue-wrap .task-row { box-shadow: none; }
.overdue-wrap .swipe-wrap { margin-bottom: 6px; }
.overdue-wrap .swipe-wrap:last-child { margin-bottom: 0; }
.btn-to-today {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  padding: 6px 10px;
  min-height: 32px;
}
.btn-to-today:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 7. 주간 뷰 ===== */
.week-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.week-nav-btns { display: flex; align-items: center; gap: 4px; }
.week-label { font-size: 18px; font-weight: 700; }

/* 주차 선택 미니 캘린더 (주간·보드 공용) */
.week-label-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.week-label-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none;
  border-radius: 9px;
  padding: 4px 8px;
  min-width: 0;
  transition: background .15s;
}
.week-label-btn:hover { background: var(--surface2); }
.week-label-btn > .icon { width: 16px; height: 16px; color: var(--muted); flex: none; transition: transform .15s; }
.week-label-btn[aria-expanded="true"] > .icon { transform: rotate(180deg); }

.week-picker {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 80;
  width: 286px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  padding: 10px;
  animation: popIn .15s;
}
.wp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.wp-title { font-size: 13px; font-weight: 700; margin-right: auto; padding-left: 4px; }
.wp-today-btn { min-height: 28px; padding: 3px 10px; font-size: 12px; margin-left: 4px; }
.wp-dows { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.wp-dow { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0; }
.wp-week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
}
.wp-week.is-sel { background: var(--surface2); box-shadow: inset 0 0 0 1px var(--border); }
.wp-week:hover { background: var(--accent-soft); }
.wp-week:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wp-day {
  font-size: 12px;
  text-align: center;
  padding: 6px 0;
  color: var(--text);
}
.wp-day.out { color: var(--muted); opacity: .5; }
.wp-day.is-today { color: var(--accent); font-weight: 800; }

/* 모바일: 팝오버를 화면 중앙 작은 카드로 */
@media (max-width: 639px) {
  .week-picker {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100vw - 32px));
    z-index: 120;
  }
}

.week-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
}
.kpi-chip .kpi-name { font-size: 12px; font-weight: 600; }
.kpi-chip .kpi-num { font-size: 20px; font-weight: 700; }
.kpi-chip.st-todo  .kpi-name { color: var(--st-todo); }
.kpi-chip.st-doing .kpi-name { color: var(--st-doing); }
.kpi-chip.st-done  .kpi-name { color: var(--st-done); }
.kpi-chip.st-late  .kpi-name { color: var(--st-late); }

.week-grid { display: none; gap: 12px; align-items: start; }
.wk-col {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 180px;
}
.wk-col.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wk-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.wk-day { font-size: 13px; font-weight: 700; }
.wk-col.is-today .wk-day { color: var(--accent); }
.wk-date { font-size: 12px; color: var(--muted); }
.wk-count {
  font-size: 11px; font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--muted);
}
.wk-head .icon-btn { margin-left: auto; }

.wk-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 9px 10px;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.wk-card:hover { border-color: var(--accent); }
.wk-card:last-child { margin-bottom: 0; }
.wk-title { font-weight: 500; cursor: pointer; word-break: break-all; margin-bottom: 7px; }
.wk-card.is-done .wk-title { text-decoration: line-through; color: var(--muted); }
.wk-card.is-done { opacity: .62; }
.wk-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wk-note {
  font-size: 12px; color: var(--muted);
  margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wk-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 18px 0; }

.week-list { display: block; }
.wl-day-head { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; }
.wl-day-head.is-today .wl-day-name { color: var(--accent); }
.wl-day-name { font-size: 14px; font-weight: 700; }
.wl-day-date { font-size: 12px; color: var(--muted); }

/* ===== 8. 프로젝트 뷰 ===== */
.proj-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }

.proj-group-head {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  border: none; background: none;
  font-size: 13px; font-weight: 700;
  color: var(--muted);
  margin: 22px 0 10px;
  padding: 0;
  text-align: left;
}
.proj-group-head .chev { transition: transform .15s; display: inline-flex; }
.proj-group-head.open .chev { transform: rotate(0deg); }
.proj-group-head .chev.closed { transform: rotate(-90deg); }

.proj-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.proj-card:hover { border-color: var(--accent); }
.proj-card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.proj-name { font-weight: 600; flex: 1; min-width: 0; word-break: break-all; }
.proj-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.proj-note {
  font-size: 12px; color: var(--muted);
  margin-top: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-tasks-count { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.proj-tasks-count .icon { width: 13px; height: 13px; }

/* ===== 9. 통계 뷰 ===== */
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stats-seg { flex: none; }
.stats-seg .seg-btn { padding: 6px 14px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.metric-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 700; }
.metric-value.c-done { color: var(--st-done); }
.metric-value.c-late { color: var(--st-late); }
.metric-value.c-accent { color: var(--accent); }

.stats-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stats-card h2 { font-size: 14px; font-weight: 700; margin-bottom: 14px; }

.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; position: relative; flex: none; }
.donut::after { content: ''; position: absolute; inset: 21%; background: var(--surface); border-radius: 50%; }
.donut-center {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-center .pct { font-size: 22px; font-weight: 700; }
.donut-center .lbl { font-size: 11px; color: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-item .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-item .num { margin-left: auto; font-weight: 700; padding-left: 16px; }

.bar-row { display: grid; grid-template-columns: 112px 1fr 76px; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.bar-num { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

.sched-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.sched-item:last-child { border-bottom: none; }
.sched-name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-date { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ===== 10. 모달 ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,17,21,.48);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%; max-width: 540px;
  max-height: 90vh; max-height: 90dvh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: popIn .18s;
}
@keyframes popIn { from { transform: scale(.97); opacity: 0; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px 0;
}
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal-foot .spacer { flex: 1; }
.modal-foot .link-ext { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-foot .link-ext:hover { color: var(--accent); }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.linked-tasks { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.linked-task {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: none; border: none;
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  min-height: 42px;
}
.linked-task:last-child { border-bottom: none; }
.linked-task:hover { background: var(--surface2); }
.linked-task .lt-date { font-size: 12px; color: var(--muted); flex: none; }
.linked-task .lt-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-empty { font-size: 13px; color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }

.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.settings-info { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ===== 11. 토스트 ===== */
.toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px;
  z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  animation: toastUp .25s;
  max-width: 100%;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transition: opacity .3s; }
@keyframes toastUp { from { transform: translateY(10px); opacity: 0; } }

/* ===== 12. 로그인 ===== */
.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%; max-width: 360px;
  text-align: center;
}
.login-card.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.login-lock {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 14px;
}
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.login-card .input { margin-bottom: 10px; text-align: center; }
.login-error { font-size: 12px; color: var(--danger); margin: -2px 0 10px; }
/* ===== 13. 모바일 탭바 / FAB ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: none;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: none; background: none;
  color: var(--muted);
  font-size: 10px;
  padding: 0 2px;
  white-space: nowrap;
}
.tab-item .icon { width: 22px; height: 22px; }
.tab-item.active { color: var(--accent); font-weight: 600; }

.fab {
  position: fixed; right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 60;
  width: 56px; height: 56px;
  display: none; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37,99,235,.4);
}
.fab .icon { width: 24px; height: 24px; }
.fab:active { transform: scale(.95); }

/* ===== 14. 반응형 ===== */
/* 태블릿 이상 (>=640px): 헤더 탭 표시, 주간 그리드 */
@media (min-width: 640px) {
  .header-tabs { display: flex; }
  .week-grid { display: grid; }
  .week-list { display: none; }
  .proj-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* 모바일 (<640px) */
@media (max-width: 639px) {
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; }
  .fab { display: flex; }
  .logo-text { display: none; }
  .sync-label { display: none; }
  .icon-btn { width: 44px; height: 44px; }
  .header-tab { min-height: 44px; }

  /* 빠른 추가: 한 줄 컴팩트 input + 작은 추가 버튼 (상세 입력은 FAB 시트) */
  .quick-add { display: flex; gap: 8px; padding: 8px; }
  .quick-add .qa-title { flex: 1; min-width: 0; }
  .quick-add .qa-date,
  .quick-add .qa-chips,
  .quick-add .qa-cat,
  .quick-add .qa-prio { display: none; }
  .quick-add .qa-btn { flex: none; width: 44px; min-width: 44px; padding: 0; }
  .quick-add .qa-btn span { display: none; }
  .quick-add .input, .quick-add .btn { min-height: 44px; }

  /* 주간 리스트 날짜 헤더 sticky (헤더 높이 56px 아래) */
  .wl-day-head {
    position: sticky; top: 56px; z-index: 5;
    background: var(--bg);
    margin: 0; padding: 14px 0 8px;
  }

  .week-kpi { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }

  .check-btn { width: 36px; height: 36px; }
  .task-row { min-height: 56px; }
  .badge { padding: 6px 11px; }

  /* 업무명이 칩·버튼에 밀려 사라지지 않도록 제목을 윗줄 전체로 분리 */
  .task-main { flex-wrap: wrap; row-gap: 3px; }
  .task-main .task-title {
    flex: 1 1 100%;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .field-grid-2 { grid-template-columns: 1fr; }

  /* 하단 시트 모달 */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    border-radius: 16px 16px 0 0;
    max-height: 92vh; max-height: 92dvh;
    animation: sheetUp .25s;
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }

  /* 토스트는 탭바 위 */
  .toast-root { bottom: calc(68px + env(safe-area-inset-bottom) + 12px); }
}

/* 좁은 데스크톱(640~1023): 주간 그리드 가로 스크롤 허용 */
@media (min-width: 640px) and (max-width: 1023px) {
  .week-grid { overflow-x: auto; }
  .wk-col { min-width: 170px; }
}

/* ===== 15. 검색 바 ===== */
.search-bar {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 10px;
}
.search-bar > .icon { color: var(--muted); }
.search-bar .input { flex: 1; }

.search-info-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 12px 0;
}
.search-info-text { font-size: 13px; font-weight: 600; color: var(--accent); }

/* ===== 16. 필터 칩 ===== */
.filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar:empty { display: none; }
.f-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  min-height: 30px;
  color: var(--muted);
  transition: border-color .15s, background .15s, color .15s;
}
.f-chip:hover { border-color: var(--accent); }
.f-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.f-chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.f-chip.f-clear { color: var(--danger); }
.f-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; flex: none; }

/* ===== 17. 보드 뷰 (칸반) ===== */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.board.as-list { display: block; }
.kb-col {
  display: flex; flex-direction: column;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  transition: border-color .15s, box-shadow .15s;
}
.kb-col.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.kb-head {
  display: flex; align-items: center; gap: 7px; flex: none;
  padding: 10px 10px 8px;
}
.kb-head .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.kb-name { font-size: 13px; font-weight: 700; }
.kb-add-head { margin-left: auto; }
.kb-cards { flex: 1; min-height: 0; padding: 0 10px; }
.kb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .15s, opacity .15s;
}
.kb-card:hover { border-color: var(--accent); }
.kb-card.dragging { opacity: .45; transform: rotate(2deg); }
.kb-card.is-done .kb-title { text-decoration: line-through; color: var(--muted); }
.kb-title {
  font-weight: 500; font-size: 13px;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 5px;
}
.kb-meta { display: flex; align-items: center; gap: 7px; min-width: 0; }
.kb-cat {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-cat .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.kb-date { font-size: 12px; color: var(--muted); white-space: nowrap; flex: none; }
.kb-badge-row { margin-top: 7px; }
.kb-empty {
  font-size: 12px; color: var(--muted); text-align: center;
  padding: 20px 8px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  margin-bottom: 7px;
}
.kb-more {
  display: block; width: 100%;
  border: none; background: none;
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  border-radius: 8px;
  padding: 7px;
  margin-bottom: 7px;
}
.kb-more:hover { background: var(--accent-soft); }
.kb-add-foot {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  flex: none;
  border: none; background: none;
  color: var(--muted);
  font-size: 12px; font-weight: 600;
  border-radius: 8px;
  padding: 7px;
  margin: 4px 10px 10px;
  transition: background .15s, color .15s;
}
.kb-add-foot:hover { background: var(--surface); color: var(--accent); }
.kb-add-foot .icon { width: 14px; height: 14px; }

/* 데스크톱·태블릿: 보드 높이 고정 + 열 내부 스크롤 (Trello 방식) */
@media (min-width: 640px) {
  .board:not(.as-list) { height: calc(100dvh - 240px); min-height: 340px; align-items: stretch; }
  .kb-cards { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
  .kb-cards::-webkit-scrollbar { width: 6px; }
  .kb-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  .kb-cards::-webkit-scrollbar-track { background: transparent; }
  /* 열이 곧 상태이므로 카드 상태 배지는 중복 — 데스크톱에서 숨김 */
  .kb-badge-row { display: none; }
}

/* ===== 18. 캘린더 뷰 ===== */
.cal-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cal-head-row { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.cal-dow { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 8px 0; }
.cal-body { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  min-height: 96px;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 6px;
  text-align: left;
  overflow: hidden;
  transition: background .15s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface2); }
.cal-cell.out { opacity: .4; }
.cal-num { font-size: 12px; font-weight: 600; }
.cal-cell.is-today .cal-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  align-self: flex-start;
}
.cal-bars { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-bar {
  font-size: 11px; font-weight: 500;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-bar.done { opacity: .55; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--muted); font-weight: 600; }
.cal-dots { display: none; align-items: center; gap: 3px; }
.cal-dots .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }

/* ===== 19. 단축키 도움말 / 빠른 추가 칩 ===== */
.sc-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sc-row:last-child { border-bottom: none; }
.kbd {
  flex: none; min-width: 64px;
  font-size: 12px; font-weight: 700;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 3px 8px;
}
.sc-desc { font-size: 13px; color: var(--muted); }
.modal-head h2 .icon { width: 16px; height: 16px; margin-right: 2px; }

.qa-chips { display: flex; align-items: center; gap: 5px; }
.qa-chip {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  padding: 5px 11px;
  min-height: 32px;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.qa-chip:hover { border-color: var(--accent); color: var(--accent); }
.qa-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ===== 20. 새 뷰 반응형 ===== */
@media (max-width: 639px) {
  /* 보드: 가로 스크롤 + 스냅 */
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; padding-bottom: 6px; }
  .board.as-list { display: block; }
  .kb-col { flex: none; width: 78vw; max-width: 300px; scroll-snap-align: start; }

  /* 캘린더: 점만 표시 */
  .cal-cell { min-height: 58px; padding: 4px; }
  .cal-bars, .cal-more { display: none; }
  .cal-dots { display: flex; flex-wrap: wrap; }

}

@media (min-width: 640px) and (max-width: 1023px) {
  .board { overflow-x: auto; }
  .kb-col { min-width: 200px; }
  .header-tab { padding: 8px 9px; }
}

/* 모션 최소화 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== 카테고리 관리 모달 ===== */
.cat-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.cat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
}
.cat-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cat-name {
  flex: 1; min-width: 0; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-count { font-size: 12px; color: var(--muted); flex: none; }
.cat-edit-input { flex: 1; min-width: 0; }
.cat-add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-add-row .input { flex: 1; min-width: 140px; }
.cat-color-pick { display: flex; gap: 6px; flex: none; }
.cat-color {
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
  border: 2px solid transparent; cursor: pointer;
}
.cat-color.active { border-color: var(--text); transform: scale(1.15); }
.cat-color:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== 빠른 추가 바텀시트 (FAB) ===== */
.qs-body .qs-title { min-height: 48px; font-size: 15px; }
.qs-chip-row {
  display: flex; gap: 6px;
  overflow-x: auto;
  margin-top: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.qs-chip-row::-webkit-scrollbar { display: none; }
.qs-chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  padding: 8px 14px;
  min-height: 44px;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.qs-chip:hover { border-color: var(--accent); color: var(--accent); }
.qs-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.qs-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.qs-chip .icon-sm { width: 14px; height: 14px; }
.qs-native-date {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  border: 0; padding: 0;
  pointer-events: none;
}

/* ===== 당겨서 새로고침 인디케이터 ===== */
.ptr {
  position: fixed; top: -46px; left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.16);
  display: none; align-items: center; justify-content: center;
  color: var(--muted);
  pointer-events: none;
}
.ptr.show { display: flex; }
.ptr.ready { color: var(--accent); }
.ptr.spinning { transition: transform .15s; }
.ptr.spinning .icon { animation: spin 1s linear infinite; }
