:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #4f46e5;
  --danger: #dc2626;
  --done: #9ca3af;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --card: #1a1b1e;
    --text: #e6e6e6;
    --muted: #9aa0a6;
    --line: #2c2e33;
    --accent: #8b85ff;
    --danger: #f87171;
    --done: #6b7280;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
.app { max-width: 760px; margin: 0 auto; padding: 24px 16px 80px; }

.app-header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.logo { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.logo a { color: inherit; text-decoration: none; font-weight: 700; }
.logo a::before { content: "∞ "; color: var(--accent); }

.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
.breadcrumbs li { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.breadcrumbs li + li::before { content: "›"; }
.breadcrumbs a { text-decoration: none; display: inline-block; background: none; border: 0; padding: 0; color: var(--muted); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs li:last-child a { color: var(--text); }

.focus { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.focus-header { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.focus-header h2 { margin: 0; font-size: 19px; flex: 1; overflow-wrap: anywhere; }
.focus-header .edit { flex: 1; }
.back { color: inherit; text-decoration: none; border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 4px 10px; white-space: nowrap; }
.back:hover { border-color: var(--accent); color: var(--accent); }

.items { list-style: none; margin: 0; padding: 0; }
.children { margin-left: 22px; padding-left: 10px; border-left: 1px dashed var(--line); }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: 8px; min-height: 36px; }
.row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.row .title { flex: 1; overflow-wrap: anywhere; cursor: text; }
.row.done > .title, .row.done > .title-stack > .title { color: var(--done); text-decoration: line-through; }
/* Title with the assignee's name as a subheading underneath. */
.title-stack { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.title-stack > .title { flex: none; }
.title-stack > .edit { flex: none; }
.assignee { font-size: 12px; line-height: 1.3; color: var(--muted); }
.assignee::before { content: "👤 "; }
.row .edit { flex: 1; }

input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex: none; }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.45; }

.icon { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; background: none; border: 0; border-radius: 6px; width: 28px; height: 28px; padding: 0; color: var(--muted); flex: none; }
.icon:hover { background: var(--line); color: var(--text); }
.icon.danger:hover { color: var(--danger); }
.caret { transition: transform 0.12s ease; }
.caret.open { transform: rotate(90deg); }
.caret.hidden { visibility: hidden; }

.actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.1s; }
.row:hover .actions, .row:focus-within .actions { opacity: 1; }
@media (hover: none) { .actions { opacity: 1; } }

.progress { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }

form.add { display: flex; gap: 8px; margin-top: 10px; }
form.add.inline { margin: 4px 0 6px; }
input:not([type]), input[type="email"], input[type="password"] { flex: 1; min-width: 0; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:not([type]):focus, input[type="email"]:focus, input[type="password"]:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.edit input { width: 100%; padding: 3px 8px; }
form.add button { border: 0; border-radius: 8px; padding: 7px 14px; background: var(--accent); color: white; }

.error { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 12px; border-radius: 8px; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 24px 0 8px; margin: 0; }

.top-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.account { display: flex; align-items: center; gap: 10px; font-size: 14px; min-width: 0; }
.account .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); }
.link-button:hover { text-decoration: underline; }

.auth { max-width: 380px; margin: 40px auto 0; padding: 24px; }
.auth h2 { margin: 0 0 16px; font-size: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-form input { font-size: 15px; }
.auth .hint { margin: -6px 0 0; font-size: 12px; }
button.primary { border: 0; border-radius: 8px; padding: 9px 14px; background: var(--accent); color: white; font-weight: 600; }
button.primary:disabled { opacity: 0.6; cursor: progress; }
.auth .switch { margin: 16px 0 0; font-size: 14px; text-align: center; }
.auth .switch.forgot { margin-top: 12px; }
.auth .intro { margin: -4px 0 16px; font-size: 14px; line-height: 1.5; }

/* Drag and drop */
.grip { color: var(--muted); opacity: 0; cursor: grab; font-size: 13px; width: 10px; flex: none; user-select: none; }
.row:hover .grip { opacity: 0.7; }
@media (hover: none) { .grip { display: none; } }
.row[draggable="true"] { cursor: grab; }
.row[draggable="true"] .title { cursor: inherit; }
.row.dragging { opacity: 0.4; }
.row.drop-target { background: color-mix(in srgb, var(--accent) 16%, transparent); outline: 2px dashed var(--accent); outline-offset: -2px; }
.focus.drop-target { outline: 2px dashed var(--accent); outline-offset: 3px; }
.breadcrumbs a.drop-target { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 4px; padding: 0 4px; }
/* Insertion line for reordering: before / after a row. */
.row { position: relative; }
.row.drop-before::before, .row.drop-after::after {
  content: ""; position: absolute; left: 4px; right: 4px; height: 3px;
  background: var(--accent); border-radius: 2px; pointer-events: none;
}
.row.drop-before::before { top: -2px; }
.row.drop-after::after { bottom: -2px; }

/* Keyboard: the current item, a pending cut, and the shortcut legend. */
.row.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.row.selected .actions { opacity: 1; }
.row.cut { opacity: 0.5; outline: 1px dashed var(--muted); outline-offset: -1px; }
.shortcuts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 16px; font-size: 12px; }
.shortcuts .clipboard { color: var(--accent); }
.shortcuts .clipboard:empty { display: none; }
.shortcuts .help-hint { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.shortcuts .help-hint:hover { color: var(--text); }
.modal.help-dialog { max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; }
.help-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.help-header h3 { margin: 0; }
.help-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 24px; }
.help-groups h4 { margin: 12px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.help-groups table { border-collapse: collapse; width: 100%; font-size: 14px; }
.help-groups td { padding: 3px 0; vertical-align: top; }
.help-groups td.keys { width: 72px; white-space: nowrap; padding-right: 10px; }
kbd { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--card); color: var(--text); }
@media (hover: none) { .shortcuts { display: none; } }

/* Trash */
.trash-link { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 16px; flex: none; }
.trash-link:hover { background: var(--line); color: var(--text); }
.trash-link .count { font-size: 11px; min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--line); color: var(--text); text-align: center; font-variant-numeric: tabular-nums; }
.empty-trash { margin-left: auto; flex: none; border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); background: transparent; border-radius: 8px; padding: 4px 10px; }
.empty-trash:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.empty-trash:disabled { opacity: 0.4; cursor: not-allowed; }
.trash .row .title { flex: 1; cursor: default; }
.trash-details { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

/* Confirmation dialog */
.modal-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; max-width: 400px; width: 100%; box-shadow: 0 20px 50px rgb(0 0 0 / 0.35); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 7px 14px; }
.modal-actions .danger-button { background: var(--danger); border-color: var(--danger); color: white; font-weight: 600; }
.modal-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header: settings link + list switcher */
/* Settings (gear) and log out (open door) next to the email. */
.header-icon { width: 32px; height: 32px; position: relative; }
.header-icon.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.header-icon .count { position: absolute; top: -2px; right: -4px; }
/* Settings, as a dialog over the lists. */
.modal.settings-dialog { max-width: 760px; max-height: calc(100vh - 32px); overflow: auto; padding: 16px 20px 20px; }
.settings-dialog:focus { outline: none; }
.settings-dialog .help-header { margin-bottom: 12px; }
.settings-dialog .panel { background: var(--bg); }
.settings-dialog p:not(.muted):not(.notice) { color: var(--text); }
.settings-dialog p.notice { color: var(--accent); }
.inline-link { font: inherit; text-align: left; }
.list-facts { margin-bottom: 16px; }
.settings-hint { margin: 0; }
/* The audit log (v). */
.modal.audit-dialog { max-width: 640px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.audit-dialog:focus { outline: none; }
.audit-entries { list-style: none; margin: 4px 0 10px; padding: 0 4px 0 0; overflow: auto; min-height: 0; flex: 1; }
.audit-entries li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.audit-entries li:last-child { border-bottom: 0; }
.audit-line { overflow-wrap: anywhere; }
.audit-title { font-weight: 500; }
.audit-entries time { flex: none; font-size: 12px; white-space: nowrap; }
.audit-more { align-self: flex-start; margin-bottom: 10px; font: inherit; font-size: 14px; }
.settings-link .count { font-size: 11px; min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--accent); color: white; text-align: center; }
.switcher { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.switcher .tab { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 14px; max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher .tab:hover { color: var(--text); border-color: var(--muted); }
.switcher .tab.active { background: var(--accent); border-color: var(--accent); color: white; }

/* Settings and join pages */
.settings-sections { display: flex; flex-direction: column; gap: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel h3 { margin: 18px 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.panel p { margin: 0 0 10px; }
.panel a { color: var(--accent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.inline-form { display: flex; gap: 8px; margin: 8px 0; }
.inline-form button, .new-link button, button.secondary, .danger-outline { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 7px 14px; white-space: nowrap; }
.inline-form button.primary { border-color: var(--accent); }
button.primary.small { padding: 4px 12px; }
button:disabled { opacity: 0.6; cursor: progress; }
.seats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 12px 0 4px; }
.seats select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; margin-left: 4px; }
.new-link { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.new-link input { flex: 1; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.new-link p { flex-basis: 100%; font-size: 13px; }
.notice { color: var(--accent); font-size: 14px; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }
.danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.danger-link { color: var(--danger); }
.join { max-width: 460px; margin: 40px auto 0; }
.button-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }

/* Side-by-side lists */
.app.two-panes { max-width: 1240px; }
.panes { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.two-panes .panes { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two-panes .panes { grid-template-columns: 1fr; } }
.pane { min-width: 0; }
.pane .breadcrumbs { margin-bottom: 8px; }
.pane.active > div > .focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
/* The cursor only stands out in the pane the keys act on. */
.two-panes .pane:not(.active) .row.selected { background: transparent; box-shadow: inset 3px 0 0 var(--line); }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.header-tools .trash-link { margin-left: 0; }
.tool { background: none; border: 0; border-radius: 8px; padding: 4px 8px; font-size: 16px; color: var(--muted); }
.tool:hover { background: var(--line); color: var(--text); }
.focus-header .tool:last-child { margin-left: 2px; }

/* Links: family items shown in my list */
.link-badge { flex: none; font-size: 12px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.link-badge.broken { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.checkbox-spacer { display: inline-block; width: 17px; flex: none; }

/* Right-click menu */
.menu-backdrop { position: fixed; inset: 0; z-index: 20; }
.context-menu { position: fixed; min-width: 190px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); display: flex; flex-direction: column; }
.context-menu .menu-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; border: 0; background: none; color: inherit; font: inherit; font-size: 14px; text-align: left; padding: 6px 10px; border-radius: 5px; cursor: pointer; }
.context-menu .menu-item:hover:not(:disabled), .context-menu .menu-item:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.context-menu .menu-item:disabled { opacity: 0.45; cursor: default; }
.context-menu .menu-item.danger { color: var(--danger); }
.context-menu kbd { font: 12px ui-monospace, monospace; color: var(--muted); }
.context-menu .menu-separator { height: 1px; background: var(--line); margin: 4px 6px; }

/* Search dialog */
.search-dialog { max-width: 460px; }
.search-dialog input[type="search"] { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin-bottom: 10px; }
.search-dialog input[type="search"]:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.search-results { list-style: none; margin: 0 0 10px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; max-height: 300px; overflow: auto; }
.search-results:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.search-results li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.search-results li:hover { background: var(--line); }
.search-results li.selected { background: color-mix(in srgb, var(--accent) 18%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.search-results .name { font-weight: 600; }
.search-results .muted { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-results { margin: 4px 0 12px; }
.search-dialog .hint { font-size: 12px; margin: 0; }
.search-dialog .assign-title { overflow-wrap: anywhere; }

.join-hint { max-width: 380px; margin: 32px auto -24px; padding: 10px 14px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: 14px; }
