/* ---------- Fonts ---------- */

/* Served from here, so the board looks the same offline. Ranges as Google Fonts splits them. */
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */

:root {
  --paper: #eceff3;
  --surface: #ffffff;
  --sunken: #e2e7ed;
  --ink: #17202b;
  --ink-2: #536070;
  --ink-3: #7d8897;
  --line: #d6dce4;
  --line-strong: #b8c1cc;
  --focus: #2f5bd3;
  --danger: #b42335;
  --high: #b85c00;
  --feature: #2f5bd3;
  --idea: #8a5a00;
  --tint: var(--ink);
  --on-tint: var(--surface);
  --shadow-pop: 0 18px 50px -12px rgb(15 25 40 / 0.35);
  --font: "Schibsted Grotesk", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #10151c;
  --surface: #19202a;
  --sunken: #141a22;
  --ink: #e4e9f0;
  --ink-2: #a3adbb;
  --ink-3: #737e8e;
  --line: #283140;
  --line-strong: #3a4556;
  --focus: #86a6ff;
  --danger: #ff7b8a;
  --high: #f0a050;
  --feature: #86a6ff;
  --idea: #e2b24f;
  --shadow-pop: 0 18px 50px -12px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10151c;
    --surface: #19202a;
    --sunken: #141a22;
    --ink: #e4e9f0;
    --ink-2: #a3adbb;
    --ink-3: #737e8e;
    --line: #283140;
    --line-strong: #3a4556;
    --focus: #86a6ff;
    --danger: #ff7b8a;
    --high: #f0a050;
    --feature: #86a6ff;
    --idea: #e2b24f;
    --shadow-pop: 0 18px 50px -12px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.i {
  display: inline-flex;
  flex: none;
}

.i svg {
  display: block;
}

kbd {
  font: inherit;
  font-size: 11.5px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-3);
}

/* ---------- Layout ---------- */

.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  height: 100dvh;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.scrim {
  display: none;
}

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--sunken);
  font-weight: 600;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  filter: brightness(0.97);
}

.btn-primary {
  background: var(--tint);
  color: var(--on-tint);
  transition: background-color 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
  filter: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

:root[data-theme="dark"] .btn-danger {
  color: #1a0b0e;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 13.5px;
}

.is-danger,
.btn-quiet.is-danger {
  color: var(--danger);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
}

.icon-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
}

.icon-btn.is-on {
  color: var(--tint);
}

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.input:focus {
  border-color: var(--focus);
  outline: 2px solid color-mix(in srgb, var(--focus) 30%, transparent);
  outline-offset: 0;
}

textarea.input {
  resize: vertical;
  line-height: 1.55;
}

.input-lg {
  font-size: 18px;
  font-weight: 650;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.hint {
  font-size: 13px;
  color: var(--ink-3);
}

.filter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-3);
}

.filter:focus-within {
  border-color: var(--focus);
}

.filter-input {
  width: 100%;
  min-width: 0;
  padding: 7px 0;
  border: 0;
  background: transparent;
  outline: none;
}

/* ---------- Menus ---------- */

.menu {
  position: relative;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.menu-list > button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.menu-list > button:hover:not(:disabled) {
  background: var(--paper);
}

/* ---------- App icons ---------- */

.app-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--s);
  height: var(--s);
  border-radius: calc(var(--s) * 0.27);
  overflow: hidden;
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

.app-icon.is-letter {
  background: var(--cat);
  color: #fff;
  font-size: calc(var(--s) * 0.4);
  letter-spacing: -0.02em;
}

.app-icon.is-emoji {
  background: color-mix(in srgb, var(--cat) 14%, var(--surface));
  font-size: calc(var(--s) * 0.58);
}

.app-icon.is-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 18px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 10px 8px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.brand-name {
  flex: 1;
  min-width: 0;
}

.side-hide {
  margin: -3px 0;
}

.brand-mark {
  display: inline-flex;
  align-items: flex-start;
  gap: 2.5px;
  padding: 5px;
  height: 26px;
  border-radius: 7px;
  background: var(--ink);
}

.brand-mark i {
  width: 4px;
  border-radius: 2px;
  background: var(--surface);
}

.brand-mark i:nth-child(1) { height: 16px; }
.brand-mark i:nth-child(2) { height: 11px; }
.brand-mark i:nth-child(3) { height: 6px; }

.switch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-2);
  text-align: left;
}

.switch-label {
  flex: 1;
}

.switch-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--ink-2);
}

.side-link:hover {
  background: var(--paper);
  color: var(--ink);
}

.side-link[aria-current="page"] {
  background: var(--paper);
  color: var(--ink);
}

.side-cats {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 4px -4px 0;
  padding: 0 4px;
}

.side-cat {
  margin-top: 12px;
}

.side-cat > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.side-cat > summary::-webkit-details-marker {
  display: none;
}

.side-cat > summary:hover {
  color: var(--ink);
}

.side-cat:not([open]) > summary {
  opacity: 0.7;
}

.cat-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 3px;
  background: var(--cat);
}

.side-cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-cat-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.side-cat ul {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.side-app {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--ink);
}

.side-app:hover {
  background: var(--paper);
}

.side-app[aria-current="page"] {
  background: color-mix(in srgb, var(--cat) 13%, var(--surface));
  box-shadow: inset 3px 0 var(--cat);
  font-weight: 650;
}

.side-app-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-empty {
  padding: 2px 10px 0 28px;
  font-size: 13px;
  color: var(--ink-3);
}

.side-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* ---------- App band (the current app, in its category color) ---------- */

.band {
  flex: none;
  padding: 26px 32px 0;
  background: var(--tint);
  color: var(--on-tint);
  transition: background-color 0.35s ease, color 0.35s ease;
}

.band :focus-visible {
  outline-color: currentColor;
}

.band-top {
  display: flex;
  align-items: center;
  gap: 18px;
}

.band .app-icon.is-letter,
.band .app-icon.is-emoji {
  background: color-mix(in srgb, var(--on-tint) 16%, transparent);
  color: var(--on-tint);
}

.band .app-icon {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--on-tint) 22%, transparent);
}

.band-text {
  min-width: 0;
}

.band-cat {
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0.78;
}

.band h1 {
  font-size: clamp(28px, 3.6vw, 42px);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.band-desc {
  display: -webkit-box;
  max-width: 72ch;
  margin-top: 6px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  opacity: 0.85;
}

.band-tabs {
  display: flex;
  gap: 26px;
  margin-top: 20px;
}

.band-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 12px;
  border-bottom: 3px solid transparent;
  font-weight: 650;
  opacity: 0.72;
}

.band-tab:hover {
  opacity: 1;
}

.band-tab[aria-current="page"] {
  border-bottom-color: currentColor;
  opacity: 1;
}

.tab-count {
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--on-tint) 18%, transparent);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.menu-toggle,
.switch-toggle {
  display: none;
}

.band .menu-toggle,
.band .switch-toggle {
  color: inherit;
}

/* ---------- Board ---------- */

.view-board {
  overflow: hidden;
}

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.board-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.board-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.board-tab {
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 650;
  color: var(--ink-2);
}

.board-tab:hover {
  background: var(--paper);
  color: var(--ink);
}

.board-tab[aria-current="page"] {
  background: color-mix(in srgb, var(--tint) 14%, var(--surface));
  color: var(--ink);
}

.board-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.board-tools .filter {
  width: 220px;
}

.lanes {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 32px 28px;
  overflow: auto;
}

.lane {
  display: flex;
  flex: 0 0 292px;
  flex-direction: column;
  max-height: 100%;
  border-radius: 12px;
  background: var(--sunken);
}

.lane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 6px 14px;
}

.lane-head h3 {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.lane-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.lane-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 8px;
  padding: 4px 10px;
  overflow-y: auto;
}

.card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: grab;
  /* A long press picks the card up: no text selection or link menu, but scrolling still works. */
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

.card:hover {
  border-color: var(--line-strong);
}

.card.is-dragging {
  opacity: 0.35;
}

/* The copy that follows the pointer; drag.js moves it with a transform. */
.drag-clone {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  margin: 0;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-pop);
  cursor: grabbing;
  pointer-events: none;
  rotate: 2deg;
}

.card-title {
  font-weight: 550;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.prio {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.prio i {
  width: 3px;
  border-radius: 1px;
  background: var(--line-strong);
}

.prio i:nth-child(1) { height: 4px; }
.prio i:nth-child(2) { height: 7px; }
.prio i:nth-child(3) { height: 10px; }
.prio i:nth-child(4) { height: 12px; }

.prio i.on { background: var(--ink-3); }
.prio-high i.on { background: var(--high); }
.prio-urgent i.on { background: var(--danger); }

.tag {
  font-weight: 650;
}

.tag-bug { color: var(--danger); }
.tag-feature { color: var(--feature); }
.tag-idea { color: var(--idea); }

.due,
.has-desc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.due.is-overdue {
  color: var(--danger);
  font-weight: 650;
}

.drop-marker {
  height: 3px;
  margin: -2px 2px;
  border-radius: 3px;
  background: var(--tint);
}

.composer {
  padding: 6px 10px 10px;
}

.composer-open {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
}

.composer-open:hover {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
}

.composer-input {
  resize: none;
}

.composer-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.lane-add {
  display: flex;
  flex: 0 0 220px;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
}

.lane-add:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

/* ---------- Notes ---------- */

.view-notes {
  overflow: hidden;
}

.notes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
}

.notes-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.notes-tools {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.notes-tools .filter {
  flex: 1;
}

.notes-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 20px;
}

.notes-group {
  padding: 12px 10px 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3);
}

.notes-empty {
  padding: 18px 12px;
  color: var(--ink-3);
}

.note-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 9px;
}

.note-item:hover {
  background: var(--paper);
}

.note-item[aria-current="page"] {
  background: color-mix(in srgb, var(--tint) 12%, var(--surface));
}

.note-item-title {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 13.5px;
  color: var(--ink-2);
}

.note-item-time {
  font-size: 12px;
  color: var(--ink-3);
}

.note-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 44px 0;
  background: var(--surface);
}

.note-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.note-back {
  display: none;
}

.note-status {
  flex: 1;
  font-size: 13px;
  color: var(--ink-3);
}

.note-status.is-error {
  color: var(--danger);
  font-weight: 600;
}

.note-title,
.note-body {
  width: 100%;
  max-width: 78ch;
  border: 0;
  background: transparent;
  outline: none;
}

.note-title {
  padding: 10px 0 4px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.note-title::placeholder,
.note-body::placeholder {
  color: var(--ink-3);
}

.note-body {
  flex: 1;
  min-height: 200px;
  padding: 10px 0 32px;
  resize: none;
  font-size: 16px;
  line-height: 1.7;
}

.note-meta {
  padding: 8px 0 14px;
  border-top: 1px solid var(--line);
  max-width: 78ch;
  font-size: 12.5px;
  color: var(--ink-3);
}

.note-placeholder {
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  color: var(--ink-2);
}

/* ---------- Settings ---------- */

.settings {
  width: 100%;
  max-width: 760px;
  padding: 28px 32px 56px;
}

.settings-section + .settings-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.settings-section h2 {
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.settings-text {
  max-width: 62ch;
  margin-bottom: 14px;
  color: var(--ink-2);
}

.icon-field,
.color-field {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.icon-field legend,
.color-field legend {
  margin-bottom: 8px;
  padding: 0;
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.color-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.color-choice:hover {
  color: var(--ink);
}

.color-choice.is-on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  color: var(--ink);
}

.color-choice .swatch,
.color-choice input[type="color"] {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  box-shadow: none;
  background: none;
  cursor: inherit;
}

.color-choice .swatch {
  background: var(--c);
}

.color-choice input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-choice input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 7px;
}

.color-choice input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 7px;
}

.icon-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.icon-controls {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.quick-emoji {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.emoji-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 18px;
  line-height: 1;
}

.emoji-btn:hover {
  border-color: var(--line-strong);
  background: var(--paper);
}

.icon-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.emoji-input {
  width: 90px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.settings .form-actions {
  justify-content: flex-start;
}

/* ---------- Home ---------- */

.home {
  padding: 36px 40px 64px;
}

.home-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 8px;
}

.home-title {
  flex: 1;
}

.home-title h1 {
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.home-title p {
  margin-top: 6px;
  color: var(--ink-2);
}

.home-cat {
  margin-top: 36px;
}

.home-cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.home-cat-head h2 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.home-cat-count {
  flex: 1;
  font-size: 13.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.home-cat-empty {
  padding: 18px 0;
  color: var(--ink-3);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.tile:hover {
  border-color: var(--cat);
  box-shadow: inset 0 0 0 1px var(--cat);
}

.tile-body {
  min-width: 0;
}

.tile h3 {
  font-size: 16px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.tile-desc {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  color: var(--ink-2);
}

.tile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-3);
}

.home-empty {
  max-width: 560px;
  margin-top: 40px;
  padding: 28px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
}

.home-empty h2 {
  font-size: 22px;
  font-weight: 800;
}

.home-empty p {
  margin: 8px 0 18px;
  color: var(--ink-2);
}

.fatal {
  max-width: 560px;
  padding: 48px 40px;
}

.fatal h1 {
  font-size: 28px;
  font-weight: 800;
}

.fatal p {
  margin: 10px 0 20px;
  color: var(--ink-2);
}

/* ---------- Dialogs ---------- */

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}

.dialog-sm { width: min(440px, calc(100vw - 32px)); }
.dialog-lg { width: min(720px, calc(100vw - 32px)); }

.dialog::backdrop {
  background: rgb(12 18 26 / 0.5);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 4px 24px;
}

.dialog-head h2 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.dialog-body {
  padding: 12px 24px 24px;
}

.dialog-message {
  margin-bottom: 18px;
  color: var(--ink-2);
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.spacer {
  flex: 1;
}

.task-form .hint {
  margin: -6px 0 14px;
}

.switcher {
  padding: 8px 16px 16px;
}

.switch-input {
  padding: 10px 12px;
  font-size: 16px;
}

.switch-list {
  max-height: min(420px, 60dvh);
  margin: 10px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.switch-list li[role="option"] {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.switch-list li.is-active {
  background: var(--paper);
}

.switch-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch-cat {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 50%;
  overflow: hidden;
  font-size: 13px;
  color: var(--ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch-empty {
  padding: 16px 10px;
  color: var(--ink-3);
}

.cat-list {
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.cat-row .input {
  flex: 1;
}

.cat-row-count {
  width: 56px;
  font-size: 13px;
  text-align: right;
  color: var(--ink-3);
}

.cat-add {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.swatch {
  display: block;
  width: 28px;
  height: 28px;
  flex: none;
  border: 2px solid var(--surface);
  border-radius: 8px;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
  list-style: none;
}

.swatch-menu > summary::-webkit-details-marker {
  display: none;
}

.swatch.is-on {
  box-shadow: 0 0 0 2px var(--ink);
}

.swatch-grid {
  right: auto;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 8px;
  min-width: 0;
  padding: 10px;
}

.swatch-custom {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.swatch-custom input {
  width: 32px;
  height: 26px;
  padding: 0;
  border: 0;
  background: none;
}

.icon-preview {
  flex: none;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  inset: auto 20px 20px auto;
  max-width: min(420px, calc(100vw - 40px));
  margin: 0;
  padding: 11px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
}

.toast[data-tone="error"] {
  background: var(--danger);
  color: #fff;
}

/* Only while it has a button (and so is open): a closed popover must keep its display: none. */
.toast.has-action {
  display: flex;
  align-items: center;
  gap: 14px;
}

.toast-text {
  flex: 1;
  min-width: 0;
}

.toast-action {
  flex: none;
  padding: 3px 10px;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  color: inherit;
  font-weight: 750;
}

.toast-action:hover {
  background: color-mix(in srgb, currentColor 28%, transparent);
}

/* Only a toast with a button takes clicks. */
.toast.has-action.is-visible {
  pointer-events: auto;
}

/* ---------- Sync status ---------- */

.brand-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.25;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  flex: none;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0;
  white-space: nowrap;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  line-height: 1.3;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sync-badge:hover .sync-pill {
  border-color: var(--line-strong);
  color: var(--ink);
}

.sync-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-3);
}

.sync-badge[data-state="syncing"] .sync-dot {
  background: var(--focus);
  animation: sync-pulse 0.8s ease-in-out infinite alternate;
}

.sync-badge[data-state="pending"] .sync-dot {
  background: var(--high);
}

.sync-badge[data-state="offline"] .sync-dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px currentColor;
}

/* The two that need the owner: louder, but still small. */
.sync-badge[data-state="signed-out"],
.sync-badge[data-state="problem"] {
  color: var(--ink);
}

.sync-badge[data-state="signed-out"] .sync-dot {
  background: var(--high);
}

.sync-badge[data-state="signed-out"] .sync-pill {
  border-color: color-mix(in srgb, var(--high) 50%, transparent);
  background: color-mix(in srgb, var(--high) 10%, var(--surface));
}

.sync-badge[data-state="problem"] .sync-dot {
  background: var(--danger);
}

.sync-badge[data-state="problem"] .sync-pill {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

@keyframes sync-pulse {
  from { opacity: 1; }
  to { opacity: 0.3; }
}

/* Under the name in the sidebar: a quiet status line rather than a pill. */
.brand .sync-badge {
  min-height: 0;
  margin: 2px 0 -2px -7px;
}

.brand .sync-pill {
  padding: 1px 7px;
  border-color: transparent;
  background: transparent;
}

.brand .sync-badge:hover .sync-pill {
  background: var(--paper);
}

/* In the app's colored band everything is drawn in the band's own text color. */
.band .sync-badge {
  color: inherit;
}

.band .sync-pill {
  border-color: color-mix(in srgb, currentColor 35%, transparent);
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.band .sync-badge:hover .sync-pill {
  border-color: currentColor;
  color: inherit;
}

.band .sync-badge[data-state] .sync-dot {
  background: currentColor;
}

.band .sync-badge[data-state="offline"] .sync-dot {
  background: transparent;
}

.band .sync-badge[data-state="signed-out"] .sync-pill,
.band .sync-badge[data-state="problem"] .sync-pill {
  border-color: var(--on-tint);
  background: var(--on-tint);
  color: var(--tint);
}

/* The header's copy is for when the sidebar (with its own) is out of view. */
.main .sync-badge {
  display: none;
}

/* At the end of the row on wide screens, so a changing label never moves the title. */
.band-top .sync-badge {
  order: 1;
  align-self: flex-start;
  margin-left: auto;
}

.home-head .sync-badge {
  order: 1;
}

.home-head > .btn {
  order: 2;
}

/* The sidebar footer's menu opens upwards, from the end of its row. */
.side-foot .menu {
  margin-left: auto;
}

.side-foot .menu-list {
  top: auto;
  bottom: calc(100% + 4px);
}

.busy-text {
  padding: 22px 24px;
  font-weight: 650;
}

/* ---------- Sync problems ---------- */

.problems {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.problem {
  --accent: var(--ink-3);
  padding: 14px 16px 12px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 3px 0 var(--accent);
}

.problem[data-kind="conflict"] { --accent: var(--high); }
.problem[data-kind="refused"] { --accent: var(--danger); }

.problem-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.problem-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.problem-time {
  flex: none;
  font-size: 12.5px;
  color: var(--ink-3);
}

.problem-message {
  margin-top: 2px;
  font-size: 14px;
  color: var(--ink-2);
}

.problem-field {
  margin-top: 12px;
}

.problem-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.problem-text {
  display: block;
  max-height: 40vh;
  font-size: 14px;
}

.problem-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.problems-empty {
  padding: 20px 0 8px;
  text-align: center;
  color: var(--ink-3);
}

/* ---------- Login ---------- */

body.signed-out .shell {
  grid-template-columns: minmax(0, 1fr);
}

body.signed-out .sidebar {
  display: none;
}

.login {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
  padding: 32px 16px;
}

.login-card {
  width: min(400px, 100%);
  padding: 30px 32px 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.login h1 {
  font-size: 30px;
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.login-text {
  margin: 8px 0 22px;
  color: var(--ink-2);
}

.login-error {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--danger);
}

.login-error:empty {
  display: none;
}

.login-actions .btn {
  width: 100%;
  padding: 10px 14px;
}

/* ---------- Another window has the data ---------- */

.elsewhere {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.elsewhere p {
  flex: 1;
  min-width: 0;
}

.elsewhere-bar {
  position: fixed;
  inset: auto 20px 20px auto;
  z-index: 20;
  max-width: min(520px, calc(100vw - 40px));
  padding: 10px 10px 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-pop);
}

.elsewhere-bar .btn-primary {
  background: var(--surface);
  color: var(--ink);
}

.elsewhere-note {
  margin: 8px 24px 0;
  padding: 10px 10px 10px 14px;
  border-radius: 10px;
  background: var(--sunken);
}

/* ---------- Hidden sidebar (wide screens; narrow ones use the slide-in drawer) ---------- */

@media (min-width: 821px) {
  :root[data-sidebar="hidden"] .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  :root[data-sidebar="hidden"] .sidebar {
    display: none;
  }

  :root[data-sidebar="hidden"] .menu-toggle,
  :root[data-sidebar="hidden"] .switch-toggle {
    display: inline-grid;
  }

  :root[data-sidebar="hidden"] .main .sync-badge {
    display: inline-flex;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 1100px) {
  .field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 899px) {
  .notes {
    grid-template-columns: minmax(0, 1fr);
  }

  .notes.has-current .notes-list,
  .notes:not(.has-current) .note-editor {
    display: none;
  }

  .note-back {
    display: inline-flex;
  }

  .note-editor {
    padding: 10px 16px 0;
  }

  .note-title {
    font-size: 24px;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  body.nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-pop);
  }

  body.nav-open .scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    background: rgb(12 18 26 / 0.45);
  }

  .menu-toggle,
  .switch-toggle {
    display: inline-grid;
  }

  /* Big enough to tap; the pill inside stays small. */
  .main .sync-badge {
    display: inline-flex;
  }

  /* The menu and switch buttons and the badge get a row of their own, so the title keeps the full width. */
  .band-top,
  .home-head {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 12px;
  }

  .band-top .menu-toggle,
  .home-head .menu-toggle {
    grid-area: 1 / 1;
  }

  .band-top .switch-toggle,
  .home-head .switch-toggle {
    grid-area: 1 / 2;
  }

  .band-top .sync-badge,
  .home-head .sync-badge {
    grid-area: 1 / 3;
    justify-self: start;
    margin: 0;
  }

  .home-head > .btn {
    grid-area: 1 / 4;
  }

  .band-top .app-icon {
    grid-area: 2 / 1;
  }

  .band-top .band-text {
    grid-area: 2 / 2 / 3 / 5;
  }

  .home-head {
    row-gap: 10px;
  }

  .home-title {
    grid-area: 2 / 1 / 3 / 5;
  }

  /* Tap targets of at least 44 px; the icons inside keep their size. */
  .menu-toggle,
  .switch-toggle,
  .dialog-head .icon-btn,
  .note-bar .icon-btn,
  .board-bar .menu > summary {
    width: 44px;
    height: 44px;
  }

  .board-tab,
  .board-bar .btn,
  .board-bar .filter,
  .note-bar .btn,
  .side-foot .btn,
  .dialog-actions .btn,
  .form-actions .btn,
  .composer-open,
  .menu-list > button {
    min-height: 44px;
  }

  .board-tab {
    display: inline-flex;
    align-items: center;
  }

  /* The column's menu is as big to tap without making its header taller. */
  .lane-head .menu > summary {
    width: 44px;
    height: 44px;
    margin: -8px 0 -6px;
  }

  .sync-badge,
  .brand .sync-badge {
    min-height: 44px;
  }

  /* Under the name, the pill stays where it was; the rest of the tap area is below it. */
  .brand .sync-badge {
    align-items: flex-start;
    margin-bottom: -12px;
  }

  .toast-action {
    min-height: 44px;
    margin: -10px -8px -10px 0;
    padding: 0 14px;
  }

  .side-foot .menu > summary {
    width: 44px;
    height: 44px;
  }

  .problem .btn {
    min-height: 44px;
  }

  .login-card {
    padding: 24px 20px 26px;
  }

  .band {
    padding: 14px 16px 0;
  }

  .band .app-icon {
    --s: 44px !important;
  }

  .band-tabs {
    gap: 20px;
    margin-top: 12px;
  }

  .board-bar {
    padding: 10px 16px;
  }

  .board-tools {
    width: 100%;
  }

  .board-tools .filter {
    flex: 1;
    width: auto;
  }

  /* One column per swipe. */
  .lanes {
    padding: 14px 16px 20px;
    scroll-padding-inline: 16px;
    scroll-snap-type: x mandatory;
  }

  .lane,
  .lane-add {
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .lane {
    flex-basis: min(86vw, 320px);
  }

  /* While a card is dragged the columns scroll by themselves near the edges; snapping would fight that. */
  .lanes:has(.is-dragging) {
    scroll-snap-type: none;
  }

  .home {
    padding: 18px 16px 48px;
  }

  .settings {
    padding: 20px 16px 48px;
  }

  .icon-row {
    flex-direction: column;
  }

  /* Delete goes on a line of its own, under Cancel and Save, so the row fits a narrow dialog. */
  .dialog-actions:has(.is-danger) {
    flex-wrap: wrap;
  }

  .dialog-actions .btn.is-danger {
    order: 1;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  /* A category's name gets the width of the dialog; its count and buttons go on the line below. */
  .cat-row {
    flex-wrap: wrap;
    row-gap: 2px;
  }

  .cat-row + .cat-row {
    border-top: 1px solid var(--line);
  }

  .cat-row .input {
    flex-basis: calc(100% - 46px);
  }

  .cat-row-count {
    flex: 1;
    width: auto;
    padding-inline-start: 40px;
    text-align: start;
  }

  .cat-row .icon-btn {
    width: 44px;
    height: 44px;
  }

  .cat-row .swatch-menu > .swatch {
    width: 34px;
    height: 34px;
  }

  .color-row .swatch {
    width: 34px;
    height: 34px;
  }

  .emoji-btn {
    width: 40px;
    height: 40px;
  }

  /* In the switcher, the app's name gets the whole row and its category goes underneath. */
  .switch-list li[role="option"] {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
  }

  .switch-list li .app-icon {
    grid-row: 1 / 3;
  }

  .switch-cat {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
