:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f4f5f7;
  --panel: #ffffff;
  --hover: #eef0f3;
  --selected: #dfe3e9;
  --line: #dde1e6;
  --line-soft: #eceef1;
  --text: #1d2430;
  --muted: #7a828e;
  --faint: #a7adb6;
  --accent: #1f6fe0;
  --accent-soft: #e6effc;
  --green: #22a05a;
  --red: #e0443e;
  --yellow: #f2b705;
  --teal: #2a9d8f;
  --row-selected: #d8e6fb;
  --check-border: #b4bac3;
  --shimmer: #f6f7f9;
  --toast-bg: #1d2430;
  --toast-action: #9fc2ff;
  --note-border: #f1d69a;
  --note-bg: #fff8e7;
  --note-text: #755209;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    system-ui,
    sans-serif;
  font-size: 15px;
}

/* Dark theme: follows the device unless a theme is picked (theme.js sets
   data-theme on <html>). Keep both blocks the same. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1e1f23;
    --sidebar: #25262b;
    --panel: #2a2b31;
    --hover: #303238;
    --selected: #3a3d45;
    --line: #3b3e45;
    --line-soft: #303237;
    --text: #e4e6ea;
    --muted: #9aa1ac;
    --faint: #6d737d;
    --accent: #4a8ff0;
    --accent-soft: #24385a;
    --green: #34b36a;
    --red: #ef5a54;
    --yellow: #f2b705;
    --teal: #3bb3a4;
    --row-selected: #2b4672;
    --check-border: #5d636d;
    --shimmer: #383a40;
    --toast-bg: #3c3f47;
    --toast-action: #9fc2ff;
    --note-border: #6b5520;
    --note-bg: #2f2814;
    --note-text: #f1d69a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e1f23;
  --sidebar: #25262b;
  --panel: #2a2b31;
  --hover: #303238;
  --selected: #3a3d45;
  --line: #3b3e45;
  --line-soft: #303237;
  --text: #e4e6ea;
  --muted: #9aa1ac;
  --faint: #6d737d;
  --accent: #4a8ff0;
  --accent-soft: #24385a;
  --green: #34b36a;
  --red: #ef5a54;
  --yellow: #f2b705;
  --teal: #3bb3a4;
  --row-selected: #2b4672;
  --check-border: #5d636d;
  --shimmer: #383a40;
  --toast-bg: #3c3f47;
  --toast-action: #9fc2ff;
  --note-border: #6b5520;
  --note-bg: #2f2814;
  --note-text: #f1d69a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

svg.icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
}

/* Layout */

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  padding: 14px 10px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--line-soft);
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 8px 4px;
  font-weight: 650;
  font-size: 14px;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.nav {
  display: grid;
  gap: 1px;
}

.nav-item,
.settings-link,
.mini-item,
.new-list {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.settings-link:hover,
.mini-item:hover,
.new-list:hover {
  background: var(--hover);
}

.nav-item.active,
.mini-item.active {
  background: var(--selected);
}

.theme-value,
.nav-item strong,
.mini-item .count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.nav-icon {
  display: grid;
  place-items: center;
}

.sidebar-section {
  display: grid;
}

.mini-list {
  display: grid;
  gap: 1px;
}

.mini-item {
  color: var(--text);
}

.mini-item.area-row {
  margin-top: 12px;
  font-weight: 650;
}

.mini-item.area-row:first-child {
  margin-top: 0;
}

.area-new {
  margin-top: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  font-weight: 650;
}

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

.sidebar-footer {
  display: grid;
  gap: 1px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.new-list,
.settings-link {
  color: var(--muted);
  font-size: 14px;
}

a.settings-link {
  text-decoration: none;
}

.content {
  min-width: 0;
  max-width: 900px;
  padding: 18px 48px 80px;
}

/* Top bar */

.topbar {
  display: grid;
  grid-template-columns: minmax(160px, 380px) auto auto;
  justify-content: end;
  align-items: center;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--sidebar);
  color: var(--muted);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--hover);
  color: var(--text);
}

.primary-button {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.primary-button:hover {
  background: #185fc4;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

.status.connected .status-dot {
  background: var(--green);
}

.status.busy .status-dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.icon-button.spinning .refresh-icon {
  animation: spin 0.9s linear infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* List header */

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 14px;
}

.view-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-heading svg.icon {
  width: 28px;
  height: 28px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
}

.summary {
  color: var(--faint);
  font-size: 13px;
}

/* New to-do */

.quick-add {
  display: grid;
  margin: 0 0 10px;
  border-radius: 8px;
}

.quick-add:focus-within {
  box-shadow: 0 2px 14px rgb(20 30 50 / 12%);
}

.quick-add-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 6px 0 8px;
  color: var(--faint);
}

.quick-add input,
.quick-add textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.quick-add input[name="scheduled"] {
  width: auto;
  color: var(--muted);
  font-size: 13px;
}

.quick-add textarea {
  display: none;
  min-height: 44px;
  padding: 0 8px 8px 38px;
  resize: vertical;
  color: var(--muted);
  font-size: 14px;
}

/* Notes appear once a title is typed, not on focus, so the list below does
   not jump when the focus moves. */
.quick-add:has(input[name="title"]:not(:placeholder-shown)) textarea,
.quick-add textarea:not(:placeholder-shown) {
  display: block;
}

.quick-add .primary-button {
  min-height: 28px;
  visibility: hidden;
}

.quick-add:focus-within .primary-button {
  visibility: visible;
}

/* Tasks */

.task-list {
  display: grid;
  gap: 22px;
}

.task-section {
  display: grid;
}

.task-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  padding: 0 8px 6px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  font-weight: 700;
}

.task-section h2.heading {
  color: var(--accent);
  font-size: 14px;
}

.task-section h2.heading.drop-into {
  border-radius: 6px;
}

.task-section-rows:empty {
  min-height: 8px;
}

.heading-new {
  width: 100%;
  padding: 4px 8px 6px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  outline: 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

#new-heading {
  min-height: 26px;
  border-color: var(--line);
  font-size: 13px;
}

.task-section-rows {
  display: grid;
}

.task-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 7px;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    background 0.15s ease;
}

.task-row:hover {
  background: var(--hover);
}

.task-row.selected,
.task-row.selected:hover {
  background: var(--row-selected);
}

.task-row.done .task-title {
  color: var(--faint);
}

.task-row.editing {
  grid-template-columns: 22px minmax(0, 1fr) auto;
  margin: 8px -8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 3px 18px rgb(20 30 50 / 16%);
}

.task-row.editing:hover {
  background: var(--panel);
}

.task-editor {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.task-editor input,
.task-editor textarea {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.edit-title {
  font-weight: 600;
  line-height: 20px;
}

.edit-note {
  min-height: 22px;
  overflow: hidden;
  resize: none;
  color: var(--muted) !important;
  font-size: 14px;
  line-height: 1.45;
}

.editor-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.field-action {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.field-action:hover {
  background: var(--hover);
  color: var(--text);
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
}

.field-icon svg.icon {
  width: 15px;
  height: 15px;
}

.field-icon.deadline {
  color: var(--red);
}

.task-editor .field select,
.task-editor .field input[type="date"] {
  width: auto;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.task-editor .field select:hover,
.task-editor .field input[type="date"]:hover {
  border-color: var(--line);
}

.field-clear,
.tag-remove {
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.tags-field {
  flex-wrap: wrap;
}

.task-editor .tag-new {
  width: 110px;
  font-size: 13px;
}

.note-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.note-links a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.checklist {
  display: grid;
  margin-top: 6px;
}

.check-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 28px;
  border-top: 1px solid var(--line-soft);
}

.check-item {
  position: relative;
}

.item-handle {
  position: absolute;
  left: -16px;
  color: var(--faint);
  font-size: 12px;
  opacity: 0;
  cursor: grab;
  touch-action: none;
}

.check-item:hover .item-handle {
  opacity: 1;
}

.check-item.dragging {
  opacity: 0.4;
}

@media (hover: none) {
  .item-handle {
    opacity: 0.6;
  }
}

.check-item:last-child {
  border-bottom: 1px solid var(--line-soft);
}

.check-item input {
  font-size: 14px;
}

.check-item.done .item-title {
  color: var(--faint);
  text-decoration: line-through;
}

.check-item.new input::placeholder {
  color: var(--faint);
}

.mini-check {
  width: 13px;
  height: 13px;
  padding: 0;
  border: 1.4px solid var(--check-border);
  border-radius: 50%;
  background: var(--panel);
  cursor: pointer;
}

.mini-check.checked {
  border-color: var(--accent);
  background: var(--accent);
}

.mini-check.placeholder {
  border-style: dashed;
  cursor: default;
}

.inline-count {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  color: var(--faint);
  font-size: 11px;
}

.inline-count svg.icon {
  width: 12px;
  height: 12px;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#log-completed {
  min-height: 26px;
  border-color: var(--line);
  font-size: 13px;
}

.toast-action {
  margin-left: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--toast-action);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.toast:has(.toast-action) {
  pointer-events: auto;
}

.task-row {
  position: relative;
}

.task-row.dragging {
  opacity: 0.4;
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

/* Rows are selected like in Things, not as text: a text selection made by
   Shift+click would start the browser's own text drag and cancel moving the
   selected to-dos. The editor keeps normal text selection. */
.task-row,
.mini-item,
.nav-item {
  -webkit-user-select: none;
  user-select: none;
}

.task-editor,
.task-editor * {
  -webkit-user-select: text;
  user-select: text;
}

.drop-into {
  background: var(--accent-soft) !important;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.drag-ghost {
  position: fixed;
  z-index: 20;
  max-width: 260px;
  padding: 4px 10px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgb(20 30 50 / 25%);
}

.drag-handle {
  position: absolute;
  top: 7px;
  left: -18px;
  width: 16px;
  color: var(--faint);
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  opacity: 0;
  cursor: grab;
  touch-action: none;
}

.task-row:hover .drag-handle {
  opacity: 1;
}

.task-row.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.task-row.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.check {
  width: 15px;
  height: 15px;
  margin-top: 3px;
  padding: 0;
  border: 1.5px solid var(--check-border);
  border-radius: 4px;
  background: var(--panel);
  cursor: pointer;
}

.check:hover {
  border-color: var(--accent);
}

.check.checked,
.check.checking {
  border-color: var(--accent);
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.6' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 11px no-repeat;
}

.task-row.completing {
  opacity: 0;
  transform: translateX(12px);
}

.task-row.completing .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-row.pending {
  opacity: 0.55;
}

.task-main {
  min-width: 0;
  cursor: default;
}

.task-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.task-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 20px;
}

.inline-icon {
  flex: none;
  color: var(--faint);
}

.inline-icon svg.icon {
  width: 13px;
  height: 13px;
}

.task-line .pill.tag {
  flex: none;
  padding: 0 6px;
  font-size: 11px;
  line-height: 16px;
}

.task-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.task-sub svg.icon {
  width: 12px;
  height: 12px;
}

.task-note {
  display: none;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.task-note a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--sidebar);
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.pill.deadline {
  background: transparent;
  color: var(--red);
}

.pill.tag {
  border: 1px solid var(--line);
  background: transparent;
}

.task-row.project-link {
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.task-row.project-link:hover {
  background: var(--hover);
}

.nav-item.nav-archive {
  margin-top: 10px;
}

.task-row.archived .task-title {
  color: var(--muted);
}

.check.canceled {
  border-color: var(--faint);
  background: var(--faint);
}

/* Canceled to-dos in a list: a cross instead of a tick, as in Things. */
.task-row .check.checked.canceled {
  border-color: var(--muted);
  background: var(--muted)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.3 3.3 8.7 8.7M8.7 3.3 3.3 8.7' fill='none' stroke='white' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 10px no-repeat;
}

.task-row.canceled .task-title {
  text-decoration: line-through;
}

.restore {
  min-height: 26px;
  padding: 0 10px;
  font-size: 13px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 200px;
  color: var(--faint);
}

/* Loading */

.skeleton {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.skeleton-row {
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--shimmer) 50%, var(--line-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-row:nth-child(2n) {
  width: 72%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Toasts */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(520px, 100%);
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--toast-bg);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 18%);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s ease;
  overflow-wrap: anywhere;
}

.toast.success {
  background: #1d7a48;
}

.toast.error {
  background: #b42d3b;
}

.toast.leaving {
  opacity: 0;
}

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

/* New project dialog */

dialog.new-project {
  width: min(400px, calc(100% - 32px));
  padding: 20px;
  border: 0;
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 25%);
}

dialog.new-project::backdrop {
  background: rgb(20 30 50 / 25%);
}

dialog.new-project form {
  display: grid;
  gap: 12px;
}

dialog.new-project h2 {
  font-size: 18px;
}

dialog.new-project label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

dialog.new-project input,
dialog.new-project select {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

/* Sign-in panel (account entered in the browser) */

.signin {
  display: none;
  min-height: 420px;
  align-items: center;
  justify-content: center;
}

.signin.visible {
  display: flex;
}

.signin-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.signin-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.signin-panel .backend-note {
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--note-border);
  border-radius: 8px;
  background: var(--note-bg);
  color: var(--note-text);
  font-size: 13px;
}

.signin-panel .backend-note.visible {
  display: block;
}

.signin-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.signin-panel input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.signin-panel .primary-button {
  min-height: 40px;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-row,
  .status.busy .status-dot,
  .icon-button.spinning .refresh-icon,
  .toast {
    animation: none;
  }

  .task-row {
    transition: none;
  }
}

/* Phone */

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  /* Lists, projects and areas become rows of chips so tasks start near the top. */
  .sidebar {
    position: static;
    gap: 8px;
    min-width: 0;
    height: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .brand {
    display: none;
  }

  .nav,
  .mini-list,
  .sidebar-footer {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-item,
  .mini-item,
  .new-list,
  .settings-link {
    flex: none;
    width: auto;
    grid-template-columns: auto auto auto;
    gap: 6px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 16px;
    background: var(--panel);
  }

  .nav-item.active,
  .mini-item.active {
    background: var(--selected);
  }

  .mini-item.area-row {
    margin-top: 0;
  }

  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .content {
    padding: 10px 12px 80px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    gap: 8px;
  }

  #refresh span:not(.refresh-icon) {
    display: none;
  }

  .status {
    grid-column: 1 / -1;
  }

  .list-header {
    padding: 14px 0 8px;
  }

  h1 {
    font-size: 24px;
  }

  .quick-add .primary-button {
    visibility: visible;
  }

  /* Touch: drag by the handle at the right edge so the list still scrolls. */
  .task-row {
    padding-right: 30px;
  }

  .drag-handle {
    top: 6px;
    right: 4px;
    left: auto;
    width: 24px;
    font-size: 16px;
    opacity: 0.6;
  }
}

/* Login page */

.login-shell {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 48px 16px;
}

.login-shell h1 {
  margin: 0;
  font-size: 22px;
}

.login-shell .brand {
  padding: 0;
  font-size: 16px;
}

.login-shell .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.login-shell .primary-button {
  min-height: 40px;
}

.login-shell a.primary-button {
  text-decoration: none;
}

.login-shell summary {
  cursor: pointer;
  font-weight: 650;
}

.login-shell code {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.login-form {
  display: grid;
  gap: 12px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.login-message {
  margin: 0;
  min-height: 1.4em;
  color: var(--muted);
}

.login-message.error {
  color: var(--red);
}

/* Keyboard: hidden sidebar, palette (move / go to) and cheat sheet */

body.sidebar-hidden .shell {
  grid-template-columns: minmax(0, 1fr);
}

body.sidebar-hidden .sidebar {
  display: none;
}

.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  justify-items: center;
  align-items: start;
  padding-top: 12vh;
  background: rgb(20 30 50 / 18%);
}

.palette {
  width: min(460px, calc(100% - 32px));
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgb(0 0 0 / 28%);
}

.palette-input {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  outline: 0;
  font-size: 15px;
}

.palette-list {
  display: grid;
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}

.palette-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.palette-item.heading {
  color: var(--accent);
  font-size: 14px;
}

.palette-item.nested {
  padding-left: 30px;
}

.palette-item.active,
.palette-item:hover {
  background: var(--selected);
}

.palette-hint {
  color: var(--faint);
  font-size: 12px;
}

dialog.cheat-sheet {
  width: min(980px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  padding: 20px 24px;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgb(0 0 0 / 28%);
}

dialog.cheat-sheet::backdrop {
  background: rgb(20 30 50 / 25%);
}

.cheat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cheat-head h2 {
  font-size: 20px;
}

.cheat-intro {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.cheat-grid {
  columns: 2 300px;
  column-gap: 32px;
}

.cheat-grid section {
  break-inside: avoid;
  margin-bottom: 16px;
}

.cheat-grid h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
}

.cheat-grid table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cheat-grid td {
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.cheat-grid td.keys {
  white-space: nowrap;
  text-align: right;
}

.cheat-grid tr.unavailable td {
  color: var(--faint);
}

.cheat-note {
  color: var(--faint);
  font-size: 11px;
}

.or {
  color: var(--faint);
  font-size: 11px;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--sidebar);
  color: var(--text);
  font: 12px/16px inherit;
  text-align: center;
}

.context-menu {
  position: fixed;
  z-index: 60;
  min-width: 170px;
  padding: 5px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 28px rgb(0 0 0 / 22%);
}

.context-menu button {
  width: 100%;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.context-menu button.danger {
  color: var(--red);
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background: var(--hover);
  outline: 0;
}

h1.renamable {
  cursor: text;
}

.rename-input {
  width: 100%;
  min-width: 0;
  padding: 0 4px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  outline: 0;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

h1 .rename-input {
  width: min(520px, 60vw);
}

.project-note {
  display: block;
  width: 100%;
  margin: -6px 0 12px;
  padding: 2px 0;
  overflow: hidden;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}

.project-note[hidden] {
  display: none;
}

.project-note:focus {
  color: var(--text);
}

.mini-item.pending {
  opacity: 0.55;
  cursor: progress;
}

/* Project header: When, deadline and tags under the title. */
.project-details {
  margin: -4px 0 8px;
}

.mini-item.finished .mini-title {
  color: var(--muted);
  text-decoration: line-through;
}

#project-finish p {
  margin: 0;
  color: var(--muted);
}

.trash-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

.dialog-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9em;
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.tag-filter-pill {
  cursor: pointer;
  border: 1px solid transparent;
}

.tag-filter-pill.active {
  border-color: var(--accent, #2b84e6);
  font-weight: 600;
}

.tags-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.tags-row {
  display: flex;
  gap: 8px;
}

.tags-row input {
  flex: 1;
  min-width: 0;
}

.archive-date {
  color: var(--muted);
  font-size: 0.85em;
}

.archive-more {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.note-markdown {
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.note-markdown p,
.note-markdown ul {
  margin: 0 0 6px;
}

.note-markdown ul {
  padding-left: 20px;
}

.note-markdown .md-h1,
.note-markdown .md-h2,
.note-markdown .md-h3 {
  font-weight: 700;
  margin: 6px 0 4px;
}

.note-markdown .md-h1 {
  font-size: 1.2em;
}

.note-markdown .md-h2 {
  font-size: 1.1em;
}

.note-markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--line);
  border-radius: 4px;
  padding: 0 3px;
}

.mini-end {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.area-toggle {
  width: 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}

.area-toggle:hover {
  background: var(--line);
}

/* MCP Tokens dialog */

dialog.new-project.wide {
  width: min(560px, calc(100% - 32px));
}

.mcp-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.mcp-row-main {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.mcp-access {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.mcp-detail {
  color: var(--muted);
  font-size: 13px;
}

.mcp-section {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

#mcp-created {
  padding: 12px;
  border-radius: 8px;
  background: var(--accent-soft);
}

.mcp-section h3 {
  margin: 0;
  font-size: 15px;
}

.mcp-section fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.mcp-section legend {
  margin-bottom: 4px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.mcp-choices {
  display: grid;
  gap: 2px;
  max-height: 140px;
  padding: 6px 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

dialog.new-project .mcp-choices label,
dialog.new-project label.mcp-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
}

dialog.new-project .mcp-choices input,
dialog.new-project .mcp-check input {
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.mcp-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.mcp-secret {
  display: flex;
  gap: 8px;
}

.mcp-secret input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.mcp-command,
dialog.new-project code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.mcp-command {
  margin: 0;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: 7px;
  background: var(--sidebar);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
