:root {
  --bg: #fdf7f9;
  --bg-gradient: linear-gradient(135deg, #fdf7f9 0%, #f4f0ff 100%);
  --surface: #ffffff;
  --surface-2: #faf5f9;
  --text: #3d3540;
  --text-dim: #9b8fa3;
  --accent: #d97ba8;
  --accent-2: #9b7fd4;
  --accent-gradient: linear-gradient(135deg, #e89bbd 0%, #b59ce0 100%);
  --border: #f0e4ee;
  --danger: #e56b7a;
  --shadow-sm: 0 2px 6px rgba(200, 160, 190, 0.12);
  --shadow: 0 6px 20px rgba(200, 160, 190, 0.18);
  --shadow-lg: 0 14px 40px rgba(160, 130, 180, 0.22);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-pill: 999px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1823;
    --bg-gradient: linear-gradient(135deg, #1c1823 0%, #221c2c 100%);
    --surface: #272130;
    --surface-2: #302838;
    --text: #f0e9f2;
    --text-dim: #a698b0;
    --accent: #e89bbd;
    --accent-2: #b59ce0;
    --accent-gradient: linear-gradient(135deg, #d47fa4 0%, #9d7fd4 100%);
    --border: #3a3144;
    --danger: #f08291;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.45);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Nunito", Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}
#app { height: 100%; }
input, textarea, button { font-family: inherit; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px 30px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: none;
}
.auth-card h1 {
  margin: 6px 0 22px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}
.auth-card h1::after {
  content: " 🌸";
  font-size: 20px;
}
.auth-card input {
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 12px;
  font-size: 15px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color .2s, background .2s;
}
.auth-card input::placeholder { color: var(--text-dim); }
.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(217, 123, 168, 0.12);
}

/* ---------- buttons ---------- */
.btn {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: var(--accent-gradient);
  color: #fff;
  transition: transform .12s ease, box-shadow .2s ease, opacity .15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); transform: none; }
.btn-block { width: 100%; }
.btn-pill { border-radius: var(--radius-pill); }

.auth-switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--text-dim); }
.auth-switch a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1.5px dashed transparent;
  transition: border-color .2s;
}
.auth-switch a:hover { border-color: var(--accent); }
.error { color: var(--danger); font-size: 13.5px; margin: -2px 0 12px; min-height: 18px; text-align: center; font-weight: 500; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar h1::before { content: "📋 "; }
.topbar .user { font-size: 14px; color: var(--text-dim); display: flex; gap: 14px; align-items: center; }
.topbar .user span::before { content: "🌷 "; }
.topbar .user button { font-size: 13px; padding: 7px 14px; border-radius: var(--radius-pill); }

/* ---------- board ---------- */
.board-wrap {
  display: flex;
  gap: 16px;
  padding: 20px;
  overflow-x: auto;
  height: calc(100vh - 61px);
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.board-wrap::-webkit-scrollbar { height: 8px; }
.board-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  width: 300px;
  min-width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.column-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.column-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background .15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-head h2:hover { background: var(--surface-2); }
.column-head .count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.column-head .actions { display: flex; gap: 2px; }
.column-head .actions button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
  transition: background .15s, color .15s;
}
.column-head .actions button:hover { background: var(--surface-2); color: var(--danger); }

.cards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 50px;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.cards::-webkit-scrollbar { width: 6px; }
.cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.45;
  cursor: grab;
  word-wrap: break-word;
  touch-action: none;
  user-select: none;
  transition: transform .12s ease, box-shadow .2s, border-color .15s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: .5; transform: scale(1.02); box-shadow: var(--shadow); }
.card.drop-target { border-color: var(--accent); }

.add-card {
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--text-dim);
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-top: 10px;
  width: 100%;
  transition: background .15s, border-color .15s, color .15s;
}
.add-card:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
}
.add-column {
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--text-dim);
  padding: 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  width: 300px;
  min-width: 300px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.add-column:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 70, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 26px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: popIn .18s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 { margin: 0 0 18px; font-size: 18px; font-weight: 700; }
.modal input, .modal textarea {
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 12px;
  font-size: 15px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.modal textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.modal input:focus, .modal textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(217, 123, 168, 0.12);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .board-wrap { padding: 12px; gap: 12px; height: calc(100vh - 57px); }
  .column { width: 86vw; min-width: 86vw; border-radius: 18px; }
  .add-column { width: 86vw; min-width: 86vw; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .topbar .user span { display: none; }
  .modal { padding: 22px; border-radius: 18px; }
  .modal-actions .btn { flex: 1; }
}
