/* PomoMed — tasks, question counter, templates, report dialog, toasts (agent FEATURES) */

:root {
  /* Specialty identity colours (always paired with a text label) */
  --spec-cm: #2563eb;
  --spec-cir: #dc2626;
  --spec-ped: #ca8a04;
  --spec-go: #c026d3;
  --spec-prev: #16a34a;
  --spec-other: #64748b;

  /* Chart series (validated: light surface) */
  --chart-a: #0d9488;
  --chart-b: #e07a1f;

  /* Feature-local tokens for panels drawn on --surface */
  --feat-muted: #4b5866;
  --feat-line: #dde3e8;
  --feat-soft: #f3f5f7;
  --feat-strong: #1f2937;
  --feat-strong-text: #ffffff;
  --feat-focus: #1d4ed8;
  --feat-danger: #b91c1c;
  --feat-danger-soft: #fee2e2;
  --feat-note-bg: #fff7d1;
  --feat-note-text: #5c4800;
  --feat-pro: #4338ca;
  --feat-pro-press: #312e81;
  --feat-on-mode-focus: #ffffff;
}

body[data-theme="dark"] {
  --spec-cm: #60a5fa;
  --spec-cir: #f87171;
  --spec-ped: #facc15;
  --spec-go: #e879f9;
  --spec-prev: #4ade80;
  --spec-other: #94a3b8;

  --chart-a: #14a294;
  --chart-b: #d27a26;

  --feat-muted: #a3afbf;
  --feat-line: #2c3a50;
  --feat-soft: #1a2333;
  --feat-strong: #f3f4f6;
  --feat-strong-text: #111827;
  --feat-focus: #93c5fd;
  --feat-danger: #fca5a5;
  --feat-danger-soft: rgba(248, 113, 113, 0.14);
  --feat-note-bg: rgba(250, 204, 21, 0.12);
  --feat-note-text: #fde68a;
  --feat-pro: #4f46e5;
  --feat-pro-press: #312e81;
}

[data-spec="cm"] { --spec: var(--spec-cm); }
[data-spec="cir"] { --spec: var(--spec-cir); }
[data-spec="ped"] { --spec: var(--spec-ped); }
[data-spec="go"] { --spec: var(--spec-go); }
[data-spec="prev"] { --spec: var(--spec-prev); }
[data-spec="other"] { --spec: var(--spec-other); }

.spec-dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--spec, var(--spec-other));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}
body[data-theme="dark"] .spec-dot { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }

/* Shared reset for feature buttons */
/* :where() keeps this reset at zero specificity so component rules win */
:where(#tasks-panel, #questions-panel, .rpt-modal, .feat-toast) :where(button, select, input, textarea) {
  font: inherit;
}
:where(#tasks-panel, #questions-panel, .rpt-modal, .feat-toast) button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
:where(#tasks-panel, #questions-panel) button:disabled { cursor: not-allowed; }

/* Focus rings: white on the coloured page, strong blue on light surfaces */
:where(#tasks-panel, #questions-panel) :focus-visible {
  outline: 3px solid var(--feat-on-mode-focus);
  outline-offset: 2px;
}
.task :focus-visible,
.task-editor :focus-visible,
.tpl-panel :focus-visible,
.feat-menu :focus-visible,
.rpt-modal :focus-visible {
  outline: 3px solid var(--feat-focus);
  outline-offset: 2px;
}

/* =========================================================
   Question counter
   ========================================================= */
#questions-panel { width: 100%; }

.qc {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius, 12px);
  background: var(--card-bg, rgba(255, 255, 255, 0.1));
  color: var(--text, #fff);
}

.qc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.qc__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.qc__acc {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qc__ring { display: block; }
.qc__ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 4;
}
.qc__ring-fill {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.45s ease;
}
.qc__acc.is-empty .qc__ring-fill { stroke-linecap: butt; }
.qc__acc-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.qc__acc-val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 700;
}
.qc__acc-unit {
  font-size: 0.75rem;
  opacity: 0.9;
}

.qc__quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
/* Acertei / Errei: desaturated semantic pair. White text stays ≥ 5.1:1 on the green
   gradient and ≥ 6.5:1 on the red one (AA on every skin, light and dark). */
.qc__quick-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #fff;
  font-weight: 800;
  font-size: 0.98rem;
  transition: transform 0.16s var(--ease, ease), box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}
.qc__quick-btn svg { flex: none; }
.qc__quick-btn--right {
  border-color: rgba(167, 230, 196, 0.45);
  background: linear-gradient(180deg, #357a59, #2c6a4c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 6px 16px -10px rgba(16, 80, 50, 0.9);
}
.qc__quick-btn--right svg { color: #c6f0d8; }
.qc__quick-btn--wrong {
  border-color: rgba(244, 186, 186, 0.42);
  background: linear-gradient(180deg, #974346, #8a3a3d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 6px 16px -10px rgba(100, 20, 24, 0.9);
}
.qc__quick-btn--wrong svg { color: #f8d3d3; }
.qc__quick-btn:hover { filter: brightness(1.08); }
.qc__quick-btn--right:hover { border-color: rgba(198, 240, 216, 0.85); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 18px -4px rgba(134, 239, 172, 0.55); }
.qc__quick-btn--wrong:hover { border-color: rgba(248, 211, 211, 0.85); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 18px -4px rgba(252, 165, 165, 0.5); }
.qc__quick-btn:active { transform: translateY(1px) scale(0.97); }
/* "+1" float-up (questions.js) */
.qc__float {
  position: absolute;
  left: 50%;
  top: 2px;
  z-index: 2;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.875rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: qc-float 0.7s var(--ease, ease-out) forwards;
}
@keyframes qc-float {
  0% { opacity: 0; transform: translate(-50%, 4px) scale(0.8); }
  25% { opacity: 1; transform: translate(-50%, -8px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1); }
}

.qc__counters {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.qc__counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.qc__label {
  font-size: 0.9rem;
  font-weight: 600;
}
.qc__controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qc__step {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  transition: background-color 0.15s ease;
}
.qc__step:hover:not(:disabled) { background: rgba(255, 255, 255, 0.26); }
.qc__step:disabled { opacity: 0.45; }
.qc__step--ten { min-width: 46px; }
.qc__value {
  min-width: 44px;
  text-align: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 700;
}
.qc__value.is-bump { animation: feat-bump 0.28s ease; }

.qc__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.85rem;
}
.qc__spec-label { font-weight: 600; }
.qc__spec-dot[hidden] { display: none; }
.qc__select {
  flex: 1 1 160px;
  min-width: 0;
  min-height: 36px;
  padding: 6px 30px 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.18);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  text-overflow: ellipsis;
}
.qc__select option { color: #111827; background: #fff; }

/* ---- Compact row (default): "Questões hoje: 18 ✓ 14 · 78%" + quick ✓/✗ ---- */
.qc { padding: 10px 10px 10px 6px; }
.qc.is-expanded { padding-bottom: 16px; }
.qc__bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qc__heading {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
}
.qc__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 48px;
  padding: 4px 6px 4px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  text-align: left;
  transition: background-color 0.15s ease;
}
.qc__toggle:hover { background: rgba(0, 0, 0, 0.12); }
.qc__sum {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.2;
}
.qc__sum-label {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qc__sum-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 2px;
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
}
.qc__sum-stats b { font-weight: 800; }
.qc__sum-a,
.qc__sum-c b { display: inline-block; }
.qc__sum-c {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.qc__sum-c svg { flex: none; }
.qc__sum-pct {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.875rem;
}
.qc__sum-pct.is-empty { background: transparent; padding-inline: 0; }
.qc__sum-a.is-bump,
.qc__sum-c b.is-bump { animation: feat-bump 0.28s ease; }
.qc__chev {
  flex: none;
  transition: transform 0.2s ease;
}
.qc__toggle[aria-expanded="true"] .qc__chev { transform: rotate(180deg); }

.qc__bar .qc__quick {
  display: flex;
  flex: none;
  gap: 8px;
  margin-top: 0;
}
.qc__bar .qc__quick-btn {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.qc__body { padding: 4px 6px 0 10px; }
.qc__body .qc__head { margin-top: 8px; }
.qc__body .qc__title {
  font-size: 0.95rem;
  font-weight: 800;
}

/* Narrow phones: quick buttons become icon-only squares (names stay in aria-label). */
@media (max-width: 440px) {
  .qc__bar .qc__quick-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .qc__bar .qc__quick-btn { width: 48px; min-width: 48px; padding: 0; }
  .qc__bar .qc__quick-btn svg { width: 22px; height: 22px; }
}

@keyframes feat-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* =========================================================
   Tasks
   ========================================================= */
#tasks-panel { width: 100%; }

.tasks {
  margin-top: 20px;
  color: var(--text, #fff);
}
.tasks__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.6);
}
.tasks__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}
.tasks__menu-wrap { position: relative; }
.tasks__menu-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transition: background-color 0.15s ease;
}
.tasks__menu-btn:hover,
.tasks__menu-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.3); }

.feat-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 248px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--surface-text, #1f2937);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.12);
  animation: feat-pop 0.14s ease;
}
.feat-menu[hidden] { display: none; }
.feat-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
}
.feat-menu__item svg { flex: none; color: var(--feat-muted); }
.feat-menu__item:hover,
.feat-menu__item:focus-visible { background: var(--feat-soft); }
.feat-menu__item.is-danger,
.feat-menu__item.is-danger svg { color: var(--feat-danger); }
.feat-menu__item.is-confirm { background: var(--feat-danger-soft); }
.feat-menu__item + .feat-menu__item.is-danger {
  margin-top: 4px;
  border-top: 1px solid var(--feat-line);
  border-radius: 0 0 7px 7px;
}

@keyframes feat-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.tasks__empty {
  margin: 16px 0 0;
  font-size: 0.92rem;
  text-align: center;
  opacity: 0.92;
}

.task-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.task-li + .task-li { margin-top: 8px; }
.task-li.is-dragging { opacity: 0.5; }
.task-li.drop-before .task { box-shadow: 0 -4px 0 0 #fff, 0 1px 3px rgba(0, 0, 0, 0.12); }
.task-li.drop-after .task { box-shadow: 0 4px 0 0 #fff, 0 1px 3px rgba(0, 0, 0, 0.12); }

.task {
  position: relative;
  border-left: 6px solid transparent;
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--surface-text, #1f2937);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s ease, transform 0.12s ease;
}
.task:hover { border-left-color: var(--feat-line); }
.task.is-active { border-left-color: var(--surface-text, #1f2937); }

.task__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 10px;
}
.task__check {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #d5d8dd;
  /* The ring is what marks it as a checkbox: ≥ 3:1 against the task card (WCAG 1.4.11). */
  box-shadow: inset 0 0 0 2px var(--surface-field-border, #7b8794);
  color: #fff;
  transition: background-color 0.2s ease, transform 0.1s ease;
}
body[data-theme="dark"] .task__check { background: #4b5563; }
.task__check:hover { background: #b9bec6; }
body[data-theme="dark"] .task__check:hover { background: #6b7280; }
.task__check[aria-checked="true"] { background: var(--mode-bg, #0f766e); box-shadow: none; }
.task__check:active { transform: scale(0.92); }

.task__main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  min-height: 40px;
  justify-content: center;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.task__title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.task.is-completed .task__title {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  color: var(--feat-muted);
}
.spec-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--feat-muted);
}
.task__count {
  flex: none;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--feat-muted);
  font-size: 0.95rem;
}
.task__count b {
  font-size: 1.1rem;
  color: var(--surface-text, #1f2937);
}
.task.is-completed .task__count b { color: var(--feat-muted); }
.task__edit {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--feat-line);
  border-radius: 7px;
  background: transparent;
  color: var(--feat-muted);
  transition: background-color 0.15s ease;
}
.task__edit:hover { background: var(--feat-soft); color: var(--surface-text, #1f2937); }

.task__note {
  margin: 0 12px 12px 48px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--feat-note-bg);
  color: var(--feat-note-text);
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tasks__add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 60px;
  margin-top: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.tasks__add:hover {
  background: rgba(0, 0, 0, 0.16);
  border-color: rgba(255, 255, 255, 0.85);
}

.tasks__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 8px;
  margin: 18px 0 0;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0 0 8px 8px;
  font-size: 0.95rem;
  text-align: center;
}
.tasks__summary[hidden] { display: none; }
.tasks__summary strong {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
.tasks__summary-sep { opacity: 0.8; }
.tasks__summary-dur { opacity: 0.9; }

/* ---------- Inline task editor ---------- */
.task-editor {
  overflow: hidden;
  margin-top: 12px;
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--surface-text, #1f2937);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  animation: feat-pop 0.16s ease;
}
.task-li.is-editing .task-editor { margin-top: 0; }
.task-editor__body { padding: 18px 16px 12px; }
.task-editor__title {
  width: 100%;
  padding: 6px 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
}
.task-editor__title::placeholder {
  color: var(--feat-muted);
  font-weight: 600;
  font-style: italic;
  opacity: 0.9;
}
.task-editor__title:focus { border-bottom-color: var(--feat-line); }
.task-editor__title:focus-visible { outline-offset: 4px; border-radius: 4px; }
.task-editor__error {
  margin: 6px 0 0;
  color: var(--feat-danger);
  font-size: 0.85rem;
  font-weight: 600;
}
.task-editor__error[hidden] { display: none; }

.task-editor__group {
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.task-editor__legend,
.stepper__label {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--feat-muted);
}
label.task-editor__legend { margin-top: 16px; }

.spec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.spec-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1.5px solid var(--feat-line);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.spec-chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.spec-chip:hover { background: var(--feat-soft); }
.spec-chip.is-checked,
.spec-chip:has(input:checked) {
  border-color: var(--spec);
  background: var(--feat-soft);
  background: color-mix(in srgb, var(--spec) 13%, transparent);
}
.spec-chip:has(input:focus-visible) {
  outline: 3px solid var(--feat-focus);
  outline-offset: 2px;
}

.task-editor__steppers {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  margin-top: 16px;
}
.stepper__controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stepper__input {
  width: 72px;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: var(--feat-soft);
  color: inherit;
  font: inherit;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  font-weight: 700;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--feat-line);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: inherit;
  box-shadow: 0 2px 0 var(--feat-line);
}
.stepper__btn:hover { background: var(--feat-soft); }
.stepper__btn:active { transform: translateY(2px); box-shadow: none; }

.task-editor__add-note {
  margin-top: 16px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--feat-muted);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.task-editor__add-note:hover { color: var(--surface-text, #1f2937); }
.task-editor__note {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--feat-soft);
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  resize: vertical;
}
.task-editor__note::placeholder { color: var(--feat-muted); }

.task-editor__footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--feat-soft);
}
.task-editor__spacer { flex: 1; }
.task-editor__delete,
.task-editor__cancel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--feat-muted);
  font-weight: 700;
}
.task-editor__delete { padding-left: 4px; }
.task-editor__delete:hover { color: var(--feat-danger); }
.task-editor__cancel:hover { color: var(--surface-text, #1f2937); }
.task-editor__save,
.tpl-btn--primary {
  min-height: 40px;
  padding: 8px 20px;
  border: 0;
  border-radius: 6px;
  background: var(--feat-strong);
  color: var(--feat-strong-text);
  font-weight: 800;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.task-editor__save:hover,
.tpl-btn--primary:hover { filter: brightness(1.15); }
.task-editor__save:active,
.tpl-btn--primary:active { transform: translateY(2px); box-shadow: none; }

/* ---------- Templates panel ---------- */
.tpl-panel {
  margin-top: 12px;
  padding: 14px 16px 16px;
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--surface-text, #1f2937);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  animation: feat-pop 0.16s ease;
}
.tpl-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tpl-panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}
.tpl-panel__close {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--feat-muted);
}
.tpl-panel__close svg { transform: rotate(45deg); }
.tpl-panel__close:hover { background: var(--feat-soft); }
.tpl-panel__label {
  display: block;
  margin: 10px 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--feat-muted);
}
.tpl-panel__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tpl-panel .tpl-panel__input {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 1.5px solid var(--feat-line);
  border-radius: 6px;
  background: var(--feat-soft);
  color: var(--surface-text, #1f2937);
  font: inherit;
}
.tpl-panel .tpl-panel__input::placeholder { color: var(--feat-muted); }
.tpl-panel__usage,
.tpl-panel__empty {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--feat-muted);
}
.tpl-panel__sub {
  margin: 16px 0 4px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--feat-muted);
}
.tpl-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.tpl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--feat-line);
}
.tpl-item:first-child { border-top: 0; }
.tpl-item__info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.tpl-item__name {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.tpl-item__meta {
  font-size: 0.8rem;
  color: var(--feat-muted);
}
.tpl-btn--primary { padding: 6px 14px; min-height: 36px; font-size: 0.88rem; }
.tpl-btn--icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--feat-line);
  border-radius: 6px;
  background: transparent;
  color: var(--feat-muted);
}
.tpl-btn--icon:hover { color: var(--feat-danger); background: var(--feat-soft); }

/* =========================================================
   Toasts (inside #toast-region)
   ========================================================= */
.feat-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 10px 16px;
  border-radius: 14px;
  background: #101826;
  color: #f9fafb;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  font-size: 0.9rem;
  line-height: 1.35;
  pointer-events: auto;
  animation: feat-toast-in 0.2s ease;
}
body[data-theme="dark"] .feat-toast { border: 1px solid rgba(255, 255, 255, 0.14); }
.feat-toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.feat-toast__msg { flex: 1; min-width: 0; }
.feat-toast__action {
  flex: none;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5eead4;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.feat-toast__action:hover { background: rgba(255, 255, 255, 0.08); }
.feat-toast__close {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
}
.feat-toast__close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.feat-toast :focus-visible { outline: 2px solid #5eead4; outline-offset: 2px; }

@keyframes feat-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* =========================================================
   Report dialog (#report-modal.rpt-modal)
   ========================================================= */
.rpt-modal { color: var(--surface-text, #1f2937); }
.rpt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rpt-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}
.rpt-close {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--feat-muted);
}
.rpt-close:hover { background: var(--feat-soft); color: var(--surface-text, #1f2937); }

.rpt-tabs {
  display: flex;
  flex-wrap: wrap; /* large text on phones: wrap instead of clipping */
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--feat-soft);
}
.rpt-tab {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 8px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--feat-muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
}
.rpt-tab:hover { color: var(--surface-text, #1f2937); }
.rpt-tab[aria-selected="true"] {
  background: var(--surface, #fff);
  color: var(--surface-text, #1f2937);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}
body[data-theme="dark"] .rpt-tab[aria-selected="true"] { background: rgba(255, 255, 255, 0.12); }

.rpt-body { gap: 16px; }
.rpt-panel {
  margin-top: 0;
  min-width: 0;
  border-radius: 6px;
}
.rpt-panel:focus-visible { outline-offset: 4px; }

.rpt-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(132px, 100%), 1fr));
  gap: 10px;
}
.rpt-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--feat-line);
  border-radius: 10px;
}
.rpt-tile__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--feat-muted);
}
.rpt-tile__value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.rpt-tile__unit {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--feat-muted);
}
.rpt-today {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--feat-soft);
  font-size: 0.9rem;
}
.rpt-today__label { font-weight: 800; }
.rpt-note,
.rpt-intro {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: var(--feat-muted);
}
.rpt-intro { margin-top: 0; }
.rpt-empty {
  margin: 0 0 4px;
  padding: 12px 14px;
  border: 1px dashed var(--feat-line);
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--feat-muted);
  text-align: center;
}

/* Bar charts */
.rpt-chart { margin: 18px 0 0; }
.rpt-chart:first-child { margin-top: 0; }
.rpt-chart__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}
.rpt-chart__title {
  font-size: 0.9rem;
  font-weight: 800;
}
.rpt-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--feat-muted);
}
.rpt-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rpt-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.rpt-swatch--correct { background: var(--chart-a); }
.rpt-swatch--wrong { background: var(--chart-b); }

.rpt-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  height: 168px;
  margin-top: 10px;
}
.rpt-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  height: 100%;
}
.rpt-col__val {
  height: 18px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--surface-text, #1f2937);
}
.rpt-col__track {
  display: flex;
  flex: 1;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid var(--feat-line);
  border-radius: 6px 6px 0 0;
  transition: background-color 0.15s ease;
}
.rpt-col__track:hover { background: var(--feat-soft); }
.rpt-bar {
  display: block;
  width: 62%;
  max-width: 30px;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
}
.rpt-bar--focus { background: var(--chart-a); }
.rpt-bar--stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.rpt-seg {
  display: block;
  flex-grow: 0;
  flex-shrink: 1;
  min-height: 2px;
}
.rpt-bar--stack > :first-child { border-radius: 4px 4px 0 0; }
.rpt-seg--correct { background: var(--chart-a); }
.rpt-seg--wrong { background: var(--chart-b); }
.rpt-col__day {
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--feat-muted);
}
.rpt-col.is-today .rpt-col__day {
  font-weight: 800;
  color: var(--surface-text, #1f2937);
}

/* By specialty */
.rpt-specs {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.rpt-spec {
  padding: 12px 0;
  border-top: 1px solid var(--feat-line);
}
.rpt-spec:first-child { border-top: 0; padding-top: 4px; }
.rpt-spec__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
}
.rpt-spec__name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 800;
}
.rpt-spec__focus {
  font-size: 0.8rem;
  color: var(--feat-muted);
}
.rpt-spec__noq {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--feat-muted);
}
.rpt-spec.is-empty .rpt-spec__name { font-weight: 600; color: var(--feat-muted); }
.rpt-acc {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.8rem;
}
.rpt-acc__label {
  font-weight: 700;
  color: var(--feat-muted);
}
.rpt-acc__track {
  height: 8px;
  border-radius: 999px;
  background: var(--feat-soft);
  overflow: hidden;
}
body[data-theme="dark"] .rpt-acc__track { background: rgba(255, 255, 255, 0.1); }
.rpt-acc__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--spec);
  transition: width 0.4s ease;
}
.rpt-acc__val {
  min-width: 92px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rpt-muted { color: var(--feat-muted); }

/* Pro teaser */
.pro-teaser {
  position: relative;
  margin-top: 6px;
  padding: 16px;
  border: 1px solid rgba(67, 56, 202, 0.25);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(67, 56, 202, 0.12));
}
body[data-theme="dark"] .pro-teaser {
  border-color: rgba(129, 140, 248, 0.3);
  background: linear-gradient(135deg, rgba(20, 162, 148, 0.12), rgba(99, 102, 241, 0.16));
}
.pro-teaser__head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pro-teaser__lock {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--feat-pro);
  color: #fff;
}
.pro-teaser__title {
  flex: 1;
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.25;
}
.pro-badge {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--feat-pro);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pro-teaser__list {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}
.pro-teaser__list li {
  position: relative;
  padding-left: 22px;
}
.pro-teaser__list li::before {
  content: "";
  position: absolute;
  top: 0.35em;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--feat-pro);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V8a5 5 0 0 1 10 0v2h1a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zm2 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V8a5 5 0 0 1 10 0v2h1a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zm2 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}
body[data-theme="dark"] .pro-teaser__list li::before { background: #a5b4fc; }
.pro-teaser__ghost {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 44px;
  margin-top: 14px;
  opacity: 0.28;
  filter: blur(1.5px);
}
.pro-teaser__ghost span {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: var(--feat-pro);
}
body[data-theme="dark"] .pro-teaser__ghost span { background: #a5b4fc; }
.pro-teaser__offer {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: var(--feat-muted);
}
.rpt-modal .pro-teaser a.pro-teaser__cta[href],
.pro-teaser__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--feat-pro);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 3px 0 var(--feat-pro-press);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}
.pro-teaser__cta:hover { filter: brightness(1.1); }
.pro-teaser__cta:active { transform: translateY(3px); box-shadow: none; }

/* =========================================================
   Responsive & motion
   ========================================================= */
@media (max-width: 420px) {
  .tasks__summary { flex-direction: column; align-items: center; gap: 2px; }
  .tasks__summary-sep { display: none; }
}

@media (max-width: 380px) {
  .qc { padding: 8px 8px 8px 4px; }
  .qc.is-expanded { padding-bottom: 14px; }
  .qc__step { min-width: 36px; height: 36px; }
  .qc__step--ten { min-width: 42px; }
  .qc__value { min-width: 38px; }
  .task__row { gap: 8px; padding: 12px 8px; }
  .task__note { margin-left: 44px; }
  .rpt-acc { grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; }
  .rpt-acc__val { min-width: 0; }
  .rpt-tab { font-size: 0.8rem; padding: 8px 4px; }
}

@media (hover: none) {
  .task-li[draggable="true"] { -webkit-user-drag: none; }
}

@media (prefers-reduced-motion: reduce) {
  .qc__value.is-bump,
  .qc__sum-a.is-bump,
  .qc__sum-c b.is-bump,
  .feat-menu,
  .task-editor,
  .tpl-panel,
  .feat-toast { animation: none; }
  .qc__ring-fill,
  .qc__chev,
  .qc__toggle,
  .rpt-bar,
  .rpt-acc__fill,
  .task,
  .feat-toast.is-leaving,
  .qc__quick-btn,
  .rpt-modal .pro-teaser a.pro-teaser__cta[href],
.pro-teaser__cta { transition: none; }
}

@media (forced-colors: active) {
  .spec-dot,
  .rpt-bar,
  .rpt-seg,
  .rpt-acc__fill,
  .rpt-swatch { forced-color-adjust: none; border: 1px solid CanvasText; }
  .task.is-active { border-left-color: Highlight; }
}

/* =========================================================
   Touch targets (≥ 40px)
   ========================================================= */
.qc__step,
.tasks__menu-btn,
.task__edit,
.tpl-panel__close,
.tpl-btn--icon { min-width: 40px; height: 40px; }
.tasks__menu-btn,
.task__edit,
.tpl-panel__close,
.tpl-btn--icon { width: 40px; }
.qc__select,
.spec-chip,
.tpl-btn--primary,
.task-editor__add-note { min-height: 40px; }
/* The round checkbox stays 28px visually; its hit area is 40px. */
.task__check { position: relative; }
.task__check::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
@media (max-width: 380px) {
  .qc__step { min-width: 40px; height: 40px; }
  .qc__step--ten { min-width: 44px; }
}

/* Contrast (WCAG AA): white text on the translucent cards over the light mode colours. */
.qc__acc-unit,
.tasks__summary-sep,
.tasks__summary-dur { opacity: 1; }
.qc__step { background: rgba(0, 0, 0, 0.18); }
.qc__step:hover:not(:disabled) { background: rgba(0, 0, 0, 0.28); }
body[data-theme="dark"] .qc__step { background: rgba(255, 255, 255, 0.12); }
body[data-theme="dark"] .qc__step:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
/* Compact question row: lighter tint keeps small white text above 4.5:1 on the light teal. */
body:not([data-theme="dark"]) .qc { background: rgba(255, 255, 255, 0.06); }

/* =========================================================
   v3: panels inside the "Seu dia" aside (owner: LAYOUT)
   ========================================================= */
/* The aside controls spacing between its panels (flex gap). */
.day-panel .qc,
.day-panel .tasks { margin-top: 0; }

/* Size the question row by its own width, not the viewport: the desktop aside
   is ~350px wide even on a large screen. */
#questions-panel { container-type: inline-size; }
@container (max-width: 400px) {
  .qc__bar .qc__quick-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .qc__bar .qc__quick-btn { width: 48px; min-width: 48px; padding: 0; justify-content: center; }
  .qc__bar .qc__quick-btn svg { width: 22px; height: 22px; }
}

/* v4 strip (≥700px): the column is the card (app.css §17), so the counter and
   the task list drop their own background/padding. */
@media (min-width: 700px) {
  .day-panel .qc,
  body:not([data-theme="dark"]) .day-panel .qc { padding: 0; border-radius: 0; background: none; }
  .day-panel .qc.is-expanded { padding-bottom: 0; }
  .day-panel .qc__toggle { padding-left: 4px; }
  .day-panel .qc__body { padding: 4px 4px 0; }
  .day-panel .tasks__header { padding-bottom: 10px; border-bottom-width: 1px; border-bottom-color: rgba(255, 255, 255, 0.35); }
  .day-panel .tasks__title { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .qc__float { display: none; }
}
