:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7487;
  --accent: #3a6df0;
  --accent-dark: #2a55c7;
  --accent-soft: #e8eefd;
  --border: #e1e5ec;
  --gray-bg: #eceff4;
  --gray-text: #9aa1ae;
  --done: #2f9e5b;
  --done-soft: #e3f4ea;
  --danger: #c43a2a;
  --danger-soft: #fbe6e3;
  --radius: 12px;
  --fab-size: 56px;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* Press feedback on every button - a quick, subtle shrink so a tap always
   confirms itself instantly, before whatever the tap triggers has finished. */
button {
  transition: transform 0.08s ease;
  font-family: inherit;
}

button:active {
  transform: scale(0.95);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

mark {
  background: #ffe58a;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* --- Top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 8px;
  padding-top: calc(8px + env(safe-area-inset-top));
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-inner + .topbar-inner { margin-top: 8px; }

.topbar-col {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 4px 2px;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active { background: var(--gray-bg); }

.icon-btn svg { width: 22px; height: 22px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 0 6px 0 12px;
  height: 40px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
}

.search-box:focus-within { border-color: var(--accent); }

.search-box > svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-size: 16px; /* 16px+ keeps iOS from zooming in on focus */
  font-family: inherit;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}

.search-box input::-webkit-search-cancel-button { display: none; }

.search-box input::placeholder { color: var(--gray-text); }

.search-clear {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-clear svg { width: 14px; height: 14px; }

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

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-bg);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--done);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

/* Horizontally scrolling chip rows (status filter, topic filter) */
.chips-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -12px;
  padding: 0 12px;
}

.chips-scroll::-webkit-scrollbar { display: none; }

.chips-scroll:empty { display: none; }

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

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chip .chip-count {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
}

.chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.chip.selected .chip-count { color: var(--accent-dark); }

.chip-add {
  border-style: dashed;
  color: var(--muted);
}

.chip-input {
  height: 32px;
  width: 150px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

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

/* --- Main --- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px 110px;
}

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

.empty-hint {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  font-size: 0.95rem;
  line-height: 1.45;
}

.empty-hint b { color: var(--ink); }

/* Survey rows (home) */
.survey-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 4px 10px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(29, 36, 51, 0.04);
  cursor: pointer;
}

.survey-row:active { background: #f8f9fb; }

.survey-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.survey-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.survey-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.survey-progress .progress-bar { height: 5px; max-width: 220px; }

.survey-progress-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.survey-progress-text.complete { color: var(--done); }

/* Drag handle - the only element with touch-action:none, so the rest of the
   row (and the list) keeps native scrolling on phones. */
.drag-handle {
  touch-action: none;
  width: 36px;
  align-self: stretch;
  min-height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-text);
  cursor: grab;
}

.drag-handle svg { width: 18px; height: 18px; }

.dragging .drag-handle { color: var(--accent); }

.dragging {
  position: relative;
  z-index: 30;
  box-shadow: 0 10px 24px rgba(29, 36, 51, 0.2) !important;
  background: var(--card);
}

/* Topic groups (survey view) */
.topic-group + .topic-group { margin-top: 18px; }

.topic-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 8px;
  cursor: pointer;
}

.topic-header .topic-dot { width: 10px; height: 10px; }

.topic-name {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-count {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-text);
}

.topic-count.complete { color: var(--done); }

.topic-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--gray-text);
  transition: transform 0.2s ease;
  transform: rotate(90deg);
}

.topic-group.collapsed .topic-chevron { transform: rotate(0deg); }

.topic-group.collapsed .q-list,
.topic-group.collapsed .topic-add { display: none; }

.topic-add-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.topic-add-btn svg { width: 15px; height: 15px; }

.q-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.q-empty {
  padding: 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--gray-text);
  font-size: 0.86rem;
  text-align: center;
  cursor: pointer;
}

/* Question rows */
.q-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 4px 0 4px 2px;
  min-height: 52px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(29, 36, 51, 0.04);
  cursor: pointer;
}

.q-row:active { background: #f8f9fb; }

.q-row.done { background: #fbfdfc; }

.q-check {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.q-check-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #c3c9d4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.q-check-circle svg { width: 14px; height: 14px; }

.q-row.done .q-check-circle,
.q-sheet-status.done .q-check-circle {
  background: var(--done);
  border-color: var(--done);
  color: #fff;
}

.q-body {
  flex: 1;
  min-width: 0;
  padding: 11px 2px 10px 0;
}

.q-text {
  font-size: 0.97rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.q-row.done .q-text { color: var(--muted); }

.q-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--muted);
}

.q-meta:empty { display: none; }

.q-meta-comments {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.q-meta-comments svg { width: 13px; height: 13px; }

.q-snippet {
  display: block;
  width: 100%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}

.q-topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

/* Search results (home) */
.results-section + .results-section { margin-top: 18px; }

.results-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 2px 2px 8px;
}

.result-survey {
  font-weight: 700;
  color: var(--accent-dark);
}

/* Floating add button (FAB) */
.fab {
  position: fixed;
  right: max(18px, calc(50% - 360px + 18px));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(42, 85, 199, 0.35);
  z-index: 15;
  cursor: pointer;
}

.fab:active { background: var(--accent-dark); }

.fab svg { width: 26px; height: 26px; }

/* --- Sheets (bottom modals) --- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}

.sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 0.25s ease;
  z-index: 21;
  max-width: 720px;
  margin: 0 auto;
  max-height: 88vh;
  max-height: min(88dvh, calc(var(--vvh, 100dvh) - 12px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet.show { transform: translateY(calc(-1 * var(--kb, 0px))); }

.sheet-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.sheet-close-btn svg { width: 15px; height: 15px; }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 14px;
}

.sheet h2 {
  margin: 0 40px 12px 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.sheet-hint {
  margin: -4px 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.sheet label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin: 14px 0 7px;
}

.sheet input[type="text"],
.sheet textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-size: 16px;
  line-height: 1.4;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  outline: none;
}

.sheet input[type="text"]:focus,
.sheet textarea:focus { border-color: var(--accent); }

.sheet textarea { resize: none; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.sheet-actions button {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 0.97rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:active { background: var(--accent-dark); }

.btn-primary:disabled {
  background: var(--gray-bg);
  color: var(--gray-text);
  cursor: default;
}

.btn-secondary {
  background: var(--gray-bg);
  color: var(--ink);
}

.btn-compact {
  flex: 0 0 auto;
  padding: 0 14px;
  height: 44px;
  font-size: 0.92rem;
}

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
}

.btn-danger-solid:active { background: #a02d20; }

.inline-save-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-save-row input[type="text"] { flex: 1; min-width: 0; }

.menu-list {
  display: flex;
  flex-direction: column;
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.menu-item:active { transform: none; background: var(--bg); }

.menu-item-icon { width: 24px; text-align: center; font-size: 1.1rem; }

.menu-item-text { flex: 1; }

.menu-item-hint { color: var(--muted); font-size: 0.85rem; }

.menu-item-danger { color: var(--danger); }

/* Topics management */
.topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.topic-color-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.topic-color-btn .topic-dot { width: 16px; height: 16px; }

.topic-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid transparent;
  background: transparent;
  font-weight: 600;
}

.topic-row input[type="text"]:focus { background: #fff; border-color: var(--accent); }

.topic-row-count {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.topic-del-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.topic-del-btn svg { width: 17px; height: 17px; }

.add-topic-row { margin-top: 12px; }

/* --- Question sheet: fixed-height flex column - comments scroll inside,
   the composer and the "Завершить" button stay pinned to the bottom. --- */
#question-sheet {
  display: flex;
  flex-direction: column;
  height: 88vh;
  height: min(88dvh, calc(var(--vvh, 100dvh) - 12px));
  overflow: hidden;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.q-sheet-top { flex-shrink: 0; }

.q-sheet-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 44px;
  min-height: 32px;
}

.q-sheet-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.q-sheet-status.done { color: var(--done); }

.q-sheet-status .q-check-circle { width: 20px; height: 20px; }

.q-sheet-status .q-check-circle svg { width: 12px; height: 12px; }

.q-sheet-pos {
  font-size: 0.8rem;
  color: var(--gray-text);
  font-weight: 600;
}

.q-text-wrap {
  position: relative;
  margin-top: 6px;
}

.sheet #q-text-input {
  display: block;
  padding: 8px 40px 8px 10px;
  margin: 0 -10px;
  width: calc(100% + 20px);
  border-color: transparent;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.38;
  overflow-y: hidden;
  max-height: 30vh;
}

.sheet #q-text-input:focus { border-color: var(--accent); overflow-y: auto; }

.q-text-save {
  position: absolute;
  right: -4px;
  top: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--done);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.q-text-save svg { width: 15px; height: 15px; }

.q-text-save:disabled { background: var(--gray-bg); color: var(--gray-text); }

.chips-scroll-sheet {
  margin: 10px -16px 0;
  padding: 0 16px 2px;
}

.comments-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-top: 12px;
  padding: 10px 0 8px;
  border-top: 1px solid var(--border);
}

.comments-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-empty {
  color: var(--gray-text);
  font-size: 0.9rem;
  padding: 6px 0;
}

.comment {
  padding: 7px 12px 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.comment.editing { border-color: var(--accent); background: #fff; }

.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -4px 2px 0;
  min-height: 26px;
}

.comment-date {
  flex: 1;
  font-size: 0.74rem;
  color: var(--gray-text);
  font-weight: 600;
}

.comment-btn {
  border: none;
  background: none;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px;
  cursor: pointer;
}

.comment-btn-copy { color: var(--done); }

.comment-btn-del { color: var(--danger); }

.comment-save {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--done);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.comment-save svg { width: 13px; height: 13px; }

.comment-save:disabled { background: var(--gray-bg); color: var(--gray-text); }

.comment-text {
  font-size: 0.95rem;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  outline: none;
  cursor: text;
}

.q-bottom-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.comment-add-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.sheet #comment-input {
  flex: 1;
  overflow-y: hidden;
  max-height: 150px;
}

.comment-add-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.comment-add-btn:disabled { background: var(--gray-bg); color: var(--gray-text); cursor: default; }

.comment-add-btn svg { width: 20px; height: 20px; }

.q-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.nav-btn {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  border: none;
  background: var(--gray-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.nav-btn:disabled { color: #c9ced8; cursor: default; }

.nav-btn svg { width: 22px; height: 22px; }

.btn-done {
  flex: 1;
  height: 50px;
  border-radius: 12px;
  border: none;
  background: var(--done);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-done:active { background: #25844b; }

.btn-done.reopen {
  background: var(--done-soft);
  color: #1f7a44;
}

.q-delete-link {
  display: block;
  margin: 8px auto 0;
  border: none;
  background: none;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

/* --- Confirm dialog --- */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 40;
}

.confirm-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.confirm-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(330px, calc(100vw - 48px));
  background: var(--card);
  border-radius: 16px;
  padding: 20px 18px 16px;
  box-shadow: 0 12px 32px rgba(15, 20, 30, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 41;
}

.confirm-dialog.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.confirm-text {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-16px);
  max-width: calc(100vw - 48px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-error { background: #9c2c1f; }
.toast.toast-success { background: #237a47; }

/* --- Login page --- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 4px 20px rgba(29, 36, 51, 0.06);
}

.login-card h1 { margin: 0 0 18px; font-size: 1.4rem; }

.login-card label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 14px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

.login-card input:focus { border-color: var(--accent); }

.login-card .btn-primary { width: 100%; height: 48px; font-size: 1rem; }

.login-error {
  min-height: 1.3em;
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 0.88rem;
}
