:root {
  color-scheme: dark;
  --bg: #070b18;
  --bg-2: #0d1328;
  --panel: rgba(20, 28, 56, 0.62);
  --panel-solid: #131a33;
  --card: rgba(30, 40, 76, 0.78);
  --card-hover: rgba(40, 52, 96, 0.9);
  --line: rgba(148, 163, 255, 0.14);
  --line-strong: rgba(148, 163, 255, 0.3);
  --text: #e8ecff;
  --muted: #94a0c8;
  --cyan: #38bdf8;
  --violet: #a78bfa;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --grad: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(129, 140, 248, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(129, 140, 248, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at top, #000 30%, transparent 75%);
}
.bg-glow {
  position: fixed; inset: -20% -10% auto; height: 70vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(56, 189, 248, 0.18), transparent 70%),
    radial-gradient(40% 50% at 80% 20%, rgba(192, 132, 252, 0.18), transparent 70%);
  filter: blur(20px);
}

/* ---------- 상단 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px clamp(16px, 3vw, 36px) 10px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  width: 46px; height: 46px; flex: none; border-radius: 13px; padding: 9px 8px;
  display: flex; gap: 4px; align-items: flex-start;
  background: linear-gradient(160deg, #18213f, #0b1020);
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 24px rgba(129, 140, 248, 0.35);
}
.logo span { flex: 1; border-radius: 3px; }
.logo span:nth-child(1) { height: 100%; background: var(--cyan); }
.logo span:nth-child(2) { height: 72%; background: var(--violet); }
.logo span:nth-child(3) { height: 44%; background: var(--green); }
.brand h1 {
  margin: 0; font-size: clamp(20px, 2.4vw, 26px); font-weight: 900; letter-spacing: -0.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  outline: none; border-radius: 6px; padding: 0 4px; margin-left: -4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw;
}
.brand h1:focus { box-shadow: 0 0 0 2px var(--line-strong); }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  border: 1px solid transparent; border-radius: 11px; padding: 9px 16px; font-weight: 700; font-size: 14px;
  transition: transform .15s, background .2s, box-shadow .2s, border-color .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: #0b1020; box-shadow: 0 6px 20px rgba(129, 140, 248, 0.35); }
.btn.primary:hover { box-shadow: 0 8px 28px rgba(129, 140, 248, 0.55); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--line-strong); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.09); }
.btn.danger { background: var(--red); color: #1a0606; }
.btn.danger-ghost { background: transparent; border-color: rgba(248, 113, 113, 0.5); color: var(--red); }
.btn.danger-ghost:hover { background: rgba(248, 113, 113, 0.12); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 230px; padding: 6px;
  background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 9px;
  padding: 9px 12px; font-size: 14px;
}
.menu button:hover { background: rgba(255, 255, 255, 0.07); }
.menu .danger { color: var(--red); }

/* ---------- 요약 ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  padding: 8px clamp(16px, 3vw, 36px);
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  backdrop-filter: blur(12px); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cyan); }
.stat.warn::before { background: var(--amber); }
.stat.danger::before { background: var(--red); }
.stat:nth-child(2)::before { background: var(--violet); }
.stat-label { display: block; color: var(--muted); font-size: 12px; }
.stat strong { font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }
.stat.warn strong { color: var(--amber); }
.stat.danger strong { color: var(--red); }
.bar { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: inherit; transition: width .5s; }

/* ---------- 필터 ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px clamp(16px, 3vw, 36px);
}
.search {
  display: flex; align-items: center; gap: 8px; flex: 0 1 280px; min-width: 180px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 0 12px;
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 9px 0; }
.toolbar select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px; outline: none;
}
.toolbar select option, .field select option { background: var(--panel-solid); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); font-size: 13px; font-weight: 500;
  transition: background .2s, border-color .2s;
}
.chip:hover { background: rgba(255, 255, 255, 0.08); }
.chip.on { border-color: var(--cyan); background: rgba(56, 189, 248, 0.14); }
.chip.all { padding-left: 12px; }
.chip .n { color: var(--muted); font-size: 12px; }

.avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 900; color: #0b1020;
}
.avatar.lg { width: 34px; height: 34px; font-size: 14px; }

/* ---------- 보드 ---------- */
.board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
  padding: 10px clamp(16px, 3vw, 36px) 24px; align-items: start;
}
.column {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); display: flex; flex-direction: column; min-height: 420px;
  transition: border-color .2s, box-shadow .2s;
}
.column.drop-target { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 30px rgba(56, 189, 248, 0.25); }
.col-head {
  display: flex; align-items: center; gap: 9px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line);
}
.col-head h2 { margin: 0; font-size: 16px; font-weight: 800; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.todo { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.dot.doing { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.dot.done { background: var(--green); box-shadow: 0 0 10px var(--green); }
.count {
  font-size: 12px; font-weight: 700; color: var(--muted); background: rgba(255, 255, 255, 0.06);
  border-radius: 99px; padding: 1px 9px;
}
.col-add {
  margin-left: auto; width: 30px; height: 30px; border-radius: 9px; border: 1px dashed var(--line-strong);
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
}
.col-add:hover { color: var(--text); border-color: var(--cyan); background: rgba(56, 189, 248, 0.1); }
.list { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 120px; }
.empty {
  border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 26px 12px; text-align: center;
  color: var(--muted); font-size: 13px;
}

/* ---------- 카드 ---------- */
.card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 13px 11px 15px; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  transition: background .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--muted);
}
.card.p-high::before { background: var(--red); }
.card.p-mid::before { background: var(--amber); }
.card.p-low::before { background: var(--green); }
.card:hover { background: var(--card-hover); border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.card:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.card.is-done .card-title { text-decoration: line-through; color: var(--muted); }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; margin: 0; font-size: 14.5px; font-weight: 700; word-break: break-word; }
.prio-tag { flex: none; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.prio-tag.high { background: rgba(248, 113, 113, 0.16); color: var(--red); }
.prio-tag.mid { background: rgba(251, 191, 36, 0.14); color: var(--amber); }
.prio-tag.low { background: rgba(52, 211, 153, 0.14); color: var(--green); }
.card-desc {
  margin: 6px 0 0; color: var(--muted); font-size: 13px; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); min-width: 0; }
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due {
  flex: none; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.06); color: var(--muted);
}
.due.soon { background: rgba(251, 191, 36, 0.16); color: var(--amber); }
.due.today { background: rgba(251, 146, 60, 0.2); color: #fb923c; }
.due.over { background: rgba(248, 113, 113, 0.18); color: var(--red); }
.due.ok { background: rgba(52, 211, 153, 0.12); color: var(--green); }

.move-btns { display: none; gap: 6px; margin-top: 10px; }
.move-btns button {
  flex: 1; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04); border-radius: 8px;
  padding: 5px 0; font-size: 12px; font-weight: 700;
}

/* 드래그 */
.card.placeholder {
  background: rgba(56, 189, 248, 0.08); border: 1.5px dashed var(--cyan); box-shadow: none; transform: none;
}
.card.placeholder > * { visibility: hidden; }
.card.dragging {
  position: fixed; z-index: 100; pointer-events: none; cursor: grabbing; margin: 0;
  transform: rotate(2.5deg) scale(1.03); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--cyan);
  background: var(--card-hover); transition: none;
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- 모달 ---------- */
.modal {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 18px;
  background: var(--panel-solid); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal.small { width: min(400px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(3, 6, 15, 0.7); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 900; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; width: 32px; height: 32px; border-radius: 8px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.modal-body { padding: 10px 20px; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px 18px; }
.spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.field em { color: var(--red); font-style: normal; }
.field input, .field select, .field textarea, .member-add input {
  width: 100%; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .member-add input:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}
.field input[type="date"] { color-scheme: dark; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-strong); border-radius: 10px; padding: 3px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg b { display: block; text-align: center; padding: 7px 0; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg input:checked + b { background: rgba(129, 140, 248, 0.25); color: var(--text); }
.seg input:focus-visible + b { outline: 2px solid var(--cyan); }
.form-error { color: var(--red); font-size: 13px; min-height: 1em; margin: 0; }

.member-add { display: flex; gap: 8px; margin-bottom: 14px; }
.member-add input[name="name"] { flex: 1.2; }
.member-add input[name="role"] { flex: 1; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; }
.member-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 12px; background: rgba(255, 255, 255, 0.03);
}
.member-list .info { flex: 1; min-width: 0; }
.member-list .info b { display: block; font-size: 14px; }
.member-list .info small { color: var(--muted); font-size: 12px; }
.member-list .del { background: none; border: 0; color: var(--muted); border-radius: 8px; padding: 6px 8px; }
.member-list .del:hover { color: var(--red); background: rgba(248, 113, 113, 0.1); }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* ---------- 토스트 / 푸터 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel-solid); border: 1px solid var(--line-strong); padding: 10px 18px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 14px; transition: opacity .25s, transform .25s; z-index: 200;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.footer { text-align: center; padding: 8px 16px 30px; color: var(--muted); font-size: 12px; }
.footer p { margin: 4px 0; }
.footer .copy { color: #b7c0e6; font-weight: 500; letter-spacing: 0.01em; }

/* ---------- 반응형 ---------- */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: 1fr; }
  .column { min-height: 0; }
}
@media (hover: none) {
  .move-btns { display: flex; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .member-add { flex-wrap: wrap; }
  .member-add input { flex: 1 1 100% !important; }
  .member-add .btn { width: 100%; }
  .top-actions { width: 100%; }
  .top-actions .btn.primary { margin-left: auto; }
  .search { flex: 1 1 100%; }
  .chips { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chip { flex: none; }
  .toolbar select { flex: 1 1 100%; }
}

/* ---------- 공유 보드: 연결 상태 · 관리자 ---------- */
.conn {
  display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; padding: 1px 9px 1px 7px;
  border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: rgba(255, 255, 255, 0.06); color: var(--muted); vertical-align: 1px;
}
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.conn[data-state="live"] { background: rgba(52, 211, 153, 0.14); color: var(--green); }
.conn[data-state="live"]::before { box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.conn[data-state="off"] { background: rgba(248, 113, 113, 0.14); color: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.admin-why { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; white-space: pre-line; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--violet); }
.loading { color: var(--muted); font-size: 13px; text-align: center; padding: 26px 12px; }
.loading::before {
  content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 10px; border-radius: 50%;
  border: 2.5px solid var(--line-strong); border-top-color: var(--cyan); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .conn::before, .loading::before { animation: none !important; } }
