*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --col-bg: #e2e8f0;
  --primary: #4f6ef7;
  --primary-hover: #3d5ce8;
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --text: #1a202c;
  --text-muted: #718096;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.25);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── Header ── */
header {
  background: #1a1a2e;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: #90b4ff;
  cursor: pointer;
  letter-spacing: .3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

#username-display {
  font-size: .85rem;
  color: #8899bb;
}

/* ── Buttons ── */
button { cursor: pointer; border: none; font-family: inherit; font-size: .9rem; transition: background .15s, color .15s; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: #edf2f7;
  color: #4a5568;
  padding: .5rem 1rem;
  border-radius: var(--radius);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost {
  background: none;
  color: #555;
  padding: .35rem .65rem;
  border-radius: var(--radius);
}
.btn-ghost:hover { background: rgba(0,0,0,.07); }

.btn-ghost-light {
  background: none;
  color: #8899bb;
  padding: .35rem .65rem;
  border-radius: var(--radius);
}
.btn-ghost-light:hover { background: rgba(255,255,255,.1); color: #fff; }

.w-full { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-size: .82rem; font-weight: 500; color: #4a5568; margin-bottom: .3rem; }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
  color: var(--text);
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { min-height: 90px; resize: vertical; }

.error-msg {
  background: #fff5f5;
  color: var(--danger);
  font-size: .83rem;
  padding: .45rem .65rem;
  border-radius: var(--radius);
  margin-bottom: .75rem;
}

/* ── Views ── */
.view { padding: 1.25rem 1.5rem; }
.hidden { display: none !important; }

/* ── Login ── */
#view-login {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 52px);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 1.75rem;
  letter-spacing: .3px;
}

/* ── Home ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-header h2 { font-size: 1.3rem; }

.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .9rem;
}

.board-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 1.1rem 1.1rem 1rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  position: relative;
}
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.board-card h3 { font-size: 1rem; margin-bottom: .3rem; }
.board-date { font-size: .76rem; color: var(--text-muted); }
.board-delete {
  position: absolute;
  top: .6rem;
  right: .6rem;
  background: none;
  color: #ccc;
  font-size: 1.1rem;
  padding: .15rem .4rem;
  border-radius: 4px;
  line-height: 1;
}
.board-delete:hover { background: #fee2e2; color: var(--danger); }

.empty-state { color: var(--text-muted); padding: 2rem 0; }

/* ── Board ── */
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}
.board-header-left { display: flex; align-items: center; gap: .6rem; }
.board-header-right { display: flex; align-items: center; gap: .6rem; }
.board-header h2 { font-size: 1.2rem; }

.filter-label {
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-select {
  padding: .38rem .65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--primary); }

.columns-container {
  display: flex;
  gap: .9rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
  min-height: calc(100vh - 170px);
}

/* ── Column ── */
.column {
  background: var(--col-bg);
  border-radius: 10px;
  width: 272px;
  min-width: 272px;
  max-height: calc(100vh - 170px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .75rem .4rem;
}

.col-drag-handle {
  color: #b0bec5;
  font-size: 1rem;
  cursor: grab;
  padding: .1rem .25rem;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.col-drag-handle:hover { color: #718096; background: rgba(0,0,0,.07); }
.col-drag-handle:active { cursor: grabbing; }

.column.column-ghost { opacity: .35; }
.column.column-chosen { box-shadow: var(--shadow-md); }

.column-title {
  font-weight: 600;
  font-size: .9rem;
  color: #2d3748;
  cursor: pointer;
  padding: .1rem .3rem;
  border-radius: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-title:hover { background: rgba(0,0,0,.07); }

.col-btns { display: flex; gap: .15rem; }
.col-btn {
  background: none;
  color: #94a3b8;
  font-size: .85rem;
  padding: .2rem .45rem;
  border-radius: 4px;
}
.col-btn:hover { background: rgba(0,0,0,.1); color: #4a5568; }

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: .3rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  min-height: 48px;
}

.add-note-btn {
  display: block;
  width: calc(100% - 1rem);
  margin: .35rem .5rem .6rem;
  padding: .45rem .6rem;
  background: rgba(0,0,0,.05);
  border-radius: 6px;
  text-align: left;
  color: #718096;
  font-size: .83rem;
}
.add-note-btn:hover { background: rgba(0,0,0,.1); color: #4a5568; }

/* ── Note ── */
.note {
  background: var(--surface);
  border-radius: 7px;
  padding: .65rem .7rem;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  position: relative;
  transition: box-shadow .15s;
}
.note:hover { box-shadow: var(--shadow-md); }
.note.sortable-ghost { opacity: .35; }
.note.sortable-chosen { cursor: grabbing; }

.note-title {
  font-weight: 600;
  font-size: .88rem;
  color: #2d3748;
  word-break: break-word;
  margin-bottom: .25rem;
}

.note-content {
  font-size: .8rem;
  color: #718096;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.note-actions {
  display: flex;
  gap: .2rem;
  margin-top: .45rem;
}

.note-action-btn {
  background: none;
  color: #a0aec0;
  font-size: .75rem;
  padding: .15rem .4rem;
  border-radius: 4px;
}
.note-action-btn:hover { background: #f0f0f0; color: #4a5568; }
.note-action-btn.danger:hover { background: #fee2e2; color: var(--danger); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-large {
  width: 75vw;
  max-width: 75vw;
  height: 75vh;
  max-height: 75vh;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}
.modal-large .modal-body {
  flex: 1;
  min-height: 0;
  padding: 0;
}

.modal-split {
  display: flex;
  height: 100%;
}

.modal-split-main {
  flex: 2;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 1rem 1.25rem;
  min-width: 0;
  min-height: 0;
}
.modal-split-main .form-group:has(textarea) {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.modal-split-main textarea {
  flex: 1;
  min-height: 0;
  resize: none;
}

.modal-split-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem 1rem 1rem;
  border-left: 1px solid var(--border);
  min-width: 0;
  overflow-y: auto;
}

.color-list-label {
  font-size: .82rem;
  font-weight: 500;
  color: #4a5568;
  margin-bottom: .5rem;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.category-list-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text);
  transition: background .1s;
}
.category-list-item input { display: none; }
.category-list-item:hover { background: rgba(0,0,0,.05); }
.category-list-item.selected { background: rgba(79,110,247,.08); }

.category-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}
.category-list-item.selected .category-dot {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem .2rem;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  color: #aaa;
  font-size: 1.4rem;
  line-height: 1;
  padding: .1rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { background: #f0f0f0; color: #333; }

.modal-body { padding: 1rem 1.25rem .5rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: .75rem 1.25rem 1.25rem;
}

/* ── Note category dots (footer) ── */
.note-cat-dots {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-left: auto;
}

.note-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.2);
  flex-shrink: 0;
}

/* ── Misc ── */
p.muted { color: var(--text-muted); }
