:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f242e;
  --border: #2a3038;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --accent: #4c8dff;
  --accent-d: #2f6fe0;
  --danger: #ff5d6c;
  --ok: #3ddc84;
  --warn: #ffb648;
  --ready: #3ddc84;
  --running: #4c8dff;
  --blocked: #ff5d6c;
  --todo: #9aa3b2;
  --scheduled: #b07cff;
  --review: #ffb648;
  --triage: #ff8a3d;
  --done: #6b7280;
  --radius: 12px;
  --shadow: 0 4px 14px rgba(0,0,0,0.35);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  /* respect notches */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.topbar__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.topbar__actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); border-color: var(--accent-d); color: #fff; font-weight: 600; }
.btn--primary:active { background: var(--accent-d); }
.btn--icon { padding: 8px 12px; font-size: 1.2rem; line-height: 1; }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--ok { background: transparent; border-color: var(--ok); color: var(--ok); }
.btn--block { background: transparent; border-color: var(--warn); color: var(--warn); }

/* Tabs (status filter) */
.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 5;
  scrollbar-width: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab:active { transform: scale(0.97); }
.tab--active {
  background: var(--accent);
  border-color: var(--accent-d);
  color: #fff;
  font-weight: 600;
}
.tab__name { text-transform: capitalize; }
.tab__count {
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(0,0,0,0.28);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.tab--active .tab__count { background: rgba(0,0,0,0.22); }

/* Board */
.board {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}
.status-msg { color: var(--text-dim); text-align: center; padding: 20px; }

.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.column__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 4px 10px;
}
.column__dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex: 0 0 auto;
}
.column__name { font-weight: 700; text-transform: capitalize; }
.column__count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 9px;
}
.column__cards { display: flex; flex-direction: column; gap: 10px; }

/* Card */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--todo);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
.card:active { transform: scale(0.99); }
.card__top { display: flex; align-items: flex-start; gap: 8px; }
.card__title { font-weight: 600; flex: 1 1 auto; word-break: break-word; }
.card__body { margin-top: 6px; color: var(--text-dim); font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.card__meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}
.badge {
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.badge--assignee { background: var(--accent-d); color: #fff; border-color: var(--accent-d); }
.badge--prio { font-weight: 700; }
.badge--prio-high { color: var(--danger); border-color: var(--danger); }
.badge--prio-med { color: var(--warn); border-color: var(--warn); }
.badge--prio-low { color: var(--text-dim); }
.badge--comments { color: var(--text-dim); }
.prio-bar { display: inline-flex; gap: 2px; }

/* Wide screens: horizontal swipeable columns */
@media (min-width: 760px) {
  .board {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    align-items: flex-start;
    gap: 14px;
    scroll-snap-type: x mandatory;
  }
  .column {
    flex: 0 0 300px;
    scroll-snap-align: start;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
  }
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal__sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideup 0.18s ease-out;
}
@media (min-width: 760px) {
  .modal { align-items: center; }
  .modal__sheet { border-radius: 16px; }
}
@keyframes slideup { from { transform: translateY(20px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal__title { margin: 0; font-size: 1.1rem; word-break: break-word; }
.modal__body { padding: 14px 16px; overflow-y: auto; }
.modal__actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

.task-section { margin-bottom: 14px; }
.task-section h3 { margin: 0 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }
.task-text { white-space: pre-wrap; word-break: break-word; }
.task-meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 0.85rem; }
.task-meta-grid dt { color: var(--text-dim); }
.task-meta-grid dd { margin: 0; }

.comment {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--surface-2);
}
.comment__head { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-dim); margin-bottom: 4px; }
.comment__body { white-space: pre-wrap; word-break: break-word; }
.comment--empty { color: var(--text-dim); font-style: italic; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast[hidden] { display: none; }
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--ok { border-color: var(--ok); color: var(--ok); }

/* Login screen */
.login {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login[hidden] { display: none; }
.login__card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login__title { margin: 0; font-size: 1.6rem; text-align: center; }
.login__sub { margin: 0 0 6px; text-align: center; color: var(--text-dim); font-size: 0.9rem; }
.login__input {
  font: inherit;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.login__input:focus { outline: none; border-color: var(--accent); }
.login__btn { padding: 12px; font-size: 1rem; margin-top: 4px; }
.login__err { margin: 0; color: var(--danger); font-size: 0.85rem; text-align: center; }
.login__err[hidden] { display: none; }
