:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

body[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-alt: #1c2028;
  --hover: #20242e;
  --border: #282c36;
  --border-strong: #343a47;
  --text: #e7e9ee;
  --text-muted: #9aa1ac;
  --text-faint: #666d7a;
  --accent: #6366f1;
  --accent-text: #ffffff;
  --danger: #f87171;
  --shadow: 0 8px 24px rgba(0,0,0,0.45);
  --overlay: rgba(0,0,0,0.55);
}

body[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --hover: #f0f1f4;
  --border: #e3e5ea;
  --border-strong: #d3d6dd;
  --text: #1c1e24;
  --text-muted: #5c6270;
  --text-faint: #9198a3;
  --accent: #6366f1;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(0,0,0,0.10);
  --overlay: rgba(15,17,21,0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.brand-title { font-weight: 600; font-size: 14px; line-height: 1.2; }
.save-error { color: var(--danger); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  height: 36px; padding: 0 12px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; background: none; color: var(--text);
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.8; }
.btn-outline { border-color: var(--border); color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border: 1px solid var(--border); }
.btn-icon-primary { width: 36px; height: 36px; padding: 0; justify-content: center; background: var(--accent); color: #fff; border-radius: var(--radius-md); border: none; cursor: pointer; flex-shrink: 0; display: inline-flex; align-items: center; font-size: 16px; }
.icon-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); border: none; background: none; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:hover { opacity: 0.7; }
.icon-btn:disabled { opacity: 0.25; cursor: default; }
.btn-danger-text { color: var(--danger); background: none; border: none; padding: 0 8px; height: 36px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.link-btn { background: none; border: none; color: var(--text-faint); font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; }
.link-btn.danger:hover { color: var(--danger); }
@media (max-width: 640px) { .btn-label { display: none; } }

/* Main / filter bar / board */
.main { max-width: 1280px; margin: 0 auto; padding: 0 24px 40px; }
.filter-bar { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 16px 0 4px; }
.chip {
  flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 12px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chip-add {
  flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px dashed var(--border); background: none; color: var(--text-faint);
  font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}

.board {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px;
}
@media (max-width: 860px) {
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; padding-bottom: 8px; }
  .board-col { min-width: 82vw; flex-shrink: 0; scroll-snap-align: start; }
  .col-body { max-height: none !important; }
}

.board-col {
  display: flex; flex-direction: column;
  border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--surface-alt);
}
.board-col.drag-over { background: var(--hover); }
.col-header { display: flex; align-items: center; justify-content: space-between; padding: 12px; flex-shrink: 0; }
.col-header-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.col-title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-count { color: var(--text-faint); font-size: 12px; }
.col-body { flex: 1; overflow-y: auto; max-height: calc(100vh - 260px); padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.col-empty { color: var(--text-faint); font-size: 12px; text-align: center; padding: 32px 8px; border: 1px dashed var(--border); border-radius: var(--radius-md); }

.card {
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface);
  padding: 12px; cursor: grab;
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-title-area { min-width: 0; flex: 1; cursor: pointer; }
.card-title { font-size: 14px; font-weight: 500; line-height: 1.4; word-break: break-word; }
.card-desc {
  color: var(--text-muted); font-size: 12px; margin-top: 4px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.card-bottom-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-due { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; white-space: nowrap; }
.card-shift { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; z-index: 40; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
@media (max-width: 640px) { .modal-overlay { align-items: flex-end; padding: 0; } }
.modal {
  width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); padding: 20px;
}
@media (max-width: 640px) { .modal { border-bottom-left-radius: 0; border-bottom-right-radius: 0; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.field input[type="text"], .field input[type="date"], .field textarea, .field select {
  width: 100%; padding: 0 12px; height: 40px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); font-size: 14px;
  font-family: inherit;
}
.field textarea { height: auto; padding: 8px 12px; resize: vertical; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; gap: 8px; }
.modal-footer-right { display: flex; align-items: center; gap: 8px; }

/* Category management */
.category-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.category-row { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-alt); }
.category-row .dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.category-row .name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-form-section { border-top: 1px solid var(--border); padding-top: 16px; }
.category-form-section label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; }
.category-form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.category-form-row input[type="text"] { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); font-size: 14px; font-family: inherit; }
.category-form-row input[type="color"] { width: 36px; height: 36px; border: none; padding: 0; border-radius: var(--radius-md); cursor: pointer; flex-shrink: 0; }
.color-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.color-presets button { width: 20px; height: 20px; border-radius: 50%; border: none; cursor: pointer; padding: 0; }
.color-presets button.active { outline: 2px solid var(--text); outline-offset: 2px; }
.manage-footer { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px; display: flex; justify-content: flex-end; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
