/* Kanban — all styling. No CSS framework, no build step. */

:root {
  color-scheme: light dark;

  --bg:            #f4f5f7;
  --surface:       #ffffff;
  --surface-sunk:  #ebecf0;
  --border:        #dcdfe4;
  --text:          #172b4d;
  --text-muted:    #5e6c84;
  --accent:        #3b6ef5;
  --accent-text:   #ffffff;
  --danger:        #c9372c;
  --shadow:        0 1px 2px rgba(9, 30, 66, .12), 0 0 1px rgba(9, 30, 66, .1);
  --radius:        8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #1d2125;
    --surface:      #282e33;
    --surface-sunk: #22272b;
    --border:       #3c444c;
    --text:         #dee4ea;
    --text-muted:   #9fadbc;
    --accent:       #669df1;
    --accent-text:  #0e1114;
    --danger:       #f87168;
    --shadow:       0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* `display: inline-flex` on .btn would otherwise beat the UA rule for [hidden]. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.spacer { flex: 1; }

/* ------------------------------------------------------------------ buttons */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 12px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover      { background: var(--surface-sunk); }
.btn:active     { transform: translateY(1px); }
.btn:focus-visible,
.icon-btn:focus-visible,
.card:focus-visible,
.add-task:focus-visible,
.column-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
}
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

.btn-quiet  { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-quiet:hover { background: var(--surface-sunk); }

.btn-small  { padding: 4px 9px; font-size: 12.5px; }
.btn-block  { width: 100%; justify-content: center; margin-top: 8px; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 5px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.icon-btn:hover        { background: var(--surface-sunk); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

/* ------------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-left { flex: 1; }

.mark { font-weight: 700; letter-spacing: -.01em; font-size: 15px; }

.status { font-size: 12.5px; color: var(--text-muted); min-height: 1em; }
.status[data-tone="error"] { color: var(--danger); font-weight: 600; }

/* -------------------------------------------------------------------- board */

.board { padding: 18px 20px 60px; display: flex; flex-direction: column; gap: 18px; }
.board-loading { color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-state h2 { margin: 0 0 6px; color: var(--text); font-size: 17px; }
.empty-state p  { margin: 0; }

/* One project = one horizontal row of columns. */
.project {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.project-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.project-title { margin: 0; font-size: 15px; font-weight: 650; }
.project-meta  { font-size: 12px; color: var(--text-muted); }

.project-grip, .column-grip {
  cursor: grab;
  color: var(--text-muted);
  user-select: none;
  font-size: 13px;
  line-height: 1;
}
.project-grip:active, .column-grip:active { cursor: grabbing; }

/* Columns scroll horizontally when the row outgrows the viewport. */
.lane {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  overflow-x: auto;
  background: var(--surface-sunk);
  scrollbar-width: thin;
}

.column {
  flex: 0 0 272px;
  max-width: 272px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 10px;
}
.column-title {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  /* Three controls share this row — the title gives way, they don't. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-header .icon-btn,
.column-count { flex: 0 0 auto; }
.column-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-sunk);
  border-radius: 10px;
  padding: 1px 7px;
}

.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 24px;
}

.add-task {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  border-radius: 0 0 8px 8px;
}
.add-task:hover { background: var(--surface-sunk); color: var(--text); }

.column-add {
  flex: 0 0 272px;
  appearance: none;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  cursor: pointer;
}
.column-add:hover { background: var(--surface); color: var(--text); }

/* --------------------------------------------------------------------- card */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 52px 9px 11px; /* right gutter reserved so hover can't reflow text */
  box-shadow: var(--shadow);
  cursor: grab;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.card:active { cursor: grabbing; }

.card-title { font-weight: 550; overflow-wrap: anywhere; }

.card-desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.card-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 1px;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity .14s ease, transform .14s ease;
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; transform: none; }

.card-actions .icon-btn { width: 22px; height: 22px; font-size: 12px; }

.card-ghost { opacity: .4; }
.card-drag  { box-shadow: 0 10px 20px rgba(9, 30, 66, .25); }

/* Collapsing a card, column or project row away. JS sets the end values on the
   element; these carry them. Cards and rows shrink by height, columns by
   flex-basis — that is what gives a column its width. */
.collapsing {
  overflow: hidden;
  pointer-events: none;
  box-shadow: none;
  min-width: 0;
  transition: height .22s cubic-bezier(.4, 0, .2, 1),
              flex-basis .22s cubic-bezier(.4, 0, .2, 1),
              padding .22s cubic-bezier(.4, 0, .2, 1),
              margin .22s cubic-bezier(.4, 0, .2, 1),
              opacity .16s ease,
              transform .22s ease;
}

/* Anything restored from a toast announces itself. */
@keyframes restored-in {
  from { opacity: 0; transform: translateY(-6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes restored-glow {
  0%, 60% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
  100%    { box-shadow: var(--shadow); }
}
.restored { animation: restored-in .28s cubic-bezier(.2, .8, .3, 1), restored-glow .9s ease-out; }

/* ------------------------------------------------------------------ dialogs */

.dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 16px 40px rgba(9, 30, 66, .28);
}
.dialog::backdrop { background: rgba(9, 30, 66, .45); animation: backdrop-in .18s ease-out; }
.dialog[open] { animation: dialog-in .2s cubic-bezier(.2, .8, .3, 1); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.dialog h2 { margin: 0 0 14px; font-size: 16px; }
.dialog-body { margin: 0 0 16px; color: var(--text-muted); }

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
}

.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field input, .field textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

/* ------------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
  pointer-events: none; /* the stack spans wide; only the toasts take clicks */
}

.toast {
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  padding: 11px 8px 11px 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(9, 30, 66, .22);

  animation: toast-in .24s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.toast-leaving {
  animation: none;
  opacity: 0;
  transform: translateY(10px) scale(.97);
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, .8, .3, 1);
}

.toast-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-action {
  appearance: none;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
}
.toast-action:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.toast-action:focus-visible,
.toast-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast-close { flex: 0 0 auto; width: 22px; height: 22px; font-size: 11px; }

/* Countdown to auto-dismiss; paused while the pointer is over the toast. */
.toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  background: var(--accent);
  opacity: .5;
  animation: toast-countdown linear forwards;
}
@keyframes toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* -------------------------------------------------------------------- login */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-mark { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.login-sub  { margin: 0 0 20px; color: var(--text-muted); font-size: 13px; }
.login-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ----------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .restored,
  .dialog[open],
  .dialog::backdrop { animation: none; }

  .card,
  .card-actions,
  .toast { transition: none; animation: none; }
  .toast-bar { animation: none; opacity: 0; }
}

/* ------------------------------------------------------------------- mobile */

@media (max-width: 620px) {
  .topbar { padding: 10px 12px; }
  .board  { padding: 12px 12px 48px; }
  .column, .column-add { flex-basis: 240px; max-width: 240px; }
  .project-meta { display: none; }

  /* Keep the header on one line: the title truncates, the controls don't shrink. */
  .project-header { padding: 10px 10px 10px 12px; }
  .project-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .project-header .btn-small { flex: 0 0 auto; white-space: nowrap; }
  .project-header .icon-btn  { flex: 0 0 auto; }

  .toasts { left: 12px; right: 12px; bottom: 12px; width: auto; transform: none; }
  .toast  { width: 100%; }
}

/* Drag placeholders (fallback mode) */
.column-ghost, .project-ghost { opacity: .45; }
.column-ghost { background: var(--surface-sunk); }
