:root {
  color-scheme: light;

  /* Surfaces — light workspace, white panels */
  --canvas: oklch(0.972 0.004 286);
  --surface: oklch(0.984 0.003 286);
  --surface-2: oklch(0.958 0.004 286);
  --surface-3: oklch(0.932 0.006 286);
  --surface-card: oklch(1 0 0);
  --surface-column: oklch(0.966 0.004 286);
  --surface-toolbar: oklch(1 0 0);

  /* Dark navigation rail */
  --rail: oklch(0.248 0.018 285);
  --rail-2: oklch(0.305 0.02 285);
  --rail-ink: oklch(0.74 0.02 286);
  --rail-ink-strong: oklch(0.985 0.006 286);
  --rail-active: oklch(0.36 0.04 286);

  /* Text */
  --ink: oklch(0.27 0.02 285);
  --ink-soft: oklch(0.38 0.02 285);
  --muted: oklch(0.47 0.018 285);

  /* Lines */
  --line: oklch(0.9 0.005 286);
  --line-strong: oklch(0.84 0.008 286);

  /* Accent — indigo / purple */
  --accent: oklch(0.55 0.2 286);
  --accent-strong: oklch(0.485 0.2 286);
  --accent-hover: oklch(0.44 0.2 286);
  --accent-ink: oklch(0.99 0.01 286);
  --accent-soft: oklch(0.95 0.035 286);
  --accent-soft-strong: oklch(0.9 0.06 286);
  --accent-border: oklch(0.82 0.075 286);

  /* Status families (kanban flow) — dot + pill */
  --status-todo: oklch(0.6 0.018 285);
  --status-active: oklch(0.6 0.15 248);
  --status-done: oklch(0.62 0.14 156);
  --status-neutral: oklch(0.62 0.02 286);
  --status-todo-bg: oklch(0.915 0.008 286);
  --status-todo-ink: oklch(0.4 0.02 286);
  --status-active-bg: oklch(0.5 0.16 248);
  --status-active-ink: oklch(0.99 0.01 248);
  --status-done-bg: oklch(0.5 0.13 156);
  --status-done-ink: oklch(0.99 0.01 156);
  --status-neutral-bg: oklch(0.915 0.008 286);
  --status-neutral-ink: oklch(0.4 0.02 286);

  /* Translucent column washes — the status color bleeding into the lane bg */
  --status-todo-wash: oklch(0.5 0.02 285 / 0.05);
  --status-active-wash: oklch(0.6 0.15 248 / 0.06);
  --status-done-wash: oklch(0.62 0.13 156 / 0.07);
  --status-neutral-wash: oklch(0.5 0.02 286 / 0.05);
  --status-todo-wash-hot: oklch(0.5 0.02 285 / 0.1);
  --status-active-wash-hot: oklch(0.6 0.15 248 / 0.12);
  --status-done-wash-hot: oklch(0.62 0.13 156 / 0.13);
  --status-neutral-wash-hot: oklch(0.5 0.02 286 / 0.1);

  /* Semantic */
  --danger: oklch(0.53 0.19 25);
  --danger-strong: oklch(0.47 0.19 25);
  --danger-soft: oklch(0.955 0.03 25);
  --danger-border: oklch(0.83 0.08 25);
  --warning: oklch(0.68 0.14 70);
  --success: oklch(0.6 0.14 156);

  /* Label palette */
  --label-mint-bg: oklch(0.94 0.05 162);
  --label-mint-ink: oklch(0.4 0.1 162);
  --label-amber-bg: oklch(0.94 0.06 80);
  --label-amber-ink: oklch(0.44 0.09 72);
  --label-rose-bg: oklch(0.95 0.04 18);
  --label-rose-ink: oklch(0.46 0.12 18);
  --label-blue-bg: oklch(0.94 0.045 250);
  --label-blue-ink: oklch(0.46 0.13 258);
  --label-violet-bg: oklch(0.95 0.045 292);
  --label-violet-ink: oklch(0.48 0.16 292);

  /* Shadows — soft, light */
  --shadow-subtle: 0 1px 2px oklch(0.3 0.03 286 / 0.08);
  --shadow-card: 0 1px 3px oklch(0.3 0.03 286 / 0.1);
  --shadow-raised: 0 6px 16px oklch(0.28 0.03 286 / 0.14);
  --shadow-overlay: 0 18px 44px oklch(0.24 0.04 286 / 0.24);

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --text-caption: 0.8125rem;
  --text-ui: 0.875rem;
  --text-body: 0.9375rem;
  --text-subhead: 1.0625rem;
  --text-title: 1.25rem;
  --text-page: 1.5rem;
  --text-display: 1.875rem;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --leading-tight: 1.2;
  --leading-ui: 1.4;
  --leading-body: 1.55;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-press: cubic-bezier(0.2, 0, 0.2, 1);
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;

  /* Z-index scale: sticky bars < dropdowns/popovers < drawer < search < drag clone < toast */
  --z-sticky: 200;
  --z-dropdown: 300;
  --z-drawer-backdrop: 400;
  --z-drawer: 500;
  --z-search-backdrop: 600;
  --z-search: 610;
  --z-drag: 650;
  --z-toast: 700;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 100%;
  font-kerning: normal;
  font-optical-sizing: auto;
  line-height: var(--leading-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

/* ============================================================
   App frame: rail | workspace sidebar | main
   ============================================================ */

.app-frame {
  display: grid;
  grid-template-columns: 56px auto minmax(0, 1fr);
  min-height: 100vh;
}

.app-frame-no-sidebar {
  grid-template-columns: 56px minmax(0, 1fr);
}

.app-frame-no-sidebar > .app-main {
  grid-column: 2;
}

/* --- Navigation rail --- */

.rail {
  display: flex;
  position: sticky;
  top: 0;
  z-index: var(--z-dropdown);
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  height: 100vh;
  padding: var(--space-3) 0;
  background: var(--rail);
}

.rail-brand {
  display: inline-grid;
  place-items: center;
  margin-bottom: var(--space-2);
  text-decoration: none;
}

.rail-brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-ui);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  transition: transform var(--motion-base) var(--ease-out), background-color var(--motion-base) var(--ease-out);
}

.rail-brand:hover .brand-mark {
  background: oklch(0.6 0.2 286);
  transform: translateY(-1px);
}

.rail-nav {
  display: grid;
  gap: var(--space-1);
}

.rail-link {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 10px;
  color: var(--rail-ink);
  transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

.rail-link:hover {
  background: var(--rail-2);
  color: var(--rail-ink-strong);
  text-decoration: none;
}

.rail-link.is-active {
  background: var(--rail-active);
  color: var(--rail-ink-strong);
}

.rail-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-account {
  margin-top: auto;
}

/* --- Workspace sidebar --- */

.workspace-nav {
  display: flex;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  flex-direction: column;
  width: 248px;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.workspace-head {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--line);
}

.workspace-name {
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.board-nav-label {
  margin: var(--space-3) var(--space-4) 0;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.board-nav {
  display: grid;
  align-content: start;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.board-nav-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-sm);
  padding: 7px var(--space-2);
  color: var(--ink-soft);
  font-size: var(--text-ui);
  font-weight: var(--weight-medium);
  transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

.board-nav-item:hover {
  background: var(--surface-3);
  color: var(--ink);
  text-decoration: none;
}

.board-nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: var(--weight-semibold);
}

.board-nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line-strong);
}

.board-nav-item.is-active .board-nav-dot {
  background: var(--accent);
}

.board-nav-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-nav-new {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2);
  border-radius: var(--radius-sm);
  padding: 8px var(--space-2);
  color: var(--muted);
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
  transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

.board-nav-new:hover {
  background: var(--surface-3);
  color: var(--accent-strong);
  text-decoration: none;
}

.board-nav-new svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* --- Main --- */

.app-main {
  min-width: 0;
  overflow-x: hidden;
  background: var(--canvas);
}

.app-shell {
  min-width: 0;
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
}

/* ============================================================
   Account popover (anchored in rail foot)
   ============================================================ */

.account-menu {
  position: relative;
}

.account-menu summary {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-menu summary:hover .avatar {
  box-shadow: 0 0 0 2px var(--rail-2);
}

.account-popover {
  position: fixed;
  bottom: var(--space-3);
  left: calc(56px + var(--space-2));
  z-index: var(--z-dropdown);
  display: grid;
  gap: var(--space-3);
  width: min(320px, calc(100vw - 80px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-4);
  animation: pop-up var(--motion-base) var(--ease-out);
}

.account-menu:not([open]) > .account-popover {
  display: none;
}

.account-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.account-identity-text {
  min-width: 0;
}

.account-identity-text strong {
  display: block;
  overflow: hidden;
  font-size: var(--text-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-identity-text small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-caption);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-form {
  display: grid;
  gap: var(--space-2);
}

.account-avatar-picker {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  cursor: pointer;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.account-avatar-hint {
  color: var(--accent-strong);
}

.avatar {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  background: var(--accent-soft-strong);
  color: var(--accent-strong);
  font-weight: var(--weight-bold);
}

.avatar-small {
  width: 30px;
  height: 30px;
  font-size: var(--text-caption);
}

.avatar-mini {
  width: 22px;
  height: 22px;
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
}

.avatar-large {
  width: 72px;
  height: 72px;
  font-size: var(--text-title);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rail .avatar-small {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ============================================================
   Typography
   ============================================================ */

h1 {
  margin-bottom: var(--space-3);
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

h2 {
  font-size: var(--text-page);
  font-weight: var(--weight-bold);
  letter-spacing: -0.015em;
  line-height: var(--leading-tight);
  text-wrap: balance;
}

h3 {
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--accent-strong);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.muted,
.empty-inline,
.column-empty {
  color: var(--muted);
}

/* ============================================================
   Forms & controls
   ============================================================ */

label {
  display: grid;
  gap: 5px;
  color: var(--ink-soft);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-ui);
  padding: 7px 11px;
  transition: border-color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:hover,
textarea:hover,
select:hover {
  border-color: oklch(0.74 0.02 286);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out);
}

.button:hover {
  text-decoration: none;
}

.button:active {
  transform: translateY(1px);
  transition-duration: 80ms;
  transition-timing-function: var(--ease-press);
}

.button-primary {
  background: var(--accent-strong);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px oklch(0.4 0.15 286 / 0.35);
}

.button-primary:hover {
  background: var(--accent-hover);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface-card);
  color: var(--ink);
}

.button-secondary:hover {
  border-color: oklch(0.74 0.02 286);
  background: var(--surface-2);
}

.button-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.button-ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.button-danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-strong);
}

.button-danger:hover {
  background: oklch(0.92 0.05 25);
}

.button-compact {
  min-height: 30px;
  padding: 4px 10px;
  font-size: var(--text-caption);
}

.button-full {
  width: 100%;
}

.button.is-busy,
button.is-busy {
  position: relative;
  overflow: hidden;
  pointer-events: none;
}

.button.is-busy::after,
button.is-busy::after {
  content: "";
  position: absolute;
  inset: auto 10px 5px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.4;
  transform-origin: left center;
  animation: busy-bar 720ms var(--ease-out-expo) infinite;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--muted);
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button-quiet {
  border-color: transparent;
  background: transparent;
}

.icon-button-quiet:hover {
  border-color: transparent;
  background: var(--surface-3);
}

.text-button {
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--danger-strong);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.text-button:hover {
  text-decoration: underline;
}

.danger-text {
  color: var(--danger-strong);
}

/* Notices */

.notice {
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-size: var(--text-ui);
  font-weight: var(--weight-medium);
}

.notice-error {
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-strong);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-caption);
  line-height: var(--leading-body);
}

.form-stack {
  display: grid;
  gap: var(--space-3);
}

.sr-only {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-input-hidden {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  opacity: 0;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================================
   Auth screens
   ============================================================ */

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 420px);
  gap: var(--space-6);
  width: min(960px, calc(100vw - 32px));
  margin: 12vh auto 0;
  align-items: start;
}

.auth-copy {
  padding-top: var(--space-5);
}

.auth-copy p:not(.eyebrow) {
  max-width: 60ch;
  color: var(--muted);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

.auth-form {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}

.dev-login-panel {
  display: grid;
  gap: var(--space-2);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.dev-login-panel-compact {
  margin-top: var(--space-1);
}

.dev-login-panel p {
  margin: 0;
  color: var(--ink-soft);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.dev-login-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.dev-login-link {
  display: grid;
  gap: 1px;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  padding: 7px 9px;
  text-decoration: none;
  transition: border-color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}

.dev-login-link:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  text-decoration: none;
}

.dev-login-link span {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.dev-login-link small {
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
}

/* ============================================================
   Boards overview
   ============================================================ */

.boards-layout {
  display: grid;
  gap: var(--space-5);
  width: min(920px, calc(100vw - 48px));
  margin: var(--space-6) auto;
}

.page-heading h1 {
  margin-bottom: 0;
}

.workspace-forms {
  display: grid;
  gap: var(--space-3);
}

.create-board {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
  align-items: end;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-4);
}

.create-client {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-4);
}

.client-section {
  display: grid;
  gap: var(--space-3);
}

.client-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.client-section-head h2 {
  margin: 0;
  font-size: var(--text-title);
}

.client-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

/* Error pages: a single centered card inside the app frame */

.error-page {
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  width: min(480px, calc(100vw - 32px));
  margin: 18vh auto 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-6) var(--space-5);
  text-align: center;
}

.error-page h1 {
  margin-bottom: 0;
  font-size: var(--text-page);
}

.error-page p {
  max-width: 44ch;
  margin-bottom: var(--space-2);
  color: var(--muted);
}

/* Admin panel */

.admin-layout {
  display: grid;
  gap: var(--space-6);
  width: min(920px, calc(100vw - 48px));
  margin: var(--space-6) auto;
}

.admin-section {
  display: grid;
  gap: var(--space-3);
}

.admin-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.admin-section-head h2 {
  margin: 0;
  font-size: var(--text-title);
}

.admin-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-subtle);
  overflow: hidden;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-row .member-identity-text {
  min-width: 0;
}

.admin-row .member-identity-text strong,
.admin-row .member-identity-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row .member-identity-text strong {
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
}

.admin-row .member-identity-text small {
  color: var(--muted);
  font-size: var(--text-caption);
}

.admin-boardcount {
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.admin-row .member-role-select {
  min-width: 148px;
}

.role-pill-accent {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.board-list {
  display: grid;
  gap: var(--space-2);
}

.board-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-card);
  box-shadow: var(--shadow-subtle);
  transition: border-color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-out);
}

.board-row:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.board-row a {
  display: grid;
  gap: 3px;
  flex: 1;
  padding: var(--space-4);
  color: var(--ink);
  text-decoration: none;
}

.board-row a:hover {
  text-decoration: none;
}

.board-row strong {
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

.board-row span {
  color: var(--muted);
  font-size: var(--text-ui);
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 10px;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-5);
}

.empty-state p {
  max-width: 60ch;
  margin-bottom: 0;
  color: var(--muted);
}

/* ============================================================
   Board surface
   ============================================================ */

.board-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100%;
}

.board-page-content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100%;
}

.board-page-content.is-blurred {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.board-toolbar {
  display: grid;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-toolbar);
}

.board-identity {
  justify-self: start;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.search-field {
  display: inline-grid;
  justify-self: center;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  padding: 0;
  font-size: var(--text-ui);
  font-weight: var(--weight-medium);
  transition: border-color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out);
}

.search-field:hover {
  border-color: var(--line-strong);
  background: var(--surface-card);
}

.search-field svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.board-identity h1 {
  margin: 0;
  overflow: hidden;
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-actions {
  display: inline-flex;
  justify-self: end;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
}

.search-trigger svg,
.search-box svg,
.upload-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.board-settings {
  position: relative;
  flex: 0 0 auto;
}

.board-settings summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  cursor: pointer;
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
  list-style: none;
  padding: 6px 12px;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
}

.board-settings summary::-webkit-details-marker {
  display: none;
}

.board-settings summary:hover {
  border-color: oklch(0.74 0.02 286);
  background: var(--surface-2);
}

.settings-popover {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  display: grid;
  gap: var(--space-4);
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 84px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-4);
  animation: pop-down var(--motion-base) var(--ease-out);
}

.board-settings:not([open]) > .settings-popover {
  display: none;
}

.settings-section {
  display: grid;
  gap: var(--space-2);
}

.settings-section h2 {
  margin: 0;
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.settings-form,
.member-add,
.comment-form {
  display: grid;
  gap: var(--space-3);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.settings-danger-zone {
  display: flex;
  justify-content: flex-start;
  margin-top: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.board-workspace {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.search-banner {
  margin: var(--space-3) var(--space-4) 0;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 8px 12px;
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  line-height: var(--leading-body);
}

/* Columns rail */

.columns-rail {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  min-height: 420px;
  overflow-x: auto;
  contain: inline-size;
  padding: var(--space-4);
  scroll-padding: var(--space-4);
}

.kanban-column,
.add-column {
  flex: 0 0 280px;
  max-width: 280px;
}

.kanban-column {
  display: grid;
  grid-template-rows: auto minmax(60px, 1fr) auto;
  max-height: calc(100vh - 84px);
  border-radius: var(--radius-lg);
  background: var(--status-neutral-wash);
  padding: var(--space-2);
  transition: background-color var(--motion-base) var(--ease-out);
}

.kanban-column.status-todo {
  background: var(--status-todo-wash);
}

.kanban-column.status-active {
  background: var(--status-active-wash);
}

.kanban-column.status-done {
  background: var(--status-done-wash);
}

/* Drag target: the lane holding the ghost heats up */
.kanban-column:has(.sortable-ghost) {
  background: var(--status-neutral-wash-hot);
}

.kanban-column.status-todo:has(.sortable-ghost) {
  background: var(--status-todo-wash-hot);
}

.kanban-column.status-active:has(.sortable-ghost) {
  background: var(--status-active-wash-hot);
}

.kanban-column.status-done:has(.sortable-ghost) {
  background: var(--status-done-wash-hot);
}

.column-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 4px var(--space-2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  background: var(--status-neutral-bg);
  color: var(--status-neutral-ink);
}

.status-todo .status-pill {
  background: var(--status-todo-bg);
  color: var(--status-todo-ink);
}

.status-active .status-pill {
  background: var(--status-active-bg);
  color: var(--status-active-ink);
}

.status-done .status-pill {
  background: var(--status-done-bg);
  color: var(--status-done-ink);
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.85;
}

.column-title-form {
  min-width: 0;
}

.column-title-form input {
  field-sizing: content;
  min-width: 40px;
  max-width: 150px;
  min-height: 18px;
  border-color: transparent;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 0.6875rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.column-title-form input:hover,
.column-title-form input:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.column-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.column-archive {
  flex: 0 0 auto;
  margin-left: auto;
}

.column-tool {
  width: 28px;
  height: 28px;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}

.kanban-column:hover .column-tool,
.column-tool:focus-visible {
  opacity: 1;
}

.card-list {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  min-height: 60px;
  overflow-y: auto;
  padding: 2px;
}

.kanban-card {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  box-shadow: var(--shadow-subtle);
  transition: border-color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-out);
}

.kanban-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.kanban-card strong {
  overflow-wrap: anywhere;
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-ui);
}

.card-description {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: var(--text-caption);
  line-height: var(--leading-body);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-caption);
  line-height: 1;
}

.card-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: var(--weight-medium);
}

.card-meta-item svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-due {
  color: var(--ink-soft);
}

.avatar-mini {
  width: 20px;
  height: 20px;
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  border: 1.5px solid var(--surface-card);
}

.assignee-stack {
  display: inline-flex;
  margin-left: auto;
  align-items: center;
}

.assignee-stack .avatar-mini + .avatar-mini {
  margin-left: -6px;
}

/* Assignee picker in the drawer */

.assignee-field {
  display: grid;
  gap: var(--space-2);
}

.field-caption {
  color: var(--ink-soft);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.assignee-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.assignee-option {
  cursor: pointer;
}

.assignee-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-card);
  color: var(--ink-soft);
  padding: 3px 12px 3px 3px;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  transition: border-color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
}

.assignee-chip .avatar-mini {
  border-color: transparent;
  background: var(--surface-3);
  color: var(--muted);
}

.assignee-option:hover .assignee-chip {
  border-color: oklch(0.74 0.02 286);
  background: var(--surface-2);
}

.assignee-option input:checked + .assignee-chip {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.assignee-option input:checked + .assignee-chip .avatar-mini {
  background: var(--accent);
  color: var(--accent-ink);
}

.assignee-option input:focus-visible + .assignee-chip {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.readonly-assignees {
  display: grid;
  gap: var(--space-1);
}

.card-assignee {
  margin-left: auto;
  background: var(--accent-soft-strong);
  color: var(--accent-strong);
}

/* Sortable drag states */

.sortable-ghost {
  border: 1px dashed var(--accent);
  background: oklch(1 0 0 / 0.55);
  box-shadow: none;
  opacity: 0.9;
  transition: none !important;
}

.sortable-chosen {
  cursor: grabbing;
  transition: none !important;
}

.sortable-drag {
  border-color: var(--accent);
  box-shadow: var(--shadow-raised);
  transition: none !important;
}

/* forceFallback floating clone that follows the cursor. Rendered on <body>
   (fallbackOnBody) so column overflow can't clip it mid-drag. */
.sortable-fallback {
  z-index: var(--z-drag);
  opacity: 0.95 !important;
  box-shadow: var(--shadow-overlay);
  cursor: grabbing;
  pointer-events: none;
  transition: none !important;
  will-change: transform;
}

.is-delight-flash {
  animation: delight-flash 780ms var(--ease-out);
}

/* Labels */

.label-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.label-row-large {
  margin-top: 0;
}

.label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: var(--radius-sm);
  padding: 1px 8px;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.label-mint {
  background: var(--label-mint-bg);
  color: var(--label-mint-ink);
}

.label-amber {
  background: var(--label-amber-bg);
  color: var(--label-amber-ink);
}

.label-rose {
  background: var(--label-rose-bg);
  color: var(--label-rose-ink);
}

.label-blue {
  background: var(--label-blue-bg);
  color: var(--label-blue-ink);
}

.label-gray {
  background: var(--surface-3);
  color: var(--muted);
}

.label-violet {
  background: var(--label-violet-bg);
  color: var(--label-violet-ink);
}

/* Column empty + add */

.column-empty {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--text-caption);
  transition: border-color var(--motion-base) var(--ease-out), background-color var(--motion-base) var(--ease-out),
    color var(--motion-base) var(--ease-out);
}

.card-list:has(> [data-card-id]) > .column-empty {
  display: none;
}

.kanban-column:hover .column-empty {
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.add-card {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
}

.add-card input {
  order: 2;
  flex: 1;
  min-width: 0;
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
  padding-left: var(--space-2);
  font-weight: var(--weight-medium);
}

.add-card input::placeholder {
  color: var(--muted);
}

.add-card:hover input,
.add-card input:hover {
  background: var(--surface-3);
}

.add-card input:focus {
  border-color: var(--accent);
  background: var(--surface-card);
}

.add-card-submit {
  order: 1;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.add-card:hover .add-card-submit {
  color: var(--accent-strong);
}

.add-card-submit:hover {
  background: var(--surface-3);
}

.add-column {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: transparent;
  padding: var(--space-2);
  transition: border-color var(--motion-base) var(--ease-out), background-color var(--motion-base) var(--ease-out);
}

.add-column:hover,
.add-column:focus-within {
  border-color: var(--accent-border);
  background: var(--status-neutral-wash);
}

.add-column label {
  color: var(--muted);
}

.add-column input {
  border-color: transparent;
  background: transparent;
}

.add-column:hover input,
.add-column input:focus {
  background: var(--surface-card);
}

.add-column input:hover {
  border-color: transparent;
}

.add-column input:focus {
  border-color: var(--accent);
}

/* Members */

.section-heading,
.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.section-heading h2 {
  margin: 0;
}

.member-list {
  display: grid;
  gap: 0;
  max-height: 200px;
  margin: 0;
  overflow: auto;
}

.member-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.member-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.member-identity-text {
  min-width: 0;
}

.member-row strong {
  display: block;
  overflow: hidden;
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-row small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-caption);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
}

.member-actions form {
  display: inline-flex;
}

.member-role-select {
  width: auto;
  min-height: 30px;
  padding: 4px 26px 4px 9px;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.member-actions .icon-button {
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.member-actions .icon-button:hover {
  background: var(--danger-soft);
  color: var(--danger-strong);
}

.member-invite {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

.member-invite summary {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  padding: 7px 9px;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
}

.member-invite summary::-webkit-details-marker {
  display: none;
}

.member-invite summary:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.member-invite[open] summary {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.member-invite-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: currentColor;
}

.member-invite[open] .member-invite-icon,
.member-invite summary:hover .member-invite-icon {
  background: var(--surface-card);
}

.member-invite-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.member-invite-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.member-invite-text strong {
  overflow: hidden;
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-invite-text small {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-caption);
  line-height: var(--leading-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-invite[open] .member-invite-text small,
.member-invite summary:hover .member-invite-text small {
  color: var(--accent-strong);
}

.member-add {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2);
}

.member-invite-form {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--space-2);
}

/* Email spans the full width; role + submit share the row below. */
.member-add > label:first-of-type {
  grid-column: 1 / -1;
}

/* ============================================================
   Welcome dialog
   ============================================================ */

.welcome-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: grid;
  place-items: center;
  background: oklch(0.24 0.03 286 / 0.4);
  padding: var(--space-4);
}

.welcome-dialog {
  display: grid;
  gap: var(--space-3);
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-5);
}

.welcome-dialog h2 {
  margin: 0;
}

/* ============================================================
   Card drawer
   ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer-backdrop);
  background: oklch(0.22 0.03 286 / 0.34);
  animation: fade-in var(--motion-base) var(--ease-out);
}

.drawer-backdrop.is-closing {
  animation: fade-out var(--motion-fast) var(--ease-press) forwards;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  display: grid;
  align-content: start;
  gap: var(--space-3);
  width: min(640px, 100vw);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  animation: drawer-in var(--motion-slow) var(--ease-out-expo);
}

.drawer.is-closing {
  animation: drawer-out var(--motion-fast) var(--ease-press) forwards;
}

.drawer:focus {
  outline: 0;
}

.drawer-header {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 2;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: start;
  gap: var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface-card);
  padding: var(--space-4) var(--space-5) var(--space-3);
}

.drawer-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: var(--text-subhead);
}

.drawer-section {
  display: grid;
  gap: var(--space-2);
  margin: 0 var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.drawer-section:first-of-type {
  margin-top: var(--space-3);
  padding-top: 0;
  border-top: 0;
}

.drawer-section h3 {
  font-size: var(--text-body);
}

.card-content-section {
  gap: var(--space-3);
}

.card-content-form {
  display: grid;
  gap: var(--space-2);
}

.card-content-section > label textarea {
  min-height: 120px;
}

.card-fields-compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: var(--space-2);
}

.button-compact-save {
  justify-self: end;
  min-width: 120px;
}

.autosave-status {
  justify-self: end;
  min-height: 20px;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
}

.autosave-status[data-tone="saving"] {
  color: var(--ink-soft);
}

.autosave-status[data-tone="saved"] {
  color: var(--success);
}

.autosave-status[data-tone="error"] {
  color: var(--danger-strong);
}

.drawer > form:last-child {
  margin: var(--space-2) var(--space-5) var(--space-5);
}

/* Inline title editing */

.inline-title-form {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  align-items: center;
}

.inline-title-input {
  width: 100%;
  min-width: 0;
  min-height: 1.4em;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-title-input[readonly] {
  cursor: default;
}

.inline-title-form:hover .inline-title-input[readonly]:not([data-inline-title-disabled]) {
  background: var(--surface-3);
}

.inline-title-form.is-editing .inline-title-input {
  background: var(--surface-card);
  border-color: var(--accent);
  cursor: text;
  text-overflow: clip;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.board-title-toolbar {
  width: min(100%, 62ch);
}

.board-title-toolbar .inline-title-input {
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.board-title-form .inline-title-input {
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
}

.settings-popover .board-title-form {
  width: 100%;
}

.card-title-block {
  min-width: 0;
}

.card-title-form .inline-title-input {
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
}

/* Upload zone */

.compact-upload {
  display: grid;
  gap: var(--space-1);
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  padding: 0;
  transition: background-color var(--motion-base) var(--ease-out), border-color var(--motion-base) var(--ease-out),
    transform var(--motion-base) var(--ease-out);
}

.compact-upload.dragover,
.compact-upload:hover,
.compact-upload.is-busy {
  border-color: var(--accent);
  background: var(--accent-soft-strong);
}

.compact-upload.is-busy {
  transform: translateY(-1px);
}

.compact-upload.dragover .upload-icon,
.compact-upload:hover .upload-icon,
.compact-upload.has-selection .upload-icon {
  border-color: var(--accent);
  background: var(--surface-card);
  transform: translateY(-1px);
}

.compact-upload progress {
  width: calc(100% - 20px);
  margin: 0 10px 10px;
  opacity: 0.92;
}

.upload-prompt {
  display: grid;
  min-height: 54px;
  place-items: center;
  gap: 6px;
  padding: var(--space-3);
  color: var(--accent-strong);
  cursor: pointer;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  text-align: center;
}

.upload-icon {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--surface-card);
  color: var(--accent-strong);
  transition: background-color var(--motion-base) var(--ease-out), border-color var(--motion-base) var(--ease-out),
    transform var(--motion-base) var(--ease-out);
}

progress {
  width: min(260px, 100%);
  height: 8px;
  accent-color: var(--accent);
}

/* Attachments */

.attachment-list,
.comment-list {
  display: grid;
  gap: 0;
}

.attachment-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.attachment-icon {
  display: grid;
  width: 40px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: var(--weight-bold);
}

.attachment-main {
  min-width: 0;
}

.attachment-main strong,
.attachment-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-main strong {
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
}

.attachment-main small {
  color: var(--muted);
  font-size: var(--text-caption);
}

/* Comments */

.comment-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.comment {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}

.comment header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--text-caption);
}

.comment header strong {
  color: var(--ink);
  font-weight: var(--weight-semibold);
}

.comment p,
.comment .markdown-body {
  margin: var(--space-2) 0 0;
  overflow-wrap: anywhere;
  line-height: var(--leading-body);
}

.empty-inline {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-ui);
}

/* History */

.history-list p {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  color: var(--ink-soft);
  font-size: var(--text-caption);
  line-height: var(--leading-body);
}

.history-list p span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-list time {
  flex: 0 0 auto;
  color: var(--muted);
  white-space: nowrap;
}

.readonly-card {
  color: var(--ink-soft);
  line-height: var(--leading-body);
  white-space: pre-wrap;
}

/* Markdown */

.markdown-preview,
.markdown-body {
  max-width: 68ch;
  overflow-wrap: anywhere;
  color: var(--ink);
  line-height: var(--leading-body);
}

.markdown-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  padding: var(--space-3);
}

.markdown-preview p:last-child,
.markdown-body p:last-child,
.markdown-preview ul:last-child,
.markdown-body ul:last-child,
.markdown-preview ol:last-child,
.markdown-body ol:last-child {
  margin-bottom: 0;
}

.markdown-preview code,
.markdown-body code {
  border-radius: 4px;
  background: var(--surface-2);
  padding: 1px 5px;
  font-size: var(--text-caption);
}

.markdown-preview pre,
.markdown-body pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: var(--space-3);
}

.markdown-preview blockquote,
.markdown-body blockquote {
  margin: 0 0 var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: var(--space-2) var(--space-3);
  color: var(--ink-soft);
}

/* ============================================================
   Search palette
   ============================================================ */

.search-overlay[hidden] {
  display: none;
}

.search-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-search-backdrop);
  background: oklch(0.22 0.03 286 / 0.36);
  animation: fade-in var(--motion-base) var(--ease-out);
}

.search-overlay.is-closing .search-backdrop {
  animation: fade-out var(--motion-fast) var(--ease-press) forwards;
}

.search-panel {
  position: fixed;
  top: 10vh;
  left: 50%;
  z-index: var(--z-search);
  display: grid;
  width: min(680px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 80px));
  overflow: hidden;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-overlay);
  animation: search-in var(--motion-slow) var(--ease-out-expo);
}

.search-overlay.is-closing .search-panel {
  animation: search-out var(--motion-fast) var(--ease-press) forwards;
}

.search-box {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 28px;
  align-items: center;
  gap: var(--space-2);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
}

.search-box svg {
  color: var(--muted);
}

.search-box input {
  min-height: 40px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: var(--text-subhead);
}

.search-box input:focus {
  box-shadow: none;
}

.search-box button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-subhead);
}

.search-box button:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.search-results {
  display: grid;
  max-height: 480px;
  overflow-y: auto;
  padding: var(--space-2);
}

.search-result {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  animation: fade-slide var(--motion-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 26ms);
  transition: background-color var(--motion-fast) var(--ease-out);
}

.search-result:hover,
.search-result:focus-visible {
  background: var(--accent-soft);
}

.search-result strong {
  font-size: var(--text-ui);
  font-weight: var(--weight-semibold);
}

.search-result span {
  color: var(--muted);
  font-size: var(--text-caption);
  line-height: var(--leading-ui);
}

.search-empty {
  margin: 0;
  padding: var(--space-5);
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   Toasts
   ============================================================ */

.toast-root {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--z-toast);
  display: grid;
  justify-items: end;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: var(--space-2);
  max-width: min(360px, calc(100vw - 32px));
  min-height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-card);
  color: var(--ink);
  box-shadow: var(--shadow-raised);
  padding: 10px 12px;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  animation: toast-in var(--motion-base) var(--ease-out-expo);
}

.toast.is-leaving {
  animation: toast-out var(--motion-fast) var(--ease-press) forwards;
}

.toast-mark {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft-strong);
  color: var(--accent-strong);
  font-size: var(--text-caption);
}

.toast-life {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
  transform-origin: left center;
  animation: toast-life var(--toast-life-ms, 1900ms) linear forwards;
}

/* ============================================================
   Keyframes
   ============================================================ */

@keyframes drawer-in {
  from {
    opacity: 0.9;
    transform: translateX(20px);
  }
}

@keyframes drawer-out {
  to {
    opacity: 0.95;
    transform: translateX(20px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes search-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
}

@keyframes search-out {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px) scale(0.99);
  }
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes pop-down {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes pop-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes busy-bar {
  0% {
    transform: scaleX(0);
  }
  45% {
    transform: scaleX(1);
  }
  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

@keyframes toast-life {
  to {
    transform: scaleX(0);
  }
}

@keyframes delight-flash {
  0% {
    box-shadow: 0 0 0 0 oklch(0.55 0.2 286 / 0);
  }
  35% {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px oklch(0.55 0.2 286 / 0.24);
  }
  100% {
    box-shadow: 0 0 0 0 oklch(0.55 0.2 286 / 0);
  }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 960px) {
  .app-frame {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .workspace-nav {
    display: none;
  }
}

@media (max-width: 720px) {
  .auth-panel,
  .create-board,
  .create-client,
  .member-add,
  .comment-form,
  .card-fields-compact {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    margin-top: var(--space-5);
  }

  .board-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-2);
  }

  .board-identity h1 {
    white-space: nowrap;
  }

  .search-field {
    justify-self: end;
  }

  .board-actions {
    justify-self: end;
  }

  .board-settings {
    flex: 1;
  }

  .board-settings summary {
    justify-content: center;
    width: 100%;
  }

  .settings-popover {
    left: 0;
    right: auto;
    width: 100%;
  }

  .drawer {
    width: 100vw;
  }

  .drawer-header {
    padding: var(--space-3) var(--space-4);
  }

  .drawer-section {
    margin-inline: var(--space-4);
  }

  .drawer > form:last-child {
    margin-inline: var(--space-4);
  }

  .button-compact-save {
    justify-self: stretch;
    width: 100%;
  }

  .history-list p {
    display: grid;
    gap: var(--space-1);
  }

  .member-add {
    grid-template-columns: 1fr;
  }

  .attachment-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .attachment-row .button,
  .attachment-row form {
    grid-column: 2;
    justify-self: start;
  }

  .boards-layout {
    width: calc(100vw - 32px);
  }
}

@media (max-width: 520px) {
  .app-frame {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .rail {
    padding: var(--space-2) 0;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .account-popover {
    left: var(--space-2);
    right: var(--space-2);
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
