:root {
  --bg: #F5F2EC;
  --surface: #FFFFFF;
  --list-bg: #ECE7DD;
  --ink: #2A241D;
  --muted: #857C6E;
  --line: #DDD5C6;
  --accent: #3E6B4F;
  --on-accent: #F5F2EC;
  --danger: #C24A38;
  --danger-bg: #F7E3DF;
  --shadow: 0 1px 3px rgba(42, 36, 29, 0.10), 0 1px 2px rgba(42, 36, 29, 0.06);
  --shadow-lift: 0 8px 24px rgba(42, 36, 29, 0.18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201C16;
    --surface: #2C2620;
    --list-bg: #272219;
    --ink: #EDE6DA;
    --muted: #9C9182;
    --line: #3B342A;
    --accent: #82B393;
    --on-accent: #1E2B22;
    --danger: #E07A66;
    --danger-bg: #43281F;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
#app-view { height: 100%; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; }
input { font: inherit; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── 로그인 ─────────────────────────── */
.login-view {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 30px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-title { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; }
.login-sub { color: var(--muted); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 8px; }
.login-card input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
  margin-bottom: 8px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-error { color: var(--danger); font-size: 13px; }
.btn-block { width: 100%; padding: 11px; margin-top: 6px; }

/* ── 상단 바 ─────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.logo-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.logo-mark-lg { width: 40px; height: 40px; border-radius: 10px; }
.boards {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.board-tab {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}
.board-tab:hover { background: var(--list-bg); }
.board-tab.active {
  background: var(--list-bg);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.board-tab.new { font-weight: 400; }
.board-tab .tab-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.board-tab.dash-tab {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 4px;
  flex-shrink: 0;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.help-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}
.help-link:hover { background: var(--list-bg); color: var(--ink); }
.members { display: flex; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--surface);
  flex-shrink: 0;
}
.members .avatar:not(:first-child) { margin-left: -7px; }
.me-btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 600;
}
.me-btn:hover { background: var(--list-bg); }
.me-btn .avatar { width: 24px; height: 24px; font-size: 11px; border: none; }

/* ── 보드 영역 ─────────────────────────── */
.board {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px 24px;
  overflow-x: auto;
  overflow-y: hidden;
}
.empty-board {
  margin: auto;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.list {
  background: var(--list-bg);
  border-radius: 12px;
  width: 276px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  border: 1px solid var(--line);
}
.list.dragging-list { opacity: 0.5; }
.list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 6px 14px;
  cursor: grab;
}
.list-title { font-weight: 700; font-size: 14px; min-width: 0; }
.list-title-input {
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 7px;
  background: var(--surface);
  width: 100%;
  min-width: 0;
}
.list-title-input:focus { outline: none; }
.list-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.list-menu-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 15px;
  line-height: 1.3;
}
.list-menu-btn:hover { background: rgba(127, 127, 127, 0.12); color: var(--ink); }
.cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 10px 8px;
  overflow-y: auto;
  min-height: 24px;
}
.list.drop-target { border-color: var(--accent); }

.card {
  background: var(--surface);
  border-radius: 9px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.card:hover { border-color: var(--line); }
.card:active { cursor: grabbing; }
.card.dragging {
  opacity: 0.45;
  transform: rotate(2deg);
  box-shadow: var(--shadow-lift);
}
.card-labels { display: flex; gap: 5px; flex-wrap: wrap; }
.label { height: 7px; width: 34px; border-radius: 4px; }
.lb-red { background: #D9594C; }
.lb-orange { background: #E08A3C; }
.lb-yellow { background: #D3AE3E; }
.lb-green { background: #5FA560; }
.lb-blue { background: #4E86C6; }
.lb-purple { background: #9A6FB8; }
.card-title { font-weight: 500; overflow-wrap: anywhere; }
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.card.completed { background: #383028; border-color: transparent; }
.card.completed:hover { border-color: var(--line); }
.card.completed .card-title {
  color: #A89C8A;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.card.completed .card-top,
.card.completed .card-meta { opacity: 0.55; }
@media (prefers-color-scheme: dark) {
  .card.completed { background: #171410; }
  .card.completed .card-title { color: #857C6E; }
}
.desc-icon { color: var(--muted); font-size: 12px; line-height: 1; }
.card-meta { display: flex; align-items: center; gap: 8px; min-height: 0; }
.card-meta:empty { display: none; }
.due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--on-accent);
  background: var(--accent);
  padding: 2px 9px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  white-space: nowrap;
}
.due.overdue {
  background: var(--danger);
  color: #FFF6F2;
}
.card-meta .avatar {
  width: 24px; height: 24px;
  font-size: 11px;
  border: none;
}
.card-meta .assignee-group { margin-left: auto; display: flex; }
.card-meta .assignee-group .avatar:not(:first-child) { margin-left: -6px; }
.add-card {
  border: none;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 9px 14px 11px;
  border-radius: 0 0 12px 12px;
  cursor: pointer;
}
.add-card:hover { color: var(--ink); background: rgba(127, 127, 127, 0.08); }
.add-input { display: none; margin: 2px 10px 10px; }
.add-input input {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--surface);
}
.add-input input:focus { outline: none; }
.list.adding .add-input { display: block; }
.list.adding .add-card { display: none; }

.add-list {
  flex-shrink: 0;
  width: 276px;
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 12px;
  padding: 13px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.add-list:hover { color: var(--ink); border-color: var(--muted); }

/* ── 대시보드 ─────────────────────────── */
.dash {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}
.dash-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dash-columns {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.dash-columns .list { max-height: 46vh; }
.dash-columns .cards { padding-bottom: 12px; }
.dash-board-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.dash-board-tag .tag-dot {
  width: 8px; height: 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── 캘린더 ─────────────────────────── */
.calendar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.calendar .cal-grid { min-height: 420px; }
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.cal-nav { display: flex; gap: 4px; }
.cal-title { font-size: 17px; font-weight: 800; margin: 0 auto 0 6px; }
.cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: var(--list-bg);
  overflow: hidden;
}
.cal-head span {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 0;
}
.cal-head span.sun { color: var(--danger); }
.cal-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(96px, 1fr);
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  background: var(--surface);
  overflow-y: auto;
  min-height: 0;
}
.cal-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other { background: var(--list-bg); }
.cal-cell.other .cal-day { opacity: 0.45; }
.cal-day {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  align-self: flex-end;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.cal-cell.today .cal-day { background: var(--accent); color: var(--on-accent); }
.cal-entry {
  border: none;
  text-align: left;
  background: var(--list-bg);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-entry:hover { filter: brightness(0.96); }
.cal-entry.done {
  text-decoration: line-through;
  color: var(--muted);
  opacity: 0.7;
}

/* ── 모달 ─────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: min(470px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: var(--shadow-lift);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; }
.modal-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.modal-title { font-size: 17px; font-weight: 700; margin: 0; text-wrap: balance; }
.modal-title-input {
  font-size: 17px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 8px;
  margin-left: -8px;
  background: transparent;
  width: 100%;
}
.modal-title-input:hover { border-color: var(--line); }
.modal-title-input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.modal-sub { color: var(--muted); font-size: 12px; }
.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--list-bg); color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px 4px 5px;
  cursor: pointer;
  color: var(--muted);
}
.chip .avatar { width: 20px; height: 20px; font-size: 10px; border: none; }
.chip.on {
  border-color: var(--accent);
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.label-chip {
  width: 44px;
  height: 26px;
  border-radius: 7px;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.55;
}
.label-chip.on { opacity: 1; border-color: var(--ink); }
.due-row { display: flex; gap: 8px; align-items: center; }
.date-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--bg);
  width: fit-content;
}
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--danger); }
.btn-ghost:hover { background: var(--danger-bg); }
.btn-subtle { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-subtle:hover { background: var(--list-bg); color: var(--ink); }
.btn-complete { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-complete:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn-complete.undone { color: var(--muted); border-color: var(--line); }
.desc-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  resize: vertical;
  min-height: 80px;
}
.desc-input:focus { outline: none; border-color: var(--accent); }
.modal-title-input.done { text-decoration: line-through; color: var(--muted); }
.ical-row { display: flex; gap: 8px; }
.ical-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.ical-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ical-steps b { color: var(--ink); }

/* ── 멤버 관리 ─────────────────────────── */
.member-list { display: flex; flex-direction: column; gap: 4px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 9px;
}
.member-row:hover { background: var(--list-bg); }
.member-name { font-weight: 600; }
.member-username { color: var(--muted); font-size: 12px; }
.member-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
}
.member-actions { margin-left: auto; display: flex; gap: 4px; }
.member-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.member-form-grid { display: flex; flex-direction: column; gap: 8px; }
.member-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--bg);
}
.member-form input:focus { outline: none; border-color: var(--accent); }
.color-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.color-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.color-dot.on { border-color: var(--ink); }

/* ── 메뉴 팝오버 / 토스트 ─────────────────────────── */
.menu {
  position: fixed;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 5px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
}
.menu button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.menu button:hover { background: var(--list-bg); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-bg); }
.menu .menu-head {
  padding: 6px 12px 4px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--ink);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lift);
  max-width: min(90vw, 480px);
}
