* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", sans-serif;
  background: #f4f5f7;
  color: #172b4d;
}
.muted { color: #6b7280; }
a { color: inherit; text-decoration: none; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: #172b4d;
  color: #fff;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: #fff; }
.top-nav { display: flex; gap: 4px; }
.top-nav a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: #c7d2fe;
}
.top-nav a.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.search-form { flex: 1; max-width: 360px; }
.search-form input {
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
}
.logout-form { margin-left: auto; }
.btn-link {
  background: none;
  border: none;
  color: #c7d2fe;
  cursor: pointer;
  font-size: 14px;
}

.content { padding: 20px; }

/* Boards page */
.boards-page h1 { margin-top: 0; }
.new-board-form { display: flex; gap: 8px; margin-bottom: 20px; max-width: 480px; }
.new-board-form input { flex: 1; padding: 8px 10px; border-radius: 6px; border: 1px solid #dfe1e6; }
.new-board-form button, .add-list-form button, .add-card-form-visible button {
  padding: 8px 14px; border-radius: 6px; border: none; background: #6366f1; color: #fff; cursor: pointer;
}
.board-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.board-card {
  width: 200px;
  height: 100px;
  background: #fff;
  border-radius: 8px;
  border-top: 4px solid #6366f1;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  font-weight: 600;
  text-align: center;
}

.section-heading { margin: 28px 0 12px; font-size: 16px; color: #6b7280; }
.recent-list { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.recent-item {
  background: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.recent-item-title { font-weight: 600; font-size: 14px; }
.recent-item-meta { font-size: 12px; color: #6b7280; }

/* Notes page */
.notes-page h1 { margin-top: 0; }
.new-note-form { max-width: 480px; margin-bottom: 20px; }
.new-note-form input { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid #dfe1e6; font-size: 14px; }
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.note-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  cursor: pointer;
  position: relative;
  min-height: 90px;
}
.note-pinned { border-left: 3px solid #f59e0b; }
.note-card-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding-right: 16px; }
.note-card-preview { font-size: 12px; color: #6b7280; white-space: pre-wrap; word-break: break-word; }

/* Board page */
.board-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.board-title { margin: 0; font-size: 22px; }
.back-link { color: #6366f1; font-weight: 600; }
.btn-danger-link { background: none; border: none; color: #dc2626; cursor: pointer; margin-left: auto; font-size: 13px; }

.board-lists {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 20px;
}
.list {
  background: #ebecf0;
  border-radius: 8px;
  width: 260px;
  flex: 0 0 260px;
  padding: 8px;
}
.list-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 8px; font-weight: 600; }
.list-name[data-editable] { cursor: text; }
.list-count { color: #6b7280; font-size: 12px; }
.list-cards { min-height: 10px; display: flex; flex-direction: column; gap: 8px; }

.card {
  background: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,.15);
  cursor: pointer;
  position: relative;
}
.card-pinned { border-left: 3px solid #f59e0b; }
.pin-badge { position: absolute; top: 4px; right: 6px; font-size: 12px; }
.card-title { font-size: 14px; word-break: break-word; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag-chip {
  background: #e0e7ff;
  color: #3730a3;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
}
.card-meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.card-meta { font-size: 11px; color: #6b7280; }
.due-badge.due-today { color: #b45309; font-weight: 600; }
.due-badge.due-overdue { color: #dc2626; font-weight: 600; }
.sortable-ghost { opacity: .4; }

.add-card-form, .add-list-form { margin-top: 6px; }
.add-card-form input, .add-list-form input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px;
  font-size: 13px;
}
.add-card-form input:focus, .add-list-form input:focus { background: #fff; border-radius: 4px; outline: 1px solid #c7c9ce; }
.add-list-form {
  background: rgba(255,255,255,.4);
  border-radius: 8px;
  width: 260px;
  flex: 0 0 260px;
  padding: 8px;
}

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #172b4d; }
.login-card { background: #fff; padding: 32px; border-radius: 10px; width: 320px; text-align: center; }
.login-card h1 { margin: 0 0 4px; }
.login-card input { width: 100%; padding: 10px; margin: 14px 0; border-radius: 6px; border: 1px solid #dfe1e6; }
.login-card button { width: 100%; padding: 10px; border-radius: 6px; border: none; background: #6366f1; color: #fff; cursor: pointer; font-weight: 600; }
.alert { background: #fee2e2; color: #b91c1c; padding: 8px; border-radius: 6px; font-size: 13px; }

/* Search */
.search-results { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.search-result { background: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.search-result-title { font-weight: 600; }
.search-result-meta { font-size: 12px; color: #6b7280; margin: 4px 0; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 560px;
  padding: 0;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
}
.card-modal-title { flex: 1; font-size: 16px; font-weight: 600; border: none; outline: none; }
.pin-toggle { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .4; }
.pin-toggle.active { opacity: 1; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 16px; }
.modal-body { padding: 16px; max-height: 60vh; overflow-y: auto; }
.modal-label { display: block; font-size: 12px; font-weight: 600; color: #6b7280; margin: 14px 0 6px; text-transform: uppercase; }
.modal-label:first-child { margin-top: 0; }
#card-modal-content { width: 100%; border-radius: 6px; border: 1px solid #dfe1e6; padding: 8px; font-family: inherit; font-size: 14px; }
.link-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.link-row a { color: #6366f1; text-decoration: underline; word-break: break-all; flex: 1; }
.link-row button { background: none; border: none; color: #dc2626; cursor: pointer; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 100px; padding: 6px 8px; border-radius: 6px; border: 1px solid #dfe1e6; font-size: 13px; }
.inline-form button { padding: 6px 10px; border-radius: 6px; border: none; background: #6366f1; color: #fff; cursor: pointer; font-size: 13px; }
.tag-chip-removable { display: inline-flex; align-items: center; gap: 4px; }
.tag-chip-removable button { background: none; border: none; color: #3730a3; cursor: pointer; font-size: 11px; }
.modal-footer { display: flex; justify-content: space-between; padding: 12px 16px; border-top: 1px solid #eee; }
.modal-footer #card-modal-save { padding: 8px 16px; border-radius: 6px; border: none; background: #6366f1; color: #fff; cursor: pointer; font-weight: 600; }

.due-date-row { display: flex; align-items: center; gap: 10px; }
.due-date-row input[type="date"] { padding: 6px 8px; border-radius: 6px; border: 1px solid #dfe1e6; font-size: 13px; }
.btn-link-small { background: none; border: none; color: #6366f1; cursor: pointer; font-size: 12px; }

.checklist-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.checklist-row span { flex: 1; }
.checklist-row .checklist-done { text-decoration: line-through; color: #9ca3af; }
.checklist-row button { background: none; border: none; color: #dc2626; cursor: pointer; }
