:root {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #fbf6ec;
  --surface-3: #f0e9d9;
  --border: #e6dfd2;
  --border-strong: #d8cfbd;

  --text: #2d3a3a;
  --text-dim: #7a8585;
  --text-soft: #94a09f;

  --accent: #8ec9c1;
  --accent-2: #b3d9c9;
  --accent-3: #d4e7d8;

  --imp-low: #8eb0cc;
  --imp-low-soft: #c8d8e8;
  --imp-low-tint: #dde8f2;
  --imp-low-text: #4e7898;

  --imp-mid: #b9a27e;
  --imp-mid-soft: #d6ccb4;
  --imp-mid-tint: #ece6d2;
  --imp-mid-text: #7a6538;

  --imp-high: #d0a070;
  --imp-high-soft: #e8caa8;
  --imp-high-tint: #f4e4cc;
  --imp-high-text: #a96838;

  --imp-crit: #c87878;
  --imp-crit-soft: #e0b0b0;
  --imp-crit-tint: #f2dada;
  --imp-crit-text: #a65050;

  --radius: 14px;
  --shadow: 0 2px 10px rgba(110, 130, 130, 0.08);
  --shadow-strong: 0 6px 20px rgba(110, 130, 130, 0.15);

  --view-transition: 420ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a2222;
    --surface: #232c2c;
    --surface-2: #2a3434;
    --surface-3: #344040;
    --border: #3a4848;
    --border-strong: #4a5858;

    --text: #e6ece9;
    --text-dim: #a4b0ae;
    --text-soft: #828d8b;

    --accent: #8ec9c1;
    --accent-2: #9ed3c5;
    --accent-3: #2f4040;

    --imp-low: #7ea0bd;
    --imp-low-soft: #36495a;
    --imp-low-tint: #2a3742;
    --imp-low-text: #c4d8e8;

    --imp-mid: #b09f7a;
    --imp-mid-soft: #4d4533;
    --imp-mid-tint: #3a3526;
    --imp-mid-text: #d8c8a4;

    --imp-high: #d09a6a;
    --imp-high-soft: #5a432d;
    --imp-high-tint: #43331f;
    --imp-high-text: #e8b48a;

    --imp-crit: #d88080;
    --imp-crit-soft: #5a3838;
    --imp-crit-tint: #432828;
    --imp-crit-text: #f0a0a0;

    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 6px 20px rgba(0, 0, 0, 0.4);
  }
}

/* Forced dark theme */
:root[data-theme="dark"] {
  --bg: #1a2222; --surface: #232c2c; --surface-2: #2a3434; --surface-3: #344040;
  --border: #3a4848; --border-strong: #4a5858;
  --text: #e6ece9; --text-dim: #a4b0ae; --text-soft: #828d8b;
  --accent: #8ec9c1; --accent-2: #9ed3c5; --accent-3: #2f4040;
  --imp-low: #7ea0bd; --imp-low-soft: #36495a; --imp-low-tint: #2a3742; --imp-low-text: #c4d8e8;
  --imp-mid: #b09f7a; --imp-mid-soft: #4d4533; --imp-mid-tint: #3a3526; --imp-mid-text: #d8c8a4;
  --imp-high: #d09a6a; --imp-high-soft: #5a432d; --imp-high-tint: #43331f; --imp-high-text: #e8b48a;
  --imp-crit: #d88080; --imp-crit-soft: #5a3838; --imp-crit-tint: #432828; --imp-crit-text: #f0a0a0;
  --shadow: 0 2px 10px rgba(0,0,0,0.3); --shadow-strong: 0 6px 20px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Global checkbox & radio ===== */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
input[type="checkbox"] { border-radius: 6px; }
input[type="radio"]    { border-radius: 50%; }

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "✓";
  color: #fff;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
}
input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 5;
  flex-shrink: 0;
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.app-header h1 {
  font-size: 1.3rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--accent);
}

.version-badge {
  position: relative;
  font-size: 0.7rem;
  color: var(--text-soft);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-left: auto;
  cursor: pointer;
  font-family: inherit;
}
.version-badge:hover { border-color: var(--accent); color: var(--text); }

.version-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-strong);
  z-index: 50;
  min-width: 230px;
  font-size: 0.85rem;
  color: var(--text);
  text-align: left;
  white-space: normal;
  cursor: default;
}
.version-popover strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.version-popover ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.version-popover li { line-height: 1.4; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 4;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}

.tab.active {
  background: var(--accent-3);
  color: var(--text);
  font-weight: 600;
}

.view {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  animation: viewIn var(--view-transition) ease-out;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.view--scrollable { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; padding-bottom: 88px; }

.pending-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 4px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section h2 {
  font-size: 0.85rem;
  margin: 0;
  padding: 12px 14px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
}

.section--home {
  flex-shrink: 0;
}

.section--home.section--collapsed {
  overflow: hidden;
}

.section--home .task-list {
  padding: 10px;
}

/* Collapsible section header (home + calendar inline) */
.section-hdr {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-hdr h2 {
  border-bottom: none;
  border-radius: 0;
  flex: 1;
  background: transparent;
}

.section-count {
  font-size: 0.72rem;
  color: var(--text-soft);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 500;
}

.section-toggle {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 0.78rem;
  padding: 0 14px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  pointer-events: none;
}

.section-hdr {
  cursor: pointer;
}
.section-hdr:hover { background: var(--surface-3); }
.section-hdr:hover .section-toggle { color: var(--text); }

.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 24px 12px;
  font-size: 0.92rem;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.section .task-list { padding: 10px; }

/* ===== Task card ===== */

.task {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 22px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 10px;
  align-items: start;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.3s, max-height 0.3s, padding 0.3s, margin 0.3s, border-width 0.3s;
}
.task:active { transform: scale(0.99); }

.task-delete-perm-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 3;
  transition: background 0.12s, color 0.12s;
}
.task-delete-perm-btn:hover { background: #e53935; color: #fff; border-color: #e53935; }

.task[data-imp="1"] { border-color: var(--imp-low); background: var(--imp-low-tint); }
.task[data-imp="2"] { border-color: var(--imp-mid); background: var(--imp-mid-tint); }
.task[data-imp="3"] { border-color: var(--imp-high); background: var(--imp-high-tint); }
.task[data-imp="4"] { border-color: var(--imp-crit); background: var(--imp-crit-tint); }
.task.task--overdue { border-color: #c04040; }

.task-checkbox {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  grid-column: 1;
  grid-row: 1;
}

.task-content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-title {
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.25;
  word-wrap: break-word;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task[data-imp="3"] .task-title { color: var(--imp-high-text); }
.task[data-imp="4"] .task-title { color: var(--imp-crit-text); }

.task.completed .task-title {
  text-decoration: line-through;
  color: var(--text-soft);
}

.task-tag-pills {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
  min-height: 18px;
}

.tag-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  color: #2d3a3a;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .tag-pill { color: #1a2222; }
}

.task-corner {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.crit-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: transparent;
  border: 1.5px solid;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.crit-badge[data-imp="1"] { color: var(--imp-low-text); border-color: var(--imp-low); }
.crit-badge[data-imp="2"] { color: var(--imp-mid-text); border-color: var(--imp-mid); }
.crit-badge[data-imp="3"] { color: var(--imp-high-text); border-color: var(--imp-high); }
.crit-badge[data-imp="4"] { color: var(--imp-crit-text); border-color: var(--imp-crit); }

.task-date {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: right;
  line-height: 1.15;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.task-date:hover { background: var(--surface-3); }
.task-date.overdue { color: var(--imp-crit-text); }

.task-footer {
  position: absolute;
  bottom: 4px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.freq-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.4;
  font-family: inherit;
  white-space: nowrap;
}
.freq-icon:hover { border-color: var(--border-strong); color: var(--text); }

.sub-counter { font-variant-numeric: tabular-nums; }
.sub-counter.complete { color: var(--accent); }

.task.completing {
  animation: taskCollapse 0.45s ease-in forwards;
  pointer-events: none;
}
@keyframes taskCollapse {
  0% { transform: scale(1); opacity: 1; }
  20% { transform: scale(1.03); }
  100% { transform: scale(0.92); opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: -8px; border-width: 0; }
}

.particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  will-change: transform, opacity;
}
@keyframes burst {
  0% { transform: translate(0,0) scale(0.6); opacity: 1; }
  60% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.9rem;
  font-weight: 300;
  cursor: pointer;
  box-shadow: var(--shadow-strong);
  z-index: 10;
}

/* ===== Modal ===== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(45, 58, 58, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
  animation: fade 0.2s ease-out;
}
.modal[hidden] { display: none; }

/* cat-modal opens on top of add-item-modal and cat-picker-modal */
#cat-modal { z-index: 200; }

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

@media (min-width: 600px) {
  .modal { align-items: center; padding: 20px; }
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (min-width: 600px) {
  .modal-content { border-radius: var(--radius); }
}

.modal-content.small {
  max-width: 380px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h2 { margin: 0; font-size: 1.05rem; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-3); }

.task-form {
  padding: 16px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: none;
  padding: 0;
  margin: 0;
}

.field > span,
.field > legend {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  padding: 0;
  font-weight: 500;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="month"],
.field select,
.field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
  cursor: pointer;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.row input[type="text"],
.row input[type="number"],
.row select { flex: 1; min-width: 0; }

.importance-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.imp-chip {
  cursor: pointer;
  user-select: none;
}
.imp-chip input { display: none; }
.imp-chip span {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--surface-2);
}
.imp-chip[data-imp="1"] input:checked + span { background: var(--imp-low-soft); border-color: var(--imp-low); }
.imp-chip[data-imp="2"] input:checked + span { background: var(--imp-mid-soft); border-color: var(--imp-mid); }
.imp-chip[data-imp="3"] input:checked + span { background: var(--imp-high-soft); border-color: var(--imp-high); color: var(--imp-high-text); }
.imp-chip[data-imp="4"] input:checked + span { background: var(--imp-crit-soft); border-color: var(--imp-crit); color: var(--imp-crit-text); }
.imp-chip[data-imp="sel"] span { background: var(--accent-3); border-color: var(--accent); }

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-tags label { cursor: pointer; user-select: none; }
.task-tags label input { display: none; }
.task-tags label span {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 2px solid transparent;
  opacity: 0.55;
  transition: opacity 0.15s, transform 0.1s;
  color: #2d3a3a;
}
@media (prefers-color-scheme: dark) {
  .task-tags label span { color: #1a2222; }
}
.task-tags label input:checked + span {
  opacity: 1;
  border-color: var(--text-dim);
}

.subtasks-list,
.notifications-list,
.tags-manage-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subtasks-list li,
.notifications-list li,
.tags-manage-list li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtasks-list li .text { flex: 1; word-wrap: break-word; min-width: 0; }
.subtasks-list li.done .text { text-decoration: line-through; color: var(--text-soft); }

.tags-manage-list li {
  cursor: pointer;
  justify-content: space-between;
}

.tags-manage-list .tag-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.remove-btn {
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
}
.remove-btn:hover { color: var(--imp-crit); }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.primary-btn,
.danger-btn,
.ghost-btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  flex: 1;
}

.danger-btn {
  background: transparent;
  color: var(--imp-crit-text);
  border: 1px solid var(--imp-crit);
}

.ghost-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.ghost-btn.small { padding: 8px 12px; font-size: 0.9rem; align-self: flex-start; }

.title-input-wrap {
  position: relative;
  display: flex;
}
.title-input-wrap input {
  flex: 1;
  padding-right: 42px !important;
}

.mic-inline {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.mic-inline:hover { border-color: var(--accent); color: var(--accent); }
.mic-inline.recording {
  border-color: var(--imp-crit);
  color: var(--imp-crit-text);
  animation: pulse 1.2s infinite;
}
.mic-inline[disabled] { opacity: 0.4; cursor: not-allowed; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.mic-status {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 6px 0 0;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 200;
  box-shadow: var(--shadow-strong);
  font-size: 0.9rem;
}

/* ===== Filters bar ===== */

.filters {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  align-items: flex-start;
}

.filter-dropdown {
  position: relative;
  flex-shrink: 0;
}

.filter-dropdown-hdr {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.filter-dropdown-hdr.open,
.filter-dropdown-hdr:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--text);
}

.filter-caret { font-size: 0.65rem; }

.filter-dropdown-body {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
  min-width: 140px;
}
.filter-dropdown-body[hidden] { display: none; }

.filter-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  width: 100%;
}
.filter-chip:hover { background: var(--surface-3); color: var(--text); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.filter-chip--tag.active {
  background: var(--chip-color, var(--accent));
  border-color: var(--chip-color, var(--accent));
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 2px;
  align-self: center;
}

/* ===== Calendar ===== */

.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.cal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
}
.cal-header h2:hover { background: var(--surface-3); }

.cal-nav-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-soft);
  padding: 4px 0;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text);
  overflow: hidden;
}
.cal-day.outside { opacity: 0.35; }
.cal-day.today {
  border-color: var(--accent);
  background: var(--accent-3);
}
.cal-day.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  background: var(--accent-3);
}
.cal-day .num { font-weight: 600; }

.cal-dot {
  margin-top: auto;
  margin-bottom: 4px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== Shopping ===== */

.shopping-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.shopping-add-btn { width: 100%; }

.shopping-category {
  background: var(--cat-bg, var(--surface));
  border: 1px solid var(--border);
  border-left: 4px solid var(--cat-color, var(--accent));
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.shopping-cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  cursor: pointer;
  user-select: none;
}

.shopping-cat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.shopping-cat-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
}
.shopping-cat-name:hover {
  background: var(--surface-3);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
}

.shopping-cat-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 999px;
}

.shopping-cat-edit {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 3px 7px;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.6;
  flex-shrink: 0;
}
.shopping-cat-edit:hover { opacity: 1; border-color: var(--border-strong); }

.shopping-cat-chevron {
  font-size: 0.72rem;
  color: var(--text-soft);
  flex-shrink: 0;
}

.cat-select-btn {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}
.cat-select-btn:hover { background: var(--surface-3); }

.cat-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.cat-picker-row:last-child { border-bottom: none; }
.cat-picker-row:hover { background: var(--surface-3); }
.cat-picker-row .text { flex: 1; }

.shopping-cat-body {
  border-top: 1px solid var(--border);
  padding: 6px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.swipe-delete-wrap:last-of-type .shopping-item { border-bottom: none; }

.shopping-item-name {
  flex: 1;
  font-size: 0.96rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}
.shopping-item-name:hover { background: var(--surface-3); }

.shopping-item-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.96rem;
  font-family: inherit;
  outline: none;
}

.shopping-item-edit {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0.5;
  flex-shrink: 0;
}
.shopping-item-edit:hover { opacity: 1; }

.shopping-item.checked .shopping-item-name {
  text-decoration: line-through;
  color: var(--text-soft);
}

.shopping-add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.shopping-add-row input[type="text"] {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
}
.shopping-add-row input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Tag color grid */
.tag-color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.tag-color-grid button {
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.tag-color-grid button.selected {
  border-color: var(--text);
  transform: scale(1.05);
}

/* Month/year picker */
.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.month-grid button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
}
.month-grid button.active {
  background: var(--accent-3);
  border-color: var(--accent);
  font-weight: 600;
}

.year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.year-row .year-display {
  font-weight: 600;
  font-size: 1.1rem;
}

/* Quick actions popover */
.popover-modal .modal-content { max-width: 360px; }
.popover-modal .pop-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== Settings modal ===== */
.notif-toggle-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 2px;
}

#notif-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
#notif-details[hidden] { display: none; }

.notif-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.notif-time-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
}
.notif-time-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* ===== Home: filter+calendar layout ===== */

.view--home {
  overflow: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
}

/* Calendar section body */
.cal-section-body {
  padding: 8px 10px 10px;
}

.filter-chip-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-chip-inline:hover { background: var(--surface-3); color: var(--text); }
.filter-chip-inline.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

/* ===== Mini calendar ===== */

.mini-cal {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-cal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.mini-cal-month {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  flex: 1;
  white-space: nowrap;
}

.mini-cal-nav {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
  font-family: inherit;
}
.mini-cal-nav:hover { background: var(--surface-3); color: var(--text); }

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-cal-dow {
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-soft);
  padding: 2px 0;
  font-weight: 600;
  text-transform: uppercase;
}

.mini-cal-day {
  aspect-ratio: 5/2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2px 1px 1px;
  font-size: 0.68rem;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  transition: background 0.12s;
  overflow: hidden;
  position: relative;
}
.mini-cal-day:hover { background: rgba(0,0,0,0.06); }
.mini-cal-day.outside { color: var(--text-soft); opacity: 0.45; }
.mini-cal-day.today { background: var(--accent-3); color: var(--text); font-weight: 700; }
.mini-cal-day.selected { background: var(--accent); color: #fff; font-weight: 700; }

.mini-cal-day-num {
  line-height: 1;
  position: relative;
  z-index: 2;
}

.mini-cal-day-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px;
  margin-top: 1px;
  position: relative;
  z-index: 1;
}

.mini-cal-dot {
  border-radius: 50%;
  flex-shrink: 0;
}
.mini-cal-dot[data-imp="1"] { width: 2px; height: 2px; background: #a8c4dc; }
.mini-cal-dot[data-imp="2"] { width: 3px; height: 3px; background: #c9b896; }
.mini-cal-dot[data-imp="3"] { width: 4px; height: 4px; background: #e0894e; }
.mini-cal-dot[data-imp="4"] { width: 5px; height: 5px; background: #d45c5c; }

/* Keep day number visible over dots on selected cells */
.mini-cal-day.selected .mini-cal-dot { opacity: 0.8; }

/* old single-dot — kept for fallback but unused */
.mini-cal-day-dot {
  width: 75%;
  aspect-ratio: 1;
  border-radius: 50%;
  flex-shrink: 0;
}
.mini-cal-day.selected .mini-cal-day-dot { background: rgba(255,255,255,0.75) !important; }

/* ===== Swipe fog ===== */

#swipe-fog {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

/* ===== Small btn ===== */

.small-btn {
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 8px;
}

/* ===== Notes ===== */

.notebook-card {
  background: var(--nb-bg, var(--surface));
  border: 1px solid var(--border);
  border-left: 4px solid var(--nb-color, var(--accent));
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.notebook-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  cursor: pointer;
  user-select: none;
}
.notebook-hdr:hover { background: var(--surface-3); }

.notebook-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.notebook-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.98rem;
}

.notebook-body {
  border-top: 1px solid var(--border);
  padding: 6px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.12s;
}
.page-row:last-of-type,
.swipe-delete-wrap:last-child .page-row { border-bottom: none; }
.page-row:hover { background: var(--surface-3); }

.page-icon { font-size: 1rem; flex-shrink: 0; }

.page-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-name {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text);
}

.page-date {
  font-size: 0.72rem;
  color: var(--text-soft);
}

/* ===== Notes page modal ===== */

#notes-page-modal { align-items: flex-start; background: var(--bg); }

.notes-page-content {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
  animation: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notes-page-content .modal-header {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.page-title-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 4px;
  min-width: 0;
  outline: none;
}
.page-title-input:focus { border-bottom-color: var(--accent); }

.page-modal-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.page-editor, .page-preview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-textarea {
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-size: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  line-height: 1.6;
  padding: 16px 18px;
  resize: none;
  outline: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}
div.page-textarea[contenteditable]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-soft);
  pointer-events: none;
}
div.page-textarea[contenteditable] h1 { font-size: 1.4rem; margin: 4px 0; }
div.page-textarea[contenteditable] h2 { font-size: 1.2rem; margin: 3px 0; }
div.page-textarea[contenteditable] strong { font-weight: 700; }
div.page-textarea[contenteditable] em { font-style: italic; }
div.page-textarea[contenteditable] ul { padding-left: 18px; margin: 0; }
div.page-textarea[contenteditable] li { margin: 0; line-height: 2em; }
div.page-textarea[contenteditable] ul.todo-list { list-style: none; padding-left: 4px; }
div.page-textarea[contenteditable] ul.todo-list li { display: flex; align-items: center; gap: 6px; }
div.page-textarea[contenteditable] ul.todo-list li.todo-done { text-decoration: line-through; color: var(--text-soft); }
.todo-check { cursor: pointer; user-select: none; font-size: 1.1rem; flex-shrink: 0; }

.page-preview {
  padding: 16px 18px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
}
.page-preview h1 { font-size: 1.4rem; margin: 0 0 8px; }
.page-preview h2 { font-size: 1.2rem; margin: 0 0 6px; }
.page-preview h3 { font-size: 1.05rem; margin: 0 0 4px; }
.page-preview strong { font-weight: 700; }
.page-preview em { font-style: italic; }
.page-preview ul { padding-left: 18px; margin: 4px 0; }
.page-preview li { margin: 2px 0; }

/* ===== Changelog modal ===== */

.changelog-fullscreen {
  background: var(--bg);
  align-items: flex-start;
  padding: 0;
}

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.changelog-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
  padding: 4px 2px;
  border-radius: 8px;
}
.changelog-item:hover { background: var(--surface-3); }
.changelog-item input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}

/* ===== Shopping item edit (long press) ===== */

.item-edit-color {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.1s;
}
.item-edit-color:hover { transform: scale(1.1); border-color: var(--text); }

/* ===== Subtask inline edit ===== */

.subtask-inline-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 0.96rem;
  font-family: inherit;
  outline: none;
}

/* ===== Notes page toolbar ===== */

.page-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  position: relative;
}

.page-tool-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.page-tool-btn:hover { background: var(--surface-3); color: var(--text); }
.page-tool-btn--title { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 1rem; }
.page-tool-btn--bold { font-weight: 700; }
.page-tool-btn--italic { display: inline-flex; align-items: center; justify-content: center; font-style: normal; transform: skewX(-15deg); }
.page-tool-btn--color { font-size: 1rem; }
.page-tool-btn--mic-active { background: #e84040; color: #ffffff; animation: mic-pulse 0.9s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.88); opacity: 0.7; } }

.page-tool-color-picker {
  position: fixed;
  grid-template-columns: repeat(5, 28px);
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-strong);
  z-index: 250;
}
.page-tool-color-picker:not([hidden]) { display: grid; }

.page-tool-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.page-tool-color-swatch:hover { transform: scale(1.2); border-color: var(--text); }
.page-tool-color-swatch--default { border-color: var(--border) !important; }

/* Notebook lines — baseline sits ~2px above each ruling line */
/* With line-height:2em (32px) and typical sans-serif metrics:
   baseline ≈ padding-top + 21px; line at 31px → padding-top ≈ 8px gives ~2px gap */
.page-textarea {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(2em - 1px),
    var(--border) calc(2em - 1px),
    var(--border) 2em
  );
  background-size: 100% 2em;
  background-attachment: local;
  line-height: 2em;
  padding-top: 8px;
}

/* ===== Notes page save FAB ===== */

#page-save-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 18px;
  z-index: 150;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  transition: background 0.15s, transform 0.1s;
}
#page-save-fab:active { transform: scale(0.96); }

/* ===== Auth screen ===== */

#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#auth-screen[hidden] { display: none; }

.auth-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 4px;
}

.auth-greeting {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  text-align: center;
}

.auth-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  text-align: center;
}

.auth-hint {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
  text-align: center;
  min-height: 2.5em;
}

.auth-hint--error { color: var(--imp-crit-text); }

.auth-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 8px 0;
}

.auth-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.auth-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.auth-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 240px;
}

.auth-key {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, transform 0.08s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-key:hover { background: var(--surface-3); }
.auth-key:active { transform: scale(0.92); background: var(--accent-3); }
.auth-key--del { font-size: 1rem; color: var(--text-dim); }
.auth-key--empty { background: transparent; border: none; pointer-events: none; }
.auth-key--bio { font-size: 1.5rem; background: var(--accent-3); border-color: var(--accent); }

.auth-action-row {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.auth-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Settings security section ===== */

.pin-verify-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.pin-verify-dots {
  display: flex;
  gap: 12px;
}

.pin-verify-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 200px;
}

/* ===== Swipe-to-delete (Feitas) ===== */

.swipe-delete-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 2px;
}

.swipe-delete-bg {
  position: absolute;
  inset: 0;
  background: var(--imp-crit);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  border-radius: 12px;
}

.swipe-delete-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.swipe-delete-wrap .task,
.swipe-delete-wrap .shopping-item,
.swipe-delete-wrap .page-row {
  position: relative;
  z-index: 1;
  background: var(--surface);
}

/* Shopping importance badge */
.shopping-imp-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.shopping-imp-badge--luxo    { background: #dde8f2; color: #4a6a9a; }
.shopping-imp-badge--conforto { background: #d4eed8; color: #3a7850; }
.shopping-imp-badge--necessidade { background: #f4e4cc; color: #a07030; }
.shopping-imp-badge--urgente  { background: #f2dada; color: #a04040; }

.shopping-cat-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.shopping-empty-msg {
  padding: 14px 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0;
}

.imp-dropdown {
  position: fixed;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 130px;
}
.imp-dropdown-opt {
  padding: 10px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
}
.imp-dropdown-opt:hover { filter: brightness(0.95); }
.imp-dropdown-opt--luxo    { background: #dde8f2; color: #4a6a9a; }
.imp-dropdown-opt--conforto { background: #d4eed8; color: #3a7850; }
.imp-dropdown-opt--necessidade { background: #f4e4cc; color: #a07030; }
.imp-dropdown-opt--urgente  { background: #f2dada; color: #a04040; }

/* ===== Undo delete toast ===== */

#undo-delete-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 400;
  font-size: 0.9rem;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
#undo-delete-toast[hidden] { display: none; }

.undo-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

/* ===== Apagar todas (Feitas) ===== */

.delete-all-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 8px;
  padding: 9px;
  background: transparent;
  border: 1.5px solid var(--imp-crit);
  color: var(--imp-crit);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.delete-all-btn:hover { background: var(--imp-crit-tint); }
.delete-all-btn[hidden] { display: none; }

.done-list-sentinel { height: 1px; }
