.app-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
.app-page .main-hd {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
a.brand--link {
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
}
a.brand--link:hover {
  background: var(--bg-active);
}
a.brand--link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Arbre : repli */
.nest.is-collapsed {
  display: none;
}
.twist.is-collapsed svg {
  transform: rotate(-90deg);
}
.twist {
  cursor: pointer;
}

/* Formulaires inline dans la grille */
.checkbox-form,
.title-form,
.inline-form {
  display: contents;
}
.checkbox-form button.checkbox {
  appearance: none;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  width: 16px;
  height: 16px;
  border-radius: var(--check-shape);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.checkbox-form button.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.title-form input.title,
.title-form input.detail-title {
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  color: inherit;
  width: 100%;
  min-width: 0;
  padding: 0;
}
.title-form input.title {
  font-weight: 450;
}
.title-cell {
  min-width: 0;
}
.title-cell--has-url {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
a.task-url-go {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--accent);
  border-radius: 4px;
  text-decoration: none;
}
a.task-url-go:hover {
  background: var(--accent-soft);
}
a.task-url-go--local {
  cursor: copy;
}

.path-copy-toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 1300;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface, var(--bg-elev, #fdfcf9));
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.path-copy-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.title-form input.title--has-url,
.title-form input.detail-title.title--has-url {
  color: var(--accent);
}
.tree-row.done .title-form input.title--has-url {
  color: var(--done);
}
.link-control,
.due-control,
.share-control,
.pin-control {
  position: relative;
  flex-shrink: 0;
}
.link-btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.link-popover {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  width: min(280px, 70vw);
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.link-popover.is-open {
  display: block;
}
.link-popover-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--ink);
}
.link-popover-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}
.link-popover-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.link-popover-save,
.link-popover-clear {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.link-popover-save {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.link-popover-clear:hover {
  border-color: #dc2626;
  color: #dc2626;
}
.focus-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.focus-title .title-cell,
.focus-title .title-form--focus {
  flex: 1;
  min-width: 0;
}
.title-form--focus {
  flex: 1;
  min-width: 0;
}
.title-form input.detail-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  width: 100%;
}
.tree-row.done .title-form input.title {
  color: var(--done);
  text-decoration: line-through;
}
.main-hd-focus-slot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}
.main-hd-focus-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.main-hd-focus-host {
  display: flex;
  align-items: center;
  gap: 4px;
}
.main-hd-focus-host .task-url-go {
  width: 28px;
  height: 28px;
}
.main-hd-focus-host.focus-task {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}
.main-hd .main-hd-focus-bulk .focus-bulk-btn {
  padding: 6px 10px;
  font-size: 11px;
}
.focus-bulk-form {
  margin: 0;
}
.focus-bulk-btn {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.focus-bulk-btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-3);
}
.focus-bulk-btn:active {
  transform: scale(0.98);
}
.checkbox--note {
  display: inline-grid;
  place-items: center;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
  color: var(--ink-3);
}
.checkbox--note svg {
  width: 14px;
  height: 14px;
}
.tree-row--note.done .title-form input.title {
  text-decoration: none;
  color: var(--ink);
}
body.is-mobile .row-actions .toggle-checkable-form {
  display: none;
}
.focus-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 4px 4px 8px;
}
.focus-subhead-label {
  flex: 1;
  min-width: 0;
}
.row-btn--icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
}
a.drill.row-btn--icon {
  display: inline-grid;
}
.row-actions {
  opacity: 1 !important;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.row-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  border-radius: var(--radius);
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.row-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
.row-btn--danger:hover {
  color: #dc2626;
  border-color: #dc2626;
}
.focus-empty {
  color: var(--ink-3);
  padding: 8px 4px;
  font-size: 13px;
}
.focus-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px var(--pad-x);
  margin-top: 12px;
  color: var(--ink-3);
  font-size: 13px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}
.add-row input[type="text"] {
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  color: var(--ink);
}
.add-row-icon {
  font-size: 16px;
  line-height: 1;
}

/* Breadcrumb */
.hier-focus .focus-bc a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.hier-focus .focus-bc a:hover {
  background: var(--bg-active);
  color: var(--ink);
}
.hier-focus .focus-bc span.current {
  color: var(--ink);
  font-weight: 500;
}
a.drill {
  text-decoration: none;
  color: inherit;
}

/* Glisser-déposer */
.drag-handle {
  cursor: grab;
  touch-action: none;
}
.drag-handle:active {
  cursor: grabbing;
}
.tree-row.dragging {
  opacity: 0.45;
}

/* Connexion */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 12px);
  background: var(--bg-elev);
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.06));
}
.auth-brand {
  margin-bottom: 16px;
}
.auth-title {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 600;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.auth-input {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
  background: var(--bg);
  color: var(--ink);
}
.auth-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.auth-submit {
  margin-top: 4px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.auth-submit:hover {
  filter: brightness(1.05);
}
.auth-msg {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.45;
}
.auth-msg--error {
  color: #dc2626;
}
.auth-msg--ok {
  color: #15803d;
}
.auth-steps {
  margin: 0 0 16px;
  padding-left: 1.2rem;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.auth-steps code {
  font-size: 12px;
  word-break: break-all;
}
.auth-hash-out {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.auth-link {
  font-size: 13px;
  color: var(--accent);
}
.auth-logout-form {
  margin-left: auto;
}
.auth-logout-btn {
  font-size: 12px;
}

/* Recherche rapide (Ctrl+K) */
.global-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}
.global-search-trigger:hover {
  background: var(--bg-active);
  color: var(--ink);
}
.global-search-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.global-search-trigger-label {
  font-weight: 500;
}
.global-search-kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10px;
  line-height: 1.2;
  color: var(--ink-3);
  background: var(--bg-subtle, var(--bg));
}
.global-search {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.global-search[hidden] {
  display: none !important;
}
body.global-search-open {
  overflow: hidden;
}
.global-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.global-search-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface, var(--bg));
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}
.global-search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
}
.global-search-scope {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.global-search-scope[hidden] {
  display: none !important;
}
.global-search-scope-input {
  margin: 0;
  accent-color: var(--accent);
}
.global-search-scope-label {
  line-height: 1.35;
}
.global-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  outline: none;
}
.global-search-input::placeholder {
  color: var(--ink-3);
}
.global-search-kbd--esc {
  flex-shrink: 0;
}
.global-search-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}
.global-search-item {
  margin: 0;
}
.global-search-item-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.global-search-item.is-active .global-search-item-btn,
.global-search-item-btn:hover {
  background: var(--bg-active);
}
.global-search-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.global-search-item-title.is-done {
  text-decoration: line-through;
  color: var(--ink-3);
}
.global-search-item-title--note {
  font-style: italic;
  color: var(--ink-2);
}
.global-search-item-path {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.35;
}
.global-search-empty {
  margin: 0;
  padding: 16px 14px 0;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}
.global-search-hint {
  margin: 0;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}
