:root {
  --bg-app: #1a1a1a;
  --bg-panel: #212121;
  --bg-raised: #282828;
  --bg-raised-2: #2f2f2f;
  --bg-hover: #333333;
  --border: #333333;
  --border-soft: #2a2a2a;
  --text: #e3e3e3;
  --text-muted: #93938f;
  --text-faint: #5f5f5c;

  --accent: #4a9eff;
  --accent-hover: #63acff;
  --accent-dim: #2f6fb3;
  --accent-bg: rgba(74, 158, 255, 0.13);
  --accent-ring: rgba(74, 158, 255, 0.28);

  --success: #6bcb77;
  --danger: #e5686c;
  --danger-hover: #ec8286;
  --danger-bg: rgba(229, 104, 108, 0.13);

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Stops mobile browsers/WebView from "helpfully" inflating text size on
     their own font-boosting heuristics - without this, the exact same CSS
     pixel size can render at visibly different sizes across elements
     (e.g. an input's placeholder vs. a button label) depending on how each
     one's surrounding layout looks to that heuristic. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  color: var(--text);
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

svg { display: block; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s var(--ease), transform 0.08s var(--ease), box-shadow 0.15s var(--ease);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-subtle {
  flex: 1;
  background: var(--bg-raised);
  color: var(--text-muted);
}
.btn-subtle:hover { background: var(--bg-hover); color: var(--text); }

.btn-primary {
  background: var(--accent);
  color: #0f1720;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  background: var(--danger);
  color: #1a0e0e;
  font-weight: 600;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-block { width: 100%; }

.sidebar-header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn.active { background: var(--accent-bg); color: var(--accent); }

/* ---------- Login ---------- */

.login-screen {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 25% 15%, rgba(74, 158, 255, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 80% 85%, rgba(74, 158, 255, 0.06) 0%, transparent 45%),
    var(--bg-app);
}

.login-card {
  width: 320px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  margin: 0 auto 6px;
  box-shadow: 0 4px 16px rgba(26, 134, 255, 0.35);
}

.login-title {
  margin: 0;
  font-size: 18.5px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.login-sub {
  margin: -6px 0 6px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.login-card input { padding: 10px 12px; width: 100%; font-size: 14.5px; line-height: 1.3; }

.login-card input::placeholder { font-size: 14.5px; color: var(--text-faint); opacity: 1; }

/* Browsers (and WebView) re-style autofilled fields with their own font/background
   the moment a username gets remembered - without this override, an autofilled
   Username field visibly mismatches the untouched Password field right next to
   it, even though both share the exact same rule above. */
.login-card input:-webkit-autofill,
.login-card input:-webkit-autofill:hover,
.login-card input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-app) inset;
  box-shadow: 0 0 0 1000px var(--bg-app) inset;
  font-size: 14.5px;
  transition: background-color 5000s ease-in-out 0s;
}

.login-card .btn { padding: 10px; margin-top: 4px; font-size: 14.5px; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin: 2px 0 0;
  text-align: center;
}

/* ---------- App shell ---------- */

.app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: grid;
  grid-template-columns: 60px var(--sidebar-width, 250px) 1fr;
  grid-template-rows: 100%;
  animation: app-fade-in 0.2s var(--ease);
}

.app.resizing { cursor: col-resize; user-select: none; }
.app.resizing .sidebar-resize-handle { background: var(--accent); }

@keyframes app-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Workspace rail */

.ws-rail {
  background: #161616;
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
}

.ws-rail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.ws-dot {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14.5px;
  color: #fff;
  border: none;
  opacity: 0.55;
  transition: opacity 0.15s var(--ease), border-radius 0.15s var(--ease), transform 0.1s var(--ease);
}

.ws-dot::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--text);
  transition: height 0.15s var(--ease);
}

.ws-dot.active {
  opacity: 1;
  border-radius: 13px;
}

.ws-dot.active::before { height: 20px; }

.ws-dot:hover { opacity: 1; transform: translateY(-1px); }

.ws-rail-add {
  margin-top: auto;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-raised);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.ws-rail-add:hover { background: var(--accent-bg); color: var(--accent); }

.ws-rail-logout {
  width: 34px;
  height: 34px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.ws-rail-logout:hover { background: var(--danger-bg); color: var(--danger); }

/* Sidebar */

.sidebar {
  position: relative;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
  transition: background 0.15s var(--ease);
}

.sidebar-resize-handle:hover { background: var(--accent-dim); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
  min-width: 0;
  flex-shrink: 1;
}

.sidebar-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.sync-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: #e5c56c;
  background: rgba(229, 197, 108, 0.13);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.sync-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: sync-status-pulse 1.3s ease-in-out infinite;
}

@keyframes sync-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.section-tabs {
  display: flex;
  padding: 0 10px;
  gap: 3px;
  margin-bottom: 10px;
  background: var(--bg-raised);
  margin-left: 10px;
  margin-right: 10px;
  padding: 3px;
  border-radius: var(--radius-sm);
  width: calc(100% - 20px);
}

.section-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 5px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.section-tab:hover { color: var(--text); }

.section-tab.active {
  background: var(--bg-hover);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.sidebar-toolbar {
  display: flex;
  gap: 6px;
  padding: 0 10px 10px;
}

.sidebar-toolbar .btn { padding: 7px 8px; }

.root-dropzone {
  margin: 0 10px 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  border: 1px dashed transparent;
  transition: all 0.15s var(--ease);
  cursor: pointer;
}

.root-dropzone:hover { color: var(--text-muted); }

.root-dropzone.active { color: var(--accent); background: var(--accent-bg); }
.root-dropzone.drag-over { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

.item-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Docs/Notes/Tasks tab switch - a quick slide-and-fade "enter" for whichever
   direction the new tab is relative to the old one (matches the tab order
   left-to-right, and matches a swipe's direction when that's what triggered
   it - see the swipe handler in app.js). Applied to whatever just became the
   new content, not both old and new - there's nothing to visually cross-fade
   from once the old tab's content is already gone. */
@keyframes kindSlideInFromRight {
  from { transform: translateX(18px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes kindSlideInFromLeft {
  from { transform: translateX(-18px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.kind-slide-in-right { animation: kindSlideInFromRight 0.2s var(--ease); }
.kind-slide-in-left { animation: kindSlideInFromLeft 0.2s var(--ease); }

/* The blank area below the last folder/item is a real "go back to top level"
   target, not just dead space - click it (or drop something on it) to clear
   the current folder selection, same as the "All items" dropzone above. */
.item-list-wrap.has-selection {
  cursor: pointer;
}

.item-list-wrap.has-selection::after {
  content: "Click here to move back to top level";
  flex: 1;
  min-height: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14px;
  font-size: 12px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.12s var(--ease);
}

.item-list-wrap.has-selection:hover::after,
.item-list-wrap.has-selection.drag-over-root::after {
  opacity: 1;
}

.item-list-wrap.drag-over-root {
  outline: 1px dashed var(--accent);
  outline-offset: -4px;
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
}

.item-list, .folder-children {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.folder-children { margin-left: 12px; position: relative; }
.folder-children::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 4px;
  width: 1px;
  background: var(--border-soft);
}

/* Folder rows & category group headers (shared visual language) */

.folder-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  transition: background 0.12s var(--ease);
}

.folder-row:hover { background: var(--bg-hover); }
.folder-row.active { background: var(--accent-bg); }
.folder-row.drag-over { background: var(--accent-bg); box-shadow: inset 0 0 0 1.5px var(--accent); }
.folder-row.dragging { opacity: 0.35; }

.folder-row .folder-toggle {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s var(--ease);
}

.folder-row .folder-toggle.expanded { transform: rotate(90deg); }

.folder-row .folder-icon { flex-shrink: 0; color: var(--text-faint); display: flex; }
.folder-row .cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.folder-row .folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-row .folder-count {
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 400;
  flex-shrink: 0;
  margin-right: 2px;
}

.folder-row .folder-menu-btn {
  opacity: 0;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: opacity 0.1s, background 0.1s;
}

.folder-row:hover .folder-menu-btn { opacity: 1; }
.folder-row .folder-menu-btn:hover { background: var(--bg-raised-2); color: var(--text); }

/* Item rows */

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  user-select: none;
  transition: background 0.12s var(--ease);
}

.item-row:hover { background: var(--bg-hover); }
.item-row.active { background: var(--accent-bg); color: var(--accent); }
.item-row.dragging { opacity: 0.35; }
.item-row.drag-over { background: var(--accent-bg); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* Touch drag-and-drop (see makeTouchDraggable in app.js) - there's no native
   browser drag-image on touch the way desktop gets one for free, so this is
   our own floating stand-in, plus a dimmed state for whatever's being
   dragged, same idea as .item-row.dragging above but shared by folder rows
   too (which desktop never needed a dimmed state for, since the browser's
   own native drag image was already doing that job there). */
.touch-drag-source { opacity: 0.35; }

.touch-drag-ghost {
  pointer-events: none;
  z-index: 500;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-sm);
  transform: scale(1.03);
  background: var(--bg-panel);
}

.item-row .item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.item-row .due-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  flex-shrink: 0;
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 999px;
}

.item-row .due-badge.overdue { color: var(--danger); background: var(--danger-bg); }

.item-row .checklist-progress-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
  background: var(--accent-bg);
  padding: 2px 6px;
  border-radius: 999px;
}

/* Custom checkbox */

.task-check-wrap {
  position: relative;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
}

.task-check-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.task-check-box {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--text-faint);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  background: var(--bg-app);
  transition: all 0.15s var(--ease);
}

.task-check-box svg { width: 11px; height: 11px; stroke-width: 3; }

.task-check-input:checked + .task-check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f1720;
}

.task-check-input:hover + .task-check-box { border-color: var(--accent); }

/* Main content */

.content {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  gap: 2px;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  margin-bottom: 14px;
}

.empty-state p { margin: 4px 0; font-size: 14.5px; }
.empty-state .muted { color: var(--text-faint); font-size: 13px; }

.editor, .task-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.editor-title-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  padding: 4px 2px;
  min-width: 60px;
  letter-spacing: -0.01em;
}

.editor-title-input:focus { outline: none; box-shadow: none; }

.view-mode-switch {
  display: flex;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex-shrink: 0;
}

.view-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 5px;
  transition: all 0.15s var(--ease);
}

.view-mode-btn:hover { color: var(--text); }
.view-mode-btn.active { background: var(--accent); color: #0f1720; font-weight: 700; }

.editor-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-soft);
  margin: 0 4px;
}

.editor-panes {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

.editor-panes.mode-edit { grid-template-columns: 1fr; }
.editor-panes.mode-edit .editor-preview { display: none; }

.editor-panes.mode-read { grid-template-columns: 1fr; }
.editor-panes.mode-read .editor-source { display: none; }
.editor-panes.mode-read .editor-preview { padding: 28px 16%; }

.editor-source {
  min-height: 0;
  border: none;
  border-radius: 0;
  resize: none;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.65;
  padding: 20px;
  border-right: 1px solid var(--border-soft);
}

.editor-source.drag-over { background: var(--accent-bg); }
.task-notes.drag-over { background: var(--accent-bg); }
.editor-source:focus { outline: none; box-shadow: none; }

.markdown-fallback {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.6;
  margin: 0;
  color: var(--text);
}

.editor-preview {
  min-height: 0;
  padding: 20px 26px;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 15px;
}

.editor-preview h1, .editor-preview h2, .editor-preview h3 {
  color: #fff;
  font-weight: 700;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 7px;
}

.editor-preview a { color: var(--accent); text-decoration: none; }
.editor-preview a:hover { text-decoration: underline; }
.editor-preview img {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  cursor: zoom-in;
}

/* ---------- Image lightbox ---------- */

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  cursor: zoom-out;
  animation: overlay-in 0.15s var(--ease);
}

.image-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.image-lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }

.editor-preview code {
  background: var(--bg-raised);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.editor-preview pre {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
}
.editor-preview pre code { background: none; padding: 0; }
.editor-preview blockquote {
  border-left: 3px solid var(--accent-dim);
  margin: 0;
  padding-left: 14px;
  color: var(--text-muted);
}

.status-retry-link {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--danger);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.status-retry-link:hover { color: var(--danger-hover); }

.editor-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 20px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
}

.word-count { color: var(--text-faint); }

.task-notes-preview {
  margin: 0 20px 4px;
  padding: 4px 0;
  max-height: 220px;
}

.completed-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 6px;
  margin-top: 6px;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  border-top: 1px solid var(--border-soft);
}

.completed-section-header:hover { color: var(--text-muted); }

.completed-section-header .folder-toggle {
  width: 12px;
  height: 12px;
  color: inherit;
  display: flex;
  transition: transform 0.15s var(--ease);
}
.completed-section-header .folder-toggle.expanded { transform: rotate(90deg); }

.task-datetime {
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
  white-space: nowrap;
}

.item-row .repeat-icon { color: var(--text-faint); flex-shrink: 0; display: flex; }

/* Task detail */

.task-detail { padding: 0; overflow-y: auto; }
.task-detail .field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.task-notes {
  margin: 16px 20px 4px;
  width: calc(100% - 40px);
  min-height: 90px;
  padding: 11px 13px;
  font-size: 14.5px;
  line-height: 1.55;
  resize: vertical;
}

.task-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
}

.task-field { display: flex; flex-direction: column; min-width: 150px; }

.task-fields input[type="datetime-local"],
.task-fields input[type="number"],
.task-fields select {
  padding: 9px 11px;
  font-size: 14px;
}

.task-done-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 22px 20px 18px;
  font-size: 14.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.task-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 20px;
  margin: 4px 0 0;
  font-size: 14.5px;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

/* ---------- Advanced tasks: checklist of independently-reminded steps ---------- */

.task-checklist-section { padding: 14px 0 4px; }

.task-auto-complete-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 20px 14px;
  font-size: 14.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 20px;
}

.checklist-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.checklist-item.done { opacity: 0.55; }
.checklist-item.done .checklist-item-title { text-decoration: line-through; }

.checklist-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* The six-dot grip. touch-action: none is what lets a finger drag from it without
   the browser trying to scroll the page instead. */
.checklist-drag-handle {
  flex-shrink: 0;
  width: 20px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: var(--radius-sm);
}
.checklist-drag-handle:hover { color: var(--text); background: var(--bg-hover); }
.checklist-drag-handle:active { cursor: grabbing; }

.checklist-item.dragging {
  position: relative;
  z-index: 5;
  background: var(--bg-raised);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  opacity: 0.95;
}
.checklist-item.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.checklist-item.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }

.checklist-item-title {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-size: 14.5px;
}
.checklist-item-title:focus { outline: none; box-shadow: none; border-color: transparent; }

/* On its own line rather than squeezed into the row alongside the title and
   icon buttons - that's what was pushing this out of view on narrow phone
   widths. Wraps instead of clipping if it's still long at that point. */
.checklist-item-meta {
  font-size: 12px;
  color: var(--text-faint);
  white-space: normal;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding-left: 62px; /* lines up under the title, past the grip and the checkbox */
}

.checklist-item-meta .importance-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.importance-dot.highest { background: var(--danger); }
.importance-dot.important { background: #e5a53e; }
.importance-dot.mild { background: var(--text-faint); }

.checklist-add-btn { margin: 10px 20px 0; }

/* ---------- Loading, empty, and error primitives ---------- */

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

.spinner {
  display: inline-block;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner.sm { width: 13px; height: 13px; border-width: 2px; }
.spinner.md { width: 18px; height: 18px; border-width: 2px; }
.spinner.lg { width: 26px; height: 26px; border-width: 3px; }

/* Buttons: adding .is-loading swaps in a spinner and disables interaction, without
   changing the button's size/position - avoids layout jump between idle and loading. */
.btn.is-loading, .icon-btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.btn.is-loading::after, .icon-btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  color: inherit;
}
.btn-primary.is-loading::after, .btn-danger.is-loading::after { color: #0f1720; }

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.skeleton {
  background: var(--bg-raised);
  border-radius: 5px;
  animation: skeleton-pulse 1.3s ease-in-out infinite;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
}
.skeleton-row .skeleton { height: 13px; }
.skeleton-row .skeleton.icon { width: 14px; height: 14px; flex-shrink: 0; border-radius: 4px; }
.skeleton-row .skeleton.text { flex: 1; max-width: 70%; }

.skeleton-dot {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}

/* Section states: empty / error / loading, used anywhere a list or panel needs to
   explain its own state rather than just rendering nothing (a blank list looks
   broken; these always say what's going on and, where relevant, what to do next). */

.section-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 36px 20px;
  color: var(--text-muted);
}

.section-state-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.section-state.is-error .section-state-icon { color: var(--danger); background: var(--danger-bg); }

.section-state-title { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 0; }
.section-state-detail { font-size: 13px; color: var(--text-faint); margin: 0; max-width: 220px; line-height: 1.5; }
.section-state .btn { margin-top: 12px; }

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

.toast-stack {
  position: fixed;
  top: var(--toast-top-offset, 16px);
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  transition: top 0.15s var(--ease);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(33, 33, 33, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  line-height: 1.4;
  animation: toast-in 0.2s var(--ease);
  border-left: 3px solid var(--accent);
}

.toast.leaving { animation: toast-out 0.18s var(--ease) forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-message { flex: 1; color: var(--text); }
.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-faint);
  padding: 2px;
  border-radius: 4px;
  display: flex;
}
.toast-close:hover { color: var(--text); background: var(--bg-hover); }

.toast-action {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}
.toast-action:hover { background: var(--accent-bg); }
.toast-action:disabled { opacity: 0.5; pointer-events: none; }

.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }

.toast.danger { border-left-color: var(--danger); }
.toast.danger .toast-icon { color: var(--danger); }

.toast.warning { border-left-color: #e5c56c; }
.toast.warning .toast-icon { color: #e5c56c; }

.toast.info { border-left-color: var(--accent); }
.toast.info .toast-icon { color: var(--accent); }

.repeat-summary-btn {
  text-align: left;
  padding: 8px 10px;
  font-size: 14px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s var(--ease);
}
.repeat-summary-btn:hover { border-color: var(--accent); }

/* Inside a modal (e.g. Step settings) it sits in a field group like any other input, so fill the row. */
.modal-body .repeat-summary-btn { width: 100%; }

/* Step settings: the date/time picker, the dropdown, the number box and the Repeat
   button all share one size - full width, same height, same text size - instead of
   each control getting its own browser-default (or button-default) dimensions. */
.modal-step-settings .field-group input[type="datetime-local"],
.modal-step-settings .field-group input[type="number"],
.modal-step-settings .field-group select,
.modal-step-settings .field-group .repeat-summary-btn {
  display: block;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  margin: 0;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 13.5px;
  line-height: 1.2;
}
/* A number box otherwise keeps its own native styling (and, on phones, the browser
   default font size) - flatten it to a plain text-style box like the others. */
.modal-step-settings .field-group input[type="number"] {
  -webkit-appearance: textfield;
  -moz-appearance: textfield;
  appearance: textfield;
}

.weekday-picker {
  display: flex;
  gap: 5px;
}

.weekday-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}
.weekday-btn:hover { border-color: var(--accent); }
.weekday-btn.selected { background: var(--accent); border-color: var(--accent); color: #0f1720; }

.repeat-interval-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  color: var(--text-muted);
}
.repeat-interval-row input[type="number"] { width: 56px; padding: 7px 8px; text-align: center; }
.repeat-interval-row select { padding: 7px 8px; flex: 1; }

.repeat-end-options { display: flex; flex-direction: column; gap: 8px; }
.repeat-end-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  color: var(--text);
}
.repeat-end-option input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; flex-shrink: 0; }
.repeat-end-option input[type="date"],
.repeat-end-option input[type="number"] {
  padding: 6px 8px;
  font-size: 14px;
  width: 120px;
}
.repeat-end-option input:disabled { opacity: 0.4; }
.repeat-end-option .end-label { flex-shrink: 0; }

/* ---------- Modal system ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: overlay-in 0.15s var(--ease);
}

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s var(--ease);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 4px;
}

.modal-header h3 { margin: 0; font-size: 16.5px; font-weight: 700; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 14px 18px; overflow-y: auto; }

.modal-message { margin: 0 0 4px; color: var(--text-muted); font-size: 14.5px; line-height: 1.5; }

.modal-body .field-group { margin-bottom: 14px; }
.modal-body .field-group:last-child { margin-bottom: 0; }

.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.field-group input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  font-size: 14.5px;
}

.color-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s var(--ease);
}

.color-swatch:hover { transform: scale(1.1); }

.color-swatch.selected {
  border-color: var(--bg-panel);
  box-shadow: 0 0 0 2px currentColor;
}

.color-swatch.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 18px;
}

.modal-footer .modal-extra { margin-right: auto; }

.trash-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}

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

.trash-row-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.trash-kind-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.trash-title {
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-days {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.trash-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.trash-row-actions .btn { padding: 5px 10px; font-size: 12.5px; }

.trash-empty {
  text-align: center;
  padding: 24px 0;
  color: var(--text-faint);
  font-size: 14.5px;
}

/* Scrollbars */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #3c3c3c;
  border-radius: 6px;
  border: 2px solid var(--bg-app);
}
::-webkit-scrollbar-thumb:hover { background: #4a4a4a; }

/* Dropdown menu (kebab context actions) */

/* Search modal - anchored near the top rather than centered, matching the
   command-palette convention (Spotlight, VS Code, Notion) people already know
   from elsewhere, since a vertically-centered box would visibly jump around as
   the result list grows/shrinks while typing. */

.search-overlay { align-items: flex-start; padding-top: 12vh; }

.search-card {
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-input-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16.5px;
  padding: 2px 0;
  color: var(--text);
}
.search-input-row input:focus { outline: none; box-shadow: none; }
.search-input-row input::placeholder { color: var(--text-faint); }

.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.search-result {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.search-result:hover, .search-result.active { background: var(--bg-hover); }

.search-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg-raised);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}
.search-result-kind svg { width: 11px; height: 11px; }

.search-result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-snippet {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result mark, .search-result-title mark {
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 700;
}

.dropdown-menu {
  position: fixed;
  z-index: 150;
  background: var(--bg-raised-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 5px;
  min-width: 170px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  animation: menu-in 0.12s var(--ease);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 14px;
}

.dropdown-menu button:hover { background: var(--bg-hover); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu button.danger:hover { background: var(--danger-bg); }

/* Responsive */

/* ---------- Responsive: mobile page navigation ---------- */
/*
  Below the breakpoint, the three areas (workspace rail, section list, editor)
  stop being a permanent 3-column layout and become pages you navigate between:

  - "list" (default): section list fills the screen, rail is off-screen to the left
  - "list" + peeked: rail slides in partway, list shrinks to stay visible alongside it
  - "editor": editor fills the entire screen, rail and list are both off-screen

  This is done by giving .app a flex track wider than the viewport and sliding it
  with translateX, rather than toggling display - so the transition is a real slide,
  not a cut.
*/

.mobile-only { display: none; }

.mobile-topbar {
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.mobile-topbar-title {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .mobile-only { display: flex; }

  /* --mobile-vw is set in JS from window.innerWidth and used instead of the vw
     unit throughout this block. Using vw here caused a real, reproducible Chrome
     bug: inside a flex container that's wider than the viewport (because it also
     contains the off-screen rail/editor panels) and is being translateX'd, vw
     units resolve correctly for LAYOUT but the PAINT gets clipped well short of
     that - the box measures full width via getBoundingClientRect, but content
     past ~150-200px silently doesn't render. Pixel values computed from
     window.innerWidth sidestep the bug entirely since there's no unit for the
     browser to resolve inconsistently. */
  .app {
    --mobile-rail-width: 88px;
    display: flex;
    grid-template-columns: none;
    overflow: hidden;
    width: calc(var(--mobile-rail-width) + var(--mobile-vw, 100vw) + var(--mobile-vw, 100vw));
  }

  .ws-rail {
    flex: 0 0 var(--mobile-rail-width);
    width: var(--mobile-rail-width);
  }

  .sidebar {
    flex: 0 0 var(--mobile-vw, 100vw);
    width: var(--mobile-vw, 100vw);
    min-width: 0;
  }

  .content {
    flex: 0 0 var(--mobile-vw, 100vw);
    width: var(--mobile-vw, 100vw);
    min-width: 0;
  }

  /* Default page: list fills the screen. Track sits at -(rail width) so the
     rail is fully off-screen to the left, list occupies the full viewport. */
  .app {
    transform: translateX(calc(var(--mobile-rail-width) * -1));
    transition: transform 0.22s var(--ease);
  }

  /* Peeked: rail slides fully into view, list shrinks and shifts right to stay
     visible alongside it rather than being covered. */
  .app.mobile-peek {
    transform: translateX(0);
  }
  .app.mobile-peek .sidebar {
    flex-basis: calc(var(--mobile-vw, 100vw) - var(--mobile-rail-width));
    width: calc(var(--mobile-vw, 100vw) - var(--mobile-rail-width));
  }

  /* Editor page: track slides the rest of the way so only the editor pane shows. */
  .app.mobile-editor {
    transform: translateX(calc((var(--mobile-rail-width) + var(--mobile-vw, 100vw)) * -1));
  }
  /* If somehow both peek and editor are set, editor wins - you can't be mid-file
     and have the workspace rail open at the same time. */
  .app.mobile-editor.mobile-peek {
    transform: translateX(calc((var(--mobile-rail-width) + var(--mobile-vw, 100vw)) * -1));
  }

  .ws-peek-toggle { flex-shrink: 0; }

  /* Sidebar's own desktop chrome (drag handle, workspace settings gear) doesn't
     apply to this mode - it's always full-panel now, not a resizable column. */
  .sidebar-resize-handle { display: none; }

  /* The editor pane's mobile top bar shows a back arrow; the sidebar itself
     doesn't need its own close affordance in this model. */
  .content { display: flex; flex-direction: column; }

  /* Split view has no room on a phone screen - collapse the option entirely,
     not just visually, so there's nothing to tap into a broken layout. */
  .view-mode-btn[data-mode="split"] { display: none; }
  .editor-panes { grid-template-columns: 1fr; }
  .editor-panes .editor-source { display: block; }
  .editor-panes .editor-preview { display: none; }
  .editor-panes.mode-read .editor-preview { display: block; padding: 20px; }
  .editor-panes.mode-read .editor-source { display: none; }

  /* Bigger touch targets throughout */
  .icon-btn { width: 44px; height: 44px; }
  .ws-dot { width: 46px; height: 46px; }
  .item-row, .folder-row { padding-top: 11px; padding-bottom: 11px; }

  /* Checklist steps: use more of the screen's width. The 44px touch-target rule
     above would otherwise give each step's two icon buttons 88px between them,
     plus 20px of margin each side, squeezing the title into what's left. */
  .checklist-items { padding: 0 8px; }
  .checklist-item { padding: 6px 6px; }
  .checklist-item-row { gap: 4px; }
  .checklist-item-row .icon-btn { width: 36px; height: 36px; }
  .checklist-drag-handle { width: 18px; }
  .checklist-item-meta { padding-left: 52px; } /* grip + checkbox + gaps, so it still lines up under the title */
}

/* Phone: tighten spacing further, stack toolbars that would otherwise overflow */
@media (max-width: 480px) {
  .editor-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }
  .editor-title-input { flex-basis: 100%; order: -1; font-size: 17.5px; }
  .view-mode-switch { order: 1; }
  .editor-toolbar-actions { order: 2; margin-left: auto; }

  .task-fields { flex-direction: column; }
  .task-field { min-width: 0; width: 100%; }

  .modal-card { width: calc(100vw - 24px); }
  .login-card { padding: 28px 22px 24px; }

  /* iOS Safari zooms in on focus if an input's font-size is under 16px - keep
     every text input at least that size on phones to prevent the jarring zoom. */
  input[type="text"], input[type="password"], input[type="datetime-local"],
  input[type="number"], textarea, select { font-size: 17.5px; }

  /* Step settings on a phone: all four controls identical - the number box included -
     at 16px (no iOS zoom on focus) and a comfortable touch height. */
  .modal-step-settings .field-group input[type="datetime-local"],
  .modal-step-settings .field-group input[type="number"],
  .modal-step-settings .field-group select,
  .modal-step-settings .field-group .repeat-summary-btn {
    height: 40px;
    font-size: 16px;
  }
}

/* ---------- Offline banner ---------- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--warning, #b8860020);
  background: #4a3a12;
  color: #f5d68a;
  font-size: 13px;
  text-align: center;
}
.offline-banner button {
  border: 1px solid #f5d68a55;
  background: transparent;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.offline-banner button:hover { background: #f5d68a1a; }
body.is-offline .app { padding-top: 34px; }
@media (max-width: 700px) {
  body.is-offline .app { padding-top: 44px; }
}

/* Read-only affordance while offline or while a lazily-loaded body is still arriving. */
#editor-title[readonly], #editor-source[readonly] { opacity: 0.75; cursor: default; }

/* Checkbox field inside a modal (e.g. the "also delete tasks" option on Delete
   category?) - reuses the .task-check-* look, laid out as one inline row instead of
   a heading label above a control like the other field types. This is a <label>
   itself, so it also matches .field-group label above (small-caps heading style,
   display:block) - .field-group .field-checkbox-row is the more specific selector
   needed to actually override that, not just follow it in the file. */
.field-group .field-checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 0;
}
