:root {
  --bg: #fbfbfb;
  --card: #ffffff;
  --raise: #f4f5f7;
  --ink: #1c1d21;
  --muted: #6b6f76;
  --faint: #9b9fa6;
  --line: #ebecee;
  --line-2: #e2e3e6;
  --brand: #5e6ad2;
  --high: #eb5757;
  --med: #e0a13a;
  --low: #5e6ad2;
  --amber: #e0a13a;
  --done: #5e6ad2;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 14px/1.5 "Inter", system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv01", "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--ink);
}

/* ---- Top bar ---- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  height: 48px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 251, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
header h1 { margin: 0; font-size: 0.875rem; font-weight: 600; letter-spacing: -0.01em; }
.logout { margin: 0 0 0 auto; }
.logout button {
  padding: 0.3rem 0.7rem;
  font-size: 0.8125rem;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}
.logout button:hover { background: var(--raise); color: var(--ink); }
header a { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem; }
header a::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: linear-gradient(150deg, #8d8bff, var(--brand));
  box-shadow: 0 1px 3px rgba(94, 106, 210, 0.4);
}

main { padding: 1.25rem 1.5rem 2.5rem; }

/* ---- Board toolbar ---- */
.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  padding: 0.35rem 0.7rem;
  color: var(--muted);
}
.refresh:hover { color: var(--ink); }
.refresh .icon { font-size: 0.95rem; line-height: 1; }
.refresh.htmx-request .icon { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Board ---- */
.board {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.column {
  flex: 0 0 332px;
  max-width: 332px;
}

/* ---- Mobile pager indicator (hidden on desktop) ---- */
.pager { display: none; }

.col-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem 0.7rem;
}
.col-head h2 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.count {
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

.col-body { display: flex; flex-direction: column; gap: 0.5rem; }

/* ---- Status iconography (column header + card) ---- */
.status-icon,
.card-status {
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.status-icon { width: 15px; height: 15px; }
.card-status { width: 14px; height: 14px; margin-top: 1px; }

[data-bucket="Inbox"]        :is(.status-icon, .card-status) { border: 1.5px dashed #b9bdc4; }
[data-bucket="Next Actions"] :is(.status-icon, .card-status) { border: 2px solid #bcc0c7; }
[data-bucket="Waiting For"]  :is(.status-icon, .card-status) {
  border: 2px solid var(--amber);
  background: conic-gradient(var(--amber) 0 50%, transparent 0 50%);
}
[data-bucket="Someday"]      :is(.status-icon, .card-status) { border: 1.5px dashed #d4d7db; }
[data-bucket="Done"]         :is(.status-icon, .card-status) {
  border: 2px solid var(--done);
  background: var(--done);
}
[data-bucket="Done"] :is(.status-icon, .card-status)::after {
  content: "✓";
  color: #fff;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  box-shadow: 0 1px 2px rgba(20, 22, 28, 0.04);
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.card:hover {
  border-color: var(--line-2);
  box-shadow: 0 2px 6px rgba(20, 22, 28, 0.08);
}

.card-id {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--faint);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.card-id:hover { color: var(--muted); }

.card-title {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.25rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: -0.004em;
}
.card-title:hover { color: #000; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.prio {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}
.pri-high { background: var(--high); }
.pri-med  { background: var(--med); }
.pri-low  { background: var(--low); }

.ctx {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.4rem;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  color: var(--muted);
  background: var(--card);
}
.ctx::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 0.32rem;
}
.due {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--high) 35%, var(--line-2));
  border-radius: 5px;
  color: var(--high);
  font-variant-numeric: tabular-nums;
}

.card-foot {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--faint);
}

.empty {
  margin: 0;
  padding: 0.4rem 0.5rem;
  color: var(--faint);
  font-size: 0.8125rem;
}

/* ---- Inline composer (new task per column) ---- */
.composer { margin-top: 0.5rem; }
.composer > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  font-size: 0.8125rem;
  color: var(--muted);
  border: 1px dashed var(--line-2);
  transition: background 0.12s ease, color 0.12s ease;
  user-select: none;
}
.composer > summary::-webkit-details-marker { display: none; }
.composer > summary:hover { background: var(--card); color: var(--ink); }
.composer[open] > summary { color: var(--ink); border-style: solid; margin-bottom: 0.5rem; }

.composer form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem;
  box-shadow: 0 1px 2px rgba(20, 22, 28, 0.04);
}
.composer-row { display: flex; gap: 0.4rem; }
.composer-row > * { min-width: 0; flex: 1; }

/* ---- Form controls (shared by composer + editor) ---- */
input[type="text"],
input[type="password"],
input:not([type]),
input[type="date"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.16);
}

button {
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0.42rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
button:hover { background: var(--raise); }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(94, 106, 210, 0.3);
}
button.primary:hover { background: #5560c8; border-color: #5560c8; }
button.danger { color: var(--high); border-color: transparent; background: transparent; }
button.danger:hover { background: rgba(235, 87, 87, 0.08); }

/* ---- Detail / editor ---- */
.detail {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.4rem 1.5rem;
  max-width: 600px;
  margin: 0.5rem auto;
  box-shadow: 0 1px 2px rgba(20, 22, 28, 0.04);
  animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.detail .back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
}
.detail .back:hover { color: var(--ink); }
.detail h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.detail .state {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.detail .muted { color: var(--muted); font-size: 0.875rem; }

.detail form { display: flex; flex-direction: column; gap: 0.85rem; }
.title-input {
  font-size: 1.05rem !important;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 0.5rem 0.6rem !important;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.detail label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
}
.saved { color: #2e9e6b; font-size: 0.8125rem; font-weight: 500; }
.error {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  background: rgba(235, 87, 87, 0.08);
  border: 1px solid rgba(235, 87, 87, 0.25);
  color: #b3382f;
  font-size: 0.8125rem;
}

@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}

/* ---- Mobile board: full-width swipeable pager ---- */
@media (max-width: 700px) {
  main { padding: 0.5rem 0 2rem; }

  .toolbar { padding: 0 1rem; margin-bottom: 0.25rem; }
  .refresh { padding: 0.5rem 0.7rem; }

  /* Dot indicator + active bucket label sit above the board. */
  .pager {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.1rem 1rem 0.6rem;
  }
  .pager-dots { display: flex; align-items: center; gap: 0.1rem; }
  .pager-dot {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .pager-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-2);
    transition: background 0.15s ease, transform 0.15s ease;
  }
  .pager-dot.is-active::before { background: var(--brand); transform: scale(1.35); }
  .pager-label {
    margin-left: auto;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--ink);
  }

  /* Each column fills the viewport and snaps one-per-swipe. */
  .board {
    gap: 0;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .column {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 1rem;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  /* Roomier tap targets on cards and controls. */
  .col-head { padding: 0.2rem 0.25rem 0.7rem; }
  .card { padding: 0.85rem 0.9rem; }
  .card-title { font-size: 0.95rem; }
  .card-id, .card-foot, .meta { font-size: 0.8125rem; }
  .composer > summary { padding: 0.7rem; text-align: center; }
  .composer-row { flex-wrap: wrap; }
  .composer-row > * { flex: 1 1 100%; }
  .composer button.primary { padding: 0.6rem 0.85rem; }
}

/* ---- Login ---- */
.login-body { background: var(--bg); }
.login-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.75rem 1.6rem;
  box-shadow: 0 4px 24px rgba(20, 22, 28, 0.06);
  animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login-mark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(150deg, #8d8bff, var(--brand));
  box-shadow: 0 1px 3px rgba(94, 106, 210, 0.4);
}
.login-sub { margin: -0.35rem 0 0.4rem; color: var(--muted); font-size: 0.875rem; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.login-card button.primary { margin-top: 0.4rem; padding: 0.5rem 0.85rem; }

/* ---- Quality floor ---- */
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
