/*
 * Kanban board UI on the One Dark theme (frontend/_new/css.css).
 * Names such as --background are aliases so the board rules can keep
 * their existing variable names.
 */

/* ---------- Design tokens ---------- */

:root {
  color-scheme: dark;

  --color-bg: #282c34;
  --color-bg-deep: #21252b;
  --color-surface: #2c313a;
  --color-surface-hover: #343b46;
  --color-heading: #e6eaf0;
  --color-text: #abb2bf;
  --color-muted: #9199a8;
  --color-border: #3e4451;
  --color-border-control: #758095;
  --color-primary: #61afef;
  --color-primary-hover: #80bff3;
  --color-on-primary: #21252b;
  --color-success: #98c379;
  --color-warning: #e5c07b;
  --color-danger: #ef8790;
  --color-info: #56b6c2;
  --color-purple: #c678dd;

  --font-body:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-code:
    "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --radius-control: 3px;
  --radius-card: 5px;
  --radius-panel: 8px;
  --shadow-raised: 0 12px 32px rgb(0 0 0 / 20%);
  --transition: 160ms ease;

  --canvas: var(--color-bg);
  --background: var(--color-bg);
  --foreground: var(--color-text);
  --card: var(--color-surface);
  --card-foreground: var(--color-text);
  --popover: var(--color-surface);
  --popover-foreground: var(--color-text);
  --primary: var(--color-primary);
  --primary-foreground: var(--color-on-primary);
  --secondary: transparent;
  --secondary-foreground: var(--color-heading);
  --muted: var(--color-surface-hover);
  --muted-foreground: var(--color-muted);
  --accent: var(--color-surface);
  --accent-foreground: var(--color-primary);
  --destructive: var(--color-danger);
  --amber: var(--color-warning);
  --amber-medium: var(--color-warning);
  --border: var(--color-border);
  --input: var(--color-border-control);
  --ring: var(--color-primary);
  --sidebar: var(--color-bg-deep);
  --sidebar-primary-foreground: var(--color-border);

  --elevation-1: none;
  --elevation-2: var(--shadow-raised);
  --elevation-3: var(--shadow-raised);
  --elevation-inset: none;

  --radius: var(--radius-control);
  --radius-sm: 2px;
  --radius-md: var(--radius-control);
  --radius-lg: var(--radius-control);
  --radius-xl: var(--radius-card);
  --radius-2xl: var(--radius-panel);

  --scrollbar-thumb: var(--color-border);
  --scrollbar-thumb-hover: var(--color-border-control);

  --font-sans: var(--font-body);
  --font-mono: var(--font-code);
  --tracking-heading: -0.025em;

  --column-width: 24rem;
  --card-panel-width: 30rem;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  border: 0 solid var(--border);
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.65;
}

h1,
h2,
h3 {
  color: var(--color-heading);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

::selection {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

a {
  color: var(--color-primary);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--color-primary-hover);
}

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

button {
  cursor: pointer;
  background: none;
  padding: 0;
}

:focus-visible {
  outline: 1px solid color-mix(in oklab, var(--color-primary) 50%, transparent);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border: 2px solid transparent;
  border-radius: 9999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

svg.icon {
  display: block;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  pointer-events: none;
}

.text-muted {
  color: var(--muted-foreground);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0.4rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  user-select: none;
  cursor: pointer;
  transition:
    background-color var(--transition),
    border-color var(--transition),
    color var(--transition);
}
.btn:not(:disabled):hover {
  background: var(--color-primary-hover);
  color: var(--color-on-primary);
}
.btn:not(:disabled):active {
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 20%);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-default {
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.btn-default:not(:disabled):hover {
  background: var(--color-primary-hover);
  color: var(--color-on-primary);
}

.btn-secondary,
.settings-btn {
  border-color: var(--color-border-control);
  background: transparent;
  color: var(--color-heading);
}
.btn-secondary:not(:disabled):hover,
.settings-btn:not(:disabled):hover {
  border-color: var(--color-border-control);
  background: var(--color-surface-hover);
  color: var(--color-heading);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-text);
}
.btn-ghost:not(:disabled):hover {
  background: var(--color-surface-hover);
  color: var(--color-heading);
}

.btn-muted {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
}
.btn-muted:not(:disabled):hover {
  background: var(--color-surface-hover);
  color: var(--color-heading);
}

.btn-destructive {
  background: var(--color-danger);
  color: var(--color-on-primary);
}
.btn-destructive:not(:disabled):hover {
  background: color-mix(in oklab, var(--color-danger) 86%, white);
  color: var(--color-on-primary);
}

.btn-sm {
  font-size: 0.875rem;
}
.btn-sm svg.icon {
  width: 0.875rem;
  height: 0.875rem;
}
.btn-icon-sm,
.btn-icon-lg,
.sidebar-toggle {
  width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
}

/* ---------- Layout ---------- */

.app {
  display: flex;
  height: 100svh;
  width: 100%;
}

.board-page {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.page-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-4);
  min-height: 50px;
  padding: env(safe-area-inset-top) var(--space-6) 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-deep);
}

.board-title {
  min-width: 10rem;
  color: var(--color-heading);
  font-size: 1.125rem;
  font-weight: 750;
  letter-spacing: -0.025em;
}

/* An inline-editable value: plain text until clicked. */
.invisible-input {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0 0.5rem;
  cursor: text;
}
input.invisible-input-edit {
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: var(--color-bg-deep);
  color: var(--color-heading);
  padding: 0.125rem 0.5rem;
}
input.invisible-input-edit:focus {
  border-color: var(--color-primary);
}

/* ---------- Board ---------- */

.board {
  display: flex;
  flex: 1;
  align-items: stretch;
  gap: .75rem;
  width: 100%;
  min-height: 0;
  padding: 0.5rem 1.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

.column {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--column-width);
  padding-bottom: 1.5rem;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.column-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: 3.75rem;
  padding: 0.75rem 0;
  background: var(--color-bg);
  color: var(--color-muted);
}

/* Without a background, the head is its own rounded box, set apart from the cards. */
.column:not(.has-bg) .column-head {
  height: 3.25rem;
  margin-bottom: 0.5rem;
  padding: 0 0.5rem 0 0.75rem;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: none;
}

.column-head-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
}
.column:not(.has-bg) .column-head .invisible-input {
  color: var(--color-heading);
  font-weight: 650;
}

.column-head-actions {
  display: flex;
  align-items: center;
}

.swatch {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px dashed color-mix(in oklab, var(--muted-foreground) 60%, transparent);
}
.swatch[data-hue] {
  border-style: solid;
  background: oklch(0.72 0.14 var(--hue));
  border-color: oklch(0.62 0.15 var(--hue));
}
/* Drag handle that reorders columns */
.column-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  color: color-mix(in oklab, var(--muted-foreground) 60%, transparent);
  cursor: grab;
  touch-action: none;
}
.column-handle:hover,
.column-handle:focus-visible {
  background: var(--muted);
  color: var(--foreground);
}
.column-handle:active {
  cursor: grabbing;
}

.column.is-dragging {
  display: none;
}
.column-drop-placeholder {
  flex-shrink: 0;
  width: var(--column-width);
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  border: 2px dashed var(--color-primary);
  background: color-mix(in oklab, var(--color-primary) 10%, transparent);
}

/*
 * A column's own background color. It paints the whole column, head included,
 * down to the bottom of the window, with the same corner radius as other
 * column blocks. --column-fg is white or near-black, picked in JS for contrast
 * with --column-bg.
 */
.column.has-bg {
  border-radius: var(--radius-panel);
  background: var(--column-bg);
  color: var(--column-fg);
}
.column.has-bg .column-head {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  background: var(--column-bg);
  color: color-mix(in oklab, var(--column-fg) 88%, transparent);
}
.column.has-bg .column-handle {
  color: color-mix(in oklab, var(--column-fg) 60%, transparent);
}
.column.has-bg .column-handle:hover,
.column.has-bg .column-handle:focus-visible,
.column.has-bg .column-head .btn-ghost:hover {
  background: color-mix(in oklab, var(--column-fg) 14%, transparent);
  color: var(--column-fg);
}
.column.has-bg input.invisible-input-edit {
  background: color-mix(in oklab, var(--column-fg) 15%, transparent);
}
/* The inset box dissolves into the column's color; cards keep their own surface. */
.column.has-bg .column-body {
  padding-top: 0.25rem;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.column.has-bg .column-body.is-drag-over {
  background: color-mix(in oklab, var(--column-fg) 8%, transparent);
}
.column.has-bg .drop-placeholder {
  border-color: color-mix(in oklab, var(--column-fg) 50%, transparent);
  background: color-mix(in oklab, var(--column-fg) 10%, transparent);
}

/* Small square showing a column background in menus */
.bg-swatch {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  border-radius: 0.125rem;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--foreground) 15%, transparent);
}
.bg-swatch.is-none {
  box-shadow: none;
  border: 1px dashed color-mix(in oklab, var(--muted-foreground) 60%, transparent);
}

.column-body {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 100%;
  min-height: 10rem;
  padding: 1rem;
  border-radius: var(--radius-panel);
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  box-shadow: none;
  transition: background-color var(--transition), border-color var(--transition);
}
.column-body.is-drag-over {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.card-list {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.add-column {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--column-width);
  padding-bottom: 1.5rem;
}
.add-column-spacer {
  height: 3.75rem;
  flex-shrink: 0;
}
.add-column .btn {
  width: 100%;
  height: auto;
  min-height: 5rem;
  padding: 1rem;
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: none;
  color: var(--color-heading);
}
.add-column .btn:not(:disabled):hover {
  border-color: var(--color-primary);
  background: var(--color-surface-hover);
  color: var(--color-heading);
}
.add-column-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-muted);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* The drop indicator while dragging a card */
.drop-placeholder {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-card);
  border: 2px dashed var(--color-primary);
  background: color-mix(in oklab, var(--color-primary) 10%, transparent);
}

/* ---------- Card ---------- */

.card {
  position: relative;
  width: 100%;
  margin-bottom: 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-xl);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.card.is-dragging {
  display: none;
}
.card.is-selected .card-box {
  border-color: var(--color-primary);
  background: var(--color-surface-hover);
}

.card-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  padding: 0.5rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: none;
  transition:
    border-color var(--transition),
    background-color var(--transition);
}
.card:hover .card-box {
  border-color: var(--color-primary);
  background: var(--color-surface-hover);
}

.card-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}
/* The color dot, centered on the title's first line */
.card-swatch {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  flex-shrink: 0;
}

.card-title {
  color: var(--color-heading);
  font-size: 1rem;
  line-height: 1.375;
  font-weight: 650;
  letter-spacing: var(--tracking-heading);
  overflow-wrap: anywhere;
}
.card-title.is-untitled {
  color: color-mix(in oklab, var(--muted-foreground) 70%, transparent);
}

.card-action {
  align-self: start;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.card-content {
  padding: 0 0.75rem;
  border-top-width: 1px;
}

.card-body-wrap {
  display: grid;
  grid-template-rows: 1fr;
  transition:
    grid-template-rows 200ms ease-out,
    margin 200ms ease-out;
}
.card-body-wrap.is-collapsed {
  grid-template-rows: 0fr;
  margin-top: -0.5rem;
}
.card-body-wrap > div {
  overflow: hidden;
}
.card-body-wrap .card-content {
  padding-top: 0.5rem;
}

.card-more {
  margin: 0.75rem 0 0;
  color: var(--muted-foreground);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding-top: 0.5rem;
}

/* ---------- Meta: tasks, deadline, priority ---------- */

.meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}
.card .meta {
  margin-top: 0.5rem;
}

.task-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
}
.task-indicator svg {
  width: 0.875rem;
  height: 0.875rem;
}
.task-indicator .track {
  opacity: 0.3;
}
.task-indicator .arc {
  transition: stroke-dashoffset 200ms;
}
.task-indicator span {
  margin-top: 1px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
}

.deadline-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--muted-foreground);
}
.deadline-chip svg.icon {
  width: 0.875rem;
  height: 0.875rem;
}
.deadline-chip:hover {
  color: var(--foreground);
}
.deadline-chip.is-soon {
  color: color-mix(in oklab, var(--amber) 80%, transparent);
}
.deadline-chip.is-overdue {
  color: color-mix(in oklab, var(--destructive) 80%, transparent);
}

.priority-chip {
  display: inline-flex;
  align-items: center;
}
.priority-chip svg.icon {
  width: 0.875rem;
  height: 0.875rem;
  fill: currentColor;
  stroke-width: 1;
}
.priority-chip.is-high {
  color: color-mix(in oklab, var(--destructive) 80%, transparent);
}
.priority-chip.is-medium {
  color: color-mix(in oklab, var(--amber-medium) 80%, transparent);
}
.priority-chip.is-low {
  color: var(--muted-foreground);
}
.priority-chip.is-none {
  color: var(--muted-foreground);
}
.priority-chip.is-none svg.icon {
  fill: none;
  stroke-width: 2;
}
.priority-chip.is-none:hover {
  color: var(--foreground);
}

/* ---------- Tag chip ---------- */

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  margin: 0 0.1em;
  padding: 1px 0.375rem;
  border-radius: var(--radius-control);
  font-size: 13px;
  line-height: 1.125rem;
  background: color-mix(in oklab, var(--color-purple) 16%, transparent);
  border: 1px solid color-mix(in oklab, var(--color-purple) 40%, transparent);
  color: var(--color-heading);
  vertical-align: baseline;
}
.tag-chip svg.icon {
  width: 0.875rem;
  height: 0.875rem;
  margin-top: 1px;
  stroke-width: 2.5;
  color: var(--color-purple);
}

/* ---------- Rendered Markdown ---------- */

.md {
  position: relative;
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word;
  color: var(--card-foreground);
}
.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0.75rem 0;
}
.md h1,
.md h2,
.md h3 {
  margin: 1.5rem 0 0.5rem;
  line-height: 1.25;
  letter-spacing: var(--tracking-heading);
}
.md h1 {
  font-size: 1.25rem;
  font-weight: 700;
}
.md h2 {
  font-size: 1.125rem;
  font-weight: 700;
}
.md h3 {
  font-size: 1rem;
  font-weight: 600;
}
.md ul,
.md ol {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
}
.md ul {
  list-style: disc;
}
.md ol {
  list-style: decimal;
}
.md li {
  margin: 0.25rem 0;
  padding-left: 0.25rem;
}
.md li::marker {
  color: var(--muted-foreground);
}
.md li.task {
  position: relative;
  list-style: none;
}
.md li.task.is-checked {
  color: color-mix(in oklab, var(--muted-foreground) 70%, transparent);
}
.checkbox {
  position: absolute;
  top: 0.3em;
  left: -1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 2px;
  border: 1px solid var(--color-border-control);
  background: var(--color-bg-deep);
  color: var(--color-on-primary);
  cursor: pointer;
}
.checkbox.is-checked {
  border-color: var(--color-primary);
  background: var(--color-primary);
}
.checkbox svg.icon {
  width: 0.75rem;
  height: 0.75rem;
  stroke-width: 3;
}
.md code {
  border-radius: 2px;
  border: 0;
  background: var(--color-bg-deep);
  padding: 0.15em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-purple);
}
.md pre {
  margin: 0.625rem 0;
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: var(--color-bg-deep);
  padding: var(--space-4);
  line-height: 1.5;
}
.md pre code {
  border: 0;
  background: none;
  padding: 0;
  color: var(--color-text);
  font-size: 0.8125rem;
}
.md blockquote {
  margin: 0.75rem 0;
  padding: 0.125rem 0 0.125rem 0.75rem;
  border-left: 4px solid var(--color-info);
}
.md a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.md a:hover {
  color: var(--color-primary-hover);
}
.md mark {
  border-radius: 0.125rem;
  padding: 0 0.15em;
  background: color-mix(in oklab, var(--primary) 18%, transparent);
  color: inherit;
}
.md hr {
  margin: 1rem 0;
  border-top-width: 1px;
}

/* ---------- Card panel (view / edit) ---------- */

.card-panel {
  position: relative;
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  transition:
    width 200ms linear,
    padding 200ms linear;
}
.card-panel.is-open {
  width: calc(var(--card-panel-width) + 1rem);
  padding: 0.5rem;
}

.card-panel-inner {
  display: flex;
  flex-direction: column;
  width: var(--card-panel-width);
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-raised);
}

.panel-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: max(0.625rem, env(safe-area-inset-top)) 0.75rem 0.5rem;
  border-bottom-width: 1px;
}
.panel-header-left,
.panel-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.panel-header .meta svg.icon,
.panel-header .meta .task-indicator svg {
  width: 1rem;
  height: 1rem;
}

.panel-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom));
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding-top: 0.5rem;
}

.title-editor {
  width: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  padding: 0.375rem 0;
  color: var(--color-heading);
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.title-preview {
  padding: 0.75rem 0 0.375rem;
  color: var(--color-heading);
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.025em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.title-preview.is-untitled {
  color: color-mix(in oklab, var(--muted-foreground) 50%, transparent);
}

.body-editor {
  flex: 1;
  width: 100%;
  min-height: 12rem;
  resize: none;
  background: transparent;
  padding: 0.5rem 0;
  color: var(--color-heading);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.75;
}
.body-preview {
  flex: 1;
  padding-top: 0.5rem;
  cursor: text;
}
.body-preview.is-empty {
  color: color-mix(in oklab, var(--muted-foreground) 50%, transparent);
}

/* Jira card: one URL field, then the rendered issue list. */
.url-editor {
  width: 100%;
  margin: 0.5rem 0;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: transparent;
  padding: 0.375rem 0.5rem;
  color: var(--color-heading);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
.url-editor.is-invalid {
  border-color: var(--color-danger);
}
.jira-panel-body {
  flex: 1;
  overflow-y: auto;
}

.md .jira-issue {
  font-weight: 600;
}
.md .jira-children {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.md .jira-children li {
  margin: 0.125rem 0;
}
.jira-status {
  display: inline-block;
  border-radius: var(--radius-control);
  padding: 0 0.375em;
  background: color-mix(in oklab, var(--muted-foreground) 20%, transparent);
  color: var(--color-text);
  font-size: 0.75em;
  font-weight: 600;
  line-height: 1.6;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: 0.1em;
}
.jira-status.is-indeterminate {
  background: color-mix(in oklab, var(--color-info) 25%, transparent);
}
.jira-status.is-done {
  background: color-mix(in oklab, var(--color-success) 25%, transparent);
}
.md .jira-empty,
.md .jira-updated {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.title-editor::placeholder,
.body-editor::placeholder,
.url-editor::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--color-muted);
  opacity: 1;
}

.panel-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: color-mix(in oklab, var(--muted-foreground) 70%, transparent);
}

/* ---------- Menu / popover ---------- */

.menu {
  position: fixed;
  z-index: 60;
  min-width: 9rem;
  max-height: min(24rem, calc(100svh - 1rem));
  overflow-y: auto;
  padding: var(--space-2) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-raised);
  animation: pop-in 80ms ease-out;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
}

.menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.25rem 0.75rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu-item:hover,
.menu-item:focus-visible,
.menu-item.is-open {
  background: var(--color-surface-hover);
  color: var(--color-heading);
}
.menu-item:focus-visible {
  outline-offset: -2px;
}
.menu-item.is-destructive,
.menu-item.is-destructive:hover,
.menu-item.is-destructive:focus-visible {
  color: var(--color-danger);
}
.menu-item .menu-trailing {
  margin-left: auto;
  padding-left: 1rem;
}
.menu-item .chevron {
  color: var(--muted-foreground);
}

.menu-separator {
  height: 1px;
  margin: 0.25rem 0;
  background: var(--border);
}

.popover-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}
.popover-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.date-field {
  position: relative;
  display: flex;
  min-width: 11rem;
}
.date-input {
  width: 100%;
  min-height: 40px;
  height: 40px;
  padding: 0.25rem 2rem 0.25rem 0.55rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border-control);
  background: var(--color-bg-deep);
  color: var(--color-heading);
  font: inherit;
}
.date-input:focus {
  border-color: var(--color-primary);
}
.date-input.is-invalid {
  border-color: var(--color-danger);
}
.date-calendar {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  display: flex;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}
.date-calendar svg.icon {
  width: 1rem;
  height: 1rem;
}
.date-picker {
  position: absolute;
  right: 0;
  top: 0;
  width: 2rem;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.popover-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted-foreground);
}
.color-input {
  width: 2.5rem;
  height: 40px;
  padding: 0.125rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border-control);
  background: var(--color-bg-deep);
  cursor: pointer;
}

/* ---------- Toast ---------- */

.toast-layer {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--color-info);
  border-radius: var(--radius-control);
  background: var(--color-bg-deep);
  color: var(--color-text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-raised);
  pointer-events: auto;
  transition:
    opacity var(--transition),
    transform var(--transition);
}
.toast.is-entering,
.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}
.toast-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Confirm modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 55%);
  animation: fade-in 200ms ease-out;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.modal {
  width: 100%;
  max-width: 24rem;
  padding: clamp(1.5rem, 4vw, 2rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-raised);
  animation: pop-in 200ms ease-out;
}
.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 650;
  color: var(--color-heading);
}
.modal-description {
  margin: 0;
  color: var(--muted-foreground);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ---------- Small screens: one column per screen, full-screen panel ---------- */

@media (max-width: 767px) {
  .card-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    padding: 0;
    display: none;
  }
  .card-panel.is-open {
    display: block;
    width: 100%;
    padding: 0;
  }
  .card-panel-inner {
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }
  .column-head {
    padding: 0.75rem 0.25rem;
  }
}

@media (max-width: 429px) {
  .board {
    gap: 0;
    padding: 0;
    scroll-snap-type: x mandatory;
  }
  .column,
  .add-column {
    width: 100%;
    scroll-snap-align: center;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* ---------- Sidebar, auth, settings ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 15.5rem;
  min-height: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.sidebar-head,
.sidebar-foot {
  flex-shrink: 0;
  padding: 0.75rem;
}

.sidebar-head {
  padding-bottom: 0.25rem;
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-boards {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.25rem 0.5rem 0.75rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin-bottom: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-control);
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
}
.sidebar-item:hover {
  background: var(--color-surface);
  color: var(--color-heading);
}
.sidebar-item.is-active {
  background: var(--color-surface);
  color: var(--color-primary);
  text-decoration: none;
}

.sidebar-item-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
}
.sidebar-item-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  margin: 0.35rem 0.55rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(0 0 0 / 0.45);
}

.board-empty {
  margin: auto;
  max-width: 22rem;
  text-align: center;
  color: var(--muted-foreground);
}
.board-empty a {
  color: var(--primary);
  font-weight: 700;
}

.auth-body {
  overflow: auto;
  background: var(--color-bg);
}
.auth-page {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: var(--space-6);
}
.auth-card {
  width: min(28rem, 100%);
  padding: clamp(1.5rem, 4vw, 3rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-raised);
}
.auth-card h1 {
  margin: 0 0 var(--space-4);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  letter-spacing: -0.025em;
}
.hero__eyebrow {
  margin: 0 0 var(--space-4);
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-lead {
  margin: 0 0 var(--space-6);
  max-width: 58ch;
  color: var(--color-text);
  font-size: 1rem;
}
.field {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  color: var(--color-heading);
  font-size: 1rem;
  font-weight: 600;
}
.text-input,
.field input {
  width: 100%;
  min-height: 40px;
  height: 40px;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: var(--color-bg-deep);
  color: var(--color-heading);
  font-weight: 500;
}
.text-input:focus,
.field input:focus {
  border-color: var(--color-primary);
}
.text-input[aria-invalid="true"],
.field input[aria-invalid="true"] {
  border-color: var(--color-danger);
}
.auth-submit {
  width: 100%;
}
.form-error {
  margin: 0 0 var(--space-6);
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--color-danger);
  border-radius: var(--radius-control);
  background: var(--color-bg-deep);
  color: var(--color-danger);
  font-size: 0.875rem;
  font-weight: 650;
}

.settings-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.settings-wrap {
  flex: 1;
  overflow: auto;
  width: min(40rem, 100%);
  padding: 1.25rem 1.5rem 3rem;
}
.settings-heading {
  margin: 0;
  cursor: default;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
}
.settings-section {
  margin-top: 1.5rem;
}
.settings-section h2 {
  margin: 0 0 var(--space-4);
  font-size: clamp(1.5rem, 3vw, 1.75rem);
}
.settings-section p {
  margin: 0 0 0.9rem;
  font-size: 0.875rem;
}
.settings-create {
  display: flex;
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.settings-create .field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.settings-create .settings-btn {
  min-height: 40px;
  height: 40px;
  padding: 0 1.15rem;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}
.settings-row .text-input {
  flex: 1;
}
.settings-empty {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}
.token-row {
  align-items: flex-start;
}
.token-meta {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  font-size: 0.875rem;
}
.token-meta span {
  font-size: 0.75rem;
}
.token-reveal {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--color-success);
  border-radius: var(--radius-control);
  background: var(--color-bg-deep);
}
.token-reveal p {
  margin: 0 0 var(--space-2);
  font-size: 0.875rem;
}
.notice__title {
  color: var(--color-success);
  font-weight: 650;
}
.token-reveal-row {
  display: flex;
  gap: 0.5rem;
}
.token-reveal-row .text-input {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
code,
pre {
  font-family: var(--font-code);
  font-size: 0.9em;
}
:not(pre) > code {
  padding: 0.15em 0.4em;
  border-radius: 2px;
  background: var(--color-bg-deep);
  color: var(--color-purple);
}

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    transform: translateX(-105%);
    transition: transform 150ms ease;
    box-shadow: var(--elevation-3);
  }
  .sidebar.is-open {
    transform: none;
  }
  .settings-create,
  .token-reveal-row {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-row {
    flex-wrap: wrap;
  }
}
@media (min-width: 801px) {
  .sidebar-toggle,
  .sidebar-backdrop {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
