/* DxPomodoro. Cornice della famiglia Dx Labs (gli stessi token di DxFinance, DxTv, DxBackup e DxCare) con il rosso
   pomodoro come colore del prodotto e il verde per le pause. Due modi: chiaro e scuro (ardesia). */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;

  /* Superfici e inchiostri di famiglia. */
  --page: #f9fafb;
  --raised: #ffffff;
  --inset: #f3f4f6;
  --alt: #f1f5f9;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --line-input: #d1d5db;

  /* Rosso pomodoro: riempimento con testo bianco 5,4:1, passaggio del mouse sul 700. */
  --tomato-50: #fff4f1;
  --tomato-100: #ffe6df;
  --tomato-200: #ffcdc1;
  --tomato-300: #fda793;
  --tomato-400: #f47a5f;
  --tomato-500: #d13f25;
  --tomato-600: #c8321c;
  --tomato-700: #a82714;
  --tomato-800: #851f12;
  --tomato-900: #5f160d;
  --primary: #c8321c;
  --primary-deep: #a82714;
  --primary-text: #a82714;
  --primary-wash: rgb(200 50 28 / 0.09);
  --on-primary: #ffffff;

  /* Verde delle pause: 700 per i riempimenti con testo bianco (5:1), 600 per i segni. */
  --rest: #16a34a;
  --rest-fill: #15803d;
  --rest-text: #166534;
  --rest-wash: rgb(22 163 74 / 0.12);

  /* Stati di famiglia. */
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --bad: #dc2626;

  --ring: #c8321c;
  --shadow-card: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-pop: 0 10px 15px -3px rgb(15 23 42 / 0.12), 0 4px 6px -4px rgb(15 23 42 / 0.1);
  --backdrop: rgb(15 23 42 / 0.45);
  /* Binario della scelta delle fasi sopra il quadrante colorato: scurisce il colore della fase. */
  --flood-track: rgb(0 0 0 / 0.16);
  /* Interruttore spento: grigio con contrasto oltre 3:1 sulla scheda. */
  --switch-off: #8b929e;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --topbar-h: 56px;

  color-scheme: light;
}

html.dark {
  --page: #0f172a;
  --raised: #1e293b;
  --inset: #172033;
  --alt: #273449;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --line: #334155;
  --line-soft: #273449;
  --line-input: #475569;

  --primary: #d13f25;
  --primary-deep: #b93520;
  --primary-text: #ffb4a2;
  --primary-wash: rgb(255 180 162 / 0.13);

  --rest: #22c55e;
  --rest-fill: #15803d;
  --rest-text: #86efac;
  --rest-wash: rgb(134 239 172 / 0.13);

  --ok-bg: rgb(22 101 52 / 0.38);
  --ok-text: #86efac;
  --warn-bg: rgb(120 53 15 / 0.45);
  --warn-text: #fcd34d;
  --bad: #f87171;

  --ring: #ffb4a2;
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-pop: 0 12px 28px -6px rgb(0 0 0 / 0.55), 0 4px 8px -4px rgb(0 0 0 / 0.4);
  --backdrop: rgb(2 6 23 / 0.62);
  --switch-off: #7c8aa0;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line-input) transparent;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--primary);
  caret-color: var(--primary);
}

h1,
h2,
h3,
p,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

h2,
h3,
strong {
  color: var(--ink);
}

/* Niente parola sola sull'ultima riga di un paragrafo. */
p {
  text-wrap: pretty;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary-text);
  text-underline-offset: 3px;
}

::selection {
  background: var(--primary-wash);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 30;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--page);
  font-weight: 600;
  text-decoration: none;
}

.skip:focus {
  top: 10px;
}

.noscript {
  margin: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

/* Avviso di pagina: qualcosa che chi usa lo strumento deve sapere adesso. */
.notice {
  grid-column: 1 / -1;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.875rem;
}

/* ---------- Cornice ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.topbar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1120px;
  height: var(--topbar-h);
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--tomato-600);
  color: #ffffff;
  box-shadow:
    0 10px 15px -3px rgb(200 50 28 / 0.2),
    0 4px 6px -4px rgb(200 50 28 / 0.2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  transition:
    background 200ms ease-out,
    color 200ms ease-out;
}

.icon-btn:hover {
  background: var(--alt);
  color: var(--ink);
}

.icon-moon,
html.dark .icon-sun {
  display: none;
}

html.dark .icon-moon {
  display: block;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1152px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.side {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.footer {
  border-top: 1px solid var(--line);
  background: var(--raised);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.footer .sign {
  margin-top: 2px;
}

.footer a {
  font-weight: 600;
}

/* ---------- Pulsanti e campi ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background 200ms ease-out,
    border-color 200ms ease-out,
    color 200ms ease-out,
    transform 120ms ease-out;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-deep);
}

.btn-quiet {
  background: var(--raised);
  border-color: var(--line);
  color: var(--ink-2);
  box-shadow: var(--shadow-card);
}

.btn-quiet:hover {
  background: var(--alt);
  color: var(--ink);
}

.btn-tool {
  background: var(--primary-wash);
  border-color: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary-text);
  font-weight: 600;
}

.btn-tool:hover {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
}

.btn-lg {
  height: 52px;
  min-width: 156px;
  padding: 0 28px;
  border-radius: 12px;
  font-size: 1.125rem;
}

.btn-lg .icon {
  width: 20px;
  height: 20px;
}

.btn-sm {
  height: 36px;
  padding: 0 12px;
}

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--primary-text);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

.link-btn:hover {
  text-decoration-color: currentColor;
}

.field {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-input);
  border-radius: 8px;
  background: var(--raised);
  color: var(--ink);
  /* 16px: sotto questa misura iOS ingrandisce la pagina quando il campo prende il fuoco. */
  font-size: 1rem;
  transition:
    border-color 200ms ease-out,
    box-shadow 200ms ease-out;
}

.field::placeholder {
  color: var(--muted);
  opacity: 1;
}

.field:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-wash);
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  font-size: 0.9375rem;
}

html.dark .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.25;
}

.pill-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

/* Scelta segmentata di famiglia. */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--inset);
  transition: background 300ms ease-out;
}

.seg-item {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition:
    background 200ms ease-out,
    color 200ms ease-out;
}

.seg-item:hover {
  color: var(--ink);
}

.seg-item[aria-pressed="true"] {
  background: var(--raised);
  border-color: var(--line);
  color: var(--primary-text);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.seg-sm .seg-item {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

/* Gettone a forma di pomodoro: un pomodoro fatto, da fare o in corso. */
.tk {
  width: 24px;
  height: 24px;
  flex: none;
  overflow: visible;
}

.tk-body {
  fill: transparent;
  stroke: var(--tk-off, var(--line-input));
  stroke-width: 1.75;
  transition:
    fill 300ms ease-out,
    stroke 300ms ease-out;
}

.tk-leaf {
  fill: var(--tk-off, var(--line-input));
  transition: fill 300ms ease-out;
}

.tk.is-now .tk-body {
  stroke: var(--tk-on, var(--primary));
}

.tk.is-now .tk-leaf {
  fill: var(--tk-leaf, var(--rest));
}

.tk.is-on .tk-body {
  fill: var(--tk-on, var(--primary));
  stroke: var(--tk-on, var(--primary));
}

.tk.is-on .tk-leaf {
  fill: var(--tk-leaf, var(--rest));
}

.tk.is-new {
  animation: tk-pop 520ms var(--ease-out);
}

@keyframes tk-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

/* ---------- Quadrante ---------- */

.timer {
  --phase-fill: var(--tomato-600);
  --phase-text: var(--primary-text);
  --phase-wash: var(--primary-wash);
  --tick: var(--primary);
  --t-ink: var(--ink);
  --t-soft: var(--muted);
  --tick-rest: 0.2;

  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--raised);
  box-shadow: var(--shadow-card);
  color: var(--t-ink);
  transition: border-color 400ms ease-out;
}

.timer:focus {
  outline: none;
}

.timer[data-phase="short"],
.timer[data-phase="long"] {
  --phase-fill: var(--rest-fill);
  --phase-text: var(--rest-text);
  --phase-wash: var(--rest-wash);
  --tick: var(--rest);
}

/* In corso: il quadrante prende il colore della fase e tutto quello che ci sta sopra passa al bianco. */
.timer[data-status="running"] {
  --t-ink: #ffffff;
  --t-soft: #ffffff;
  --phase-text: #ffffff;
  --tick: #ffffff;
  --tick-rest: 0.3;
  --ring: #ffffff;
  --tk-on: #ffffff;
  --tk-off: rgb(255 255 255 / 0.5);
  --tk-leaf: #ffffff;
  border-color: var(--phase-fill);
}

.timer-flood {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--phase-fill);
  clip-path: circle(0% at var(--fx, 50%) var(--fy, 82%));
  transition:
    clip-path 760ms var(--ease-out),
    background 500ms ease-out;
}

.timer[data-status="running"] .timer-flood {
  clip-path: circle(150% at var(--fx, 50%) var(--fy, 82%));
}

.timer-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-height: min(calc(100dvh - var(--topbar-h) - 32px - env(safe-area-inset-top)), 680px);
  padding: 20px 16px 24px;
}

.timer .seg {
  max-width: 100%;
}

/* Binario scuro: le fasi non scelte restano bianche su un fondo più profondo (7:1 sul rosso, 6,6:1 sul verde). */
.timer[data-status="running"] .seg {
  background: var(--flood-track);
}

/* Da fermo la fase scelta prende il colore della fase, non quello del prodotto: verde nelle pause. */
.timer .seg-item[aria-pressed="true"] {
  color: var(--phase-text);
}

.timer[data-status="running"] .seg-item {
  color: #ffffff;
}

.timer[data-status="running"] .seg-item[aria-pressed="true"] {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--phase-fill);
  box-shadow: none;
}

.dial {
  position: relative;
  width: min(340px, 82vw, 44dvh);
  aspect-ratio: 1;
  margin: auto 0;
  flex: none;
}

.dial-ring {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tick {
  stroke: var(--tick);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 1;
  transition:
    stroke 400ms ease-out,
    opacity 400ms ease-out;
}

.tick-major {
  stroke-width: 3.5;
}

.tick.is-off {
  opacity: var(--tick-rest);
}

/* All'avvio le tacche si accendono in giro, una dopo l'altra. */
.dial-ring.is-sweep .tick {
  animation: tick-in 620ms var(--ease-out) backwards;
  animation-delay: calc(var(--i) * 9ms);
}

@keyframes tick-in {
  from {
    stroke-width: 9;
    opacity: 0;
  }
}

.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15%;
  text-align: center;
}

.dial-time {
  color: var(--t-ink);
  font-size: clamp(3.25rem, 19vw, 5.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  transition: color 300ms ease-out 80ms;
}

.dial-time.is-long {
  font-size: clamp(2.75rem, 15vw, 4.5rem);
}

/* Stato come pillola di famiglia: parola e icona. Velatura della fase da fermo, bianca sul quadrante colorato. */
.dial-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px 3px 8px;
  border-radius: 999px;
  background: var(--phase-wash);
  color: var(--phase-text);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  transition:
    color 300ms ease-out 80ms,
    background 300ms ease-out 80ms;
}

.dial-status .icon {
  width: 13px;
  height: 13px;
}

.timer[data-status="running"] .dial-status {
  background: #ffffff;
  color: var(--phase-fill);
}

.dial-task {
  display: -webkit-box;
  /* Stretto e bilanciato: una frase lunga va su due righe corte, lontana dalle tacche. */
  max-width: min(100%, 13em);
  text-wrap: balance;
  overflow: hidden;
  color: var(--t-soft);
  font-size: 0.875rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  transition: color 300ms ease-out 80ms;
}

.cycle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.cycle-tokens {
  display: flex;
  gap: 6px;
}

.cycle-label {
  color: var(--t-soft);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 300ms ease-out 80ms;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 460px;
}

.controls .btn-quiet {
  height: 44px;
}

.controls .btn-quiet:first-child {
  justify-self: end;
}

.controls .btn-quiet:last-child {
  justify-self: start;
}

.timer[data-status="running"] .btn-primary {
  background: #ffffff;
  color: var(--phase-fill);
}

.timer[data-status="running"] .btn-primary:hover {
  background: rgb(255 255 255 / 0.9);
}

.timer[data-status="running"] .btn-quiet {
  background: transparent;
  border-color: rgb(255 255 255 / 0.5);
  color: #ffffff;
  box-shadow: none;
}

.timer[data-status="running"] .btn-quiet:hover {
  background: rgb(255 255 255 / 0.14);
}

.kbd-hint {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  color: var(--t-soft);
  font-size: 0.75rem;
  transition: color 300ms ease-out 80ms;
}

.kbd-hint .dot {
  width: 3px;
  height: 3px;
  margin: 0 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Schede ---------- */

.card {
  min-width: 0;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--raised);
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 12px;
}

.card h2,
.how h2 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.sub-head {
  margin: 20px 0 10px;
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 600;
}

.empty {
  padding: 14px;
  border-radius: 12px;
  background: var(--inset);
  color: var(--ink-2);
  font-size: 0.875rem;
}

/* Attività */

.task-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

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

.task-form-row .btn {
  margin-left: auto;
  height: 44px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-input);
  border-radius: 8px;
  background: var(--raised);
}

.stepper-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  transition: background 200ms ease-out;
}

.stepper-btn:hover {
  background: var(--alt);
}

.stepper-btn:disabled {
  color: var(--line-input);
  cursor: default;
  background: transparent;
}

.stepper-btn .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.stepper-value {
  min-width: 24px;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.stepper-label {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.25;
}

.task-form + .set-note {
  margin: 0 0 12px;
}

.task-list {
  display: grid;
  gap: 2px;
}

.task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 2px;
  border-radius: 10px;
  transition: background 200ms ease-out;
}

.task.is-active {
  background: var(--primary-wash);
}

.task-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

.task-pick::before {
  content: "";
  width: 18px;
  height: 18px;
  /* Il cerchio è l'unico segno del comando: il bordo ha contrasto oltre 3:1 sulla scheda, in chiaro e in scuro. */
  border: 2px solid var(--muted);
  border-radius: 999px;
  background: var(--raised);
  transition:
    border-color 200ms ease-out,
    box-shadow 200ms ease-out;
}

.task-pick:hover::before {
  border-color: var(--primary);
}

.task.is-active .task-pick::before {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 3px var(--raised), inset 0 0 0 9px var(--primary);
}

.task-title {
  min-width: 0;
  padding: 10px 6px 10px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.task.is-active .task-title {
  color: var(--primary-text);
  font-weight: 600;
}

.task.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task.is-done .task-pick {
  visibility: hidden;
}

.task-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.task-count .tk {
  width: 16px;
  height: 16px;
}

.task-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition:
    background 200ms ease-out,
    color 200ms ease-out;
}

.task-act:hover {
  background: var(--alt);
  color: var(--ink);
}

.task.is-active .task-act:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.task.is-done .task-check {
  color: var(--ok-text);
}

/* Oggi */

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

.goal .tk {
  width: 28px;
  height: 28px;
}

.today-line {
  margin-top: 10px;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.week-n {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.week-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  max-width: 34px;
  height: 64px;
  border-radius: 6px;
  background: var(--inset);
  overflow: hidden;
}

.week-bar {
  width: 100%;
  min-height: 0;
  border-radius: 6px 6px 0 0;
  background: color-mix(in srgb, var(--primary) 45%, var(--inset));
}

.week-day.is-today .week-bar {
  background: var(--primary);
}

.week-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.week-day.is-today .week-label,
.week-day.is-today .week-n {
  color: var(--ink);
  font-weight: 700;
}

.streak {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Come funziona */

.how {
  padding: 12px 4px 0;
}

.how-steps {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  counter-reset: step;
}

.how-steps li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  column-gap: 12px;
  counter-increment: step;
  font-size: 0.875rem;
}

.how-steps li::before {
  content: counter(step);
  grid-row: span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-radius: 999px;
  color: var(--primary-text);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.how-steps strong {
  font-weight: 600;
}

.how-steps span {
  grid-column: 2;
  color: var(--muted);
}

/* ---------- Impostazioni ---------- */

dialog {
  padding: 0;
  border: 0;
  background: var(--raised);
  color: var(--ink-2);
}

dialog::backdrop {
  background: var(--backdrop);
}

.drawer {
  inset: 0 0 0 auto;
  width: min(420px, 100vw);
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.drawer[open] {
  display: flex;
  flex-direction: column;
  animation: drawer-in 380ms var(--ease-out);
}

.drawer[open]::backdrop {
  animation: fade-in 300ms ease-out;
}

@keyframes drawer-in {
  from {
    transform: translateX(48px);
    opacity: 0;
  }
}

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

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 20px calc(24px + env(safe-area-inset-bottom));
}

.set-group {
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
}

.set-group:last-child {
  border-bottom: 0;
}

.set-group h3 {
  margin-bottom: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.set-row,
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.switch-row {
  padding: 6px 0;
  cursor: pointer;
}

.switch-row > span {
  display: grid;
  gap: 2px;
}

.switch-row small,
.set-note {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.set-note {
  margin-top: 6px;
  max-width: 46ch;
}

.set-note + .btn {
  margin-top: 12px;
}

.set-note-warn {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.num {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.num .stepper-btn {
  border: 1px solid var(--line-input);
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.num-input {
  width: 52px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.num-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-wash);
}

.unit {
  min-width: 68px;
  padding-left: 8px;
  color: var(--muted);
  font-size: 0.8125rem;
}

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

.sound-row .select {
  width: 148px;
  height: 40px;
}

.sound-row .btn {
  height: 40px;
}

.range {
  width: 168px;
  height: 28px;
  margin: 0;
}

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  appearance: none;
  transition: background 200ms ease-out;
}

.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.3);
  transition: transform 220ms var(--ease-out);
}

.switch:checked {
  background: var(--primary);
}

.switch:checked::before {
  transform: translateX(18px);
}

.confirm {
  width: min(400px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
}

.confirm[open] {
  animation: confirm-in 260ms var(--ease-out);
}

@keyframes confirm-in {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
}

.confirm h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.confirm p {
  margin-top: 6px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ---------- Pagina non trovata ---------- */

.lost {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.lost-card {
  width: min(440px, 100%);
  padding: 28px 24px;
  text-align: center;
}

.lost-code {
  color: var(--primary-text);
  font-size: clamp(3.25rem, 19vw, 5.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.lost-card h1 {
  margin-top: 12px;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lost-card p {
  margin: 6px 0 20px;
}

/* ---------- Misure ---------- */

@media (max-width: 400px) {
  .seg-item {
    padding: 0 10px;
  }

  .controls {
    gap: 8px;
  }

  .controls .btn-quiet span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .controls .btn-quiet {
    width: 48px;
    padding: 0;
  }

  .btn-lg {
    min-width: 148px;
  }
}

@media (min-width: 560px) {
  .how-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
  }
}

@media (min-width: 640px) {
  .main {
    padding-top: 24px;
    gap: 24px;
  }

  .side {
    gap: 24px;
  }

  .card {
    padding: 20px;
  }

  .timer-in {
    gap: 24px;
    padding: 24px 24px 28px;
  }
}

@media (min-width: 720px) and (max-width: 1023px) {
  .side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timer-in {
    min-height: 600px;
  }
}

@media (min-width: 1024px) {
  .main {
    grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
    padding-top: 32px;
    padding-bottom: 48px;
  }

  .timer-in {
    min-height: 640px;
    height: 100%;
  }

  .dial {
    width: min(360px, 44dvh);
  }

  .how {
    grid-column: 1 / -1;
    padding-top: 16px;
  }

  .how-steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 720px) {
  .kbd-hint {
    display: flex;
  }
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn {
    min-width: 36px;
    height: 36px;
  }
}

/* Con il dito ogni bersaglio è alto e largo almeno 44px. */
@media (pointer: coarse) {
  .icon-btn {
    min-width: 44px;
    height: 44px;
  }

  .seg-item,
  .seg-sm .seg-item {
    min-height: 44px;
  }

  .btn,
  .btn-sm,
  .sound-row .btn,
  .sound-row .select {
    height: 44px;
  }

  .btn-lg {
    height: 52px;
  }

  .stepper-btn,
  .num .stepper-btn {
    width: 44px;
    height: 44px;
  }

  .num-input {
    width: 44px;
    height: 44px;
  }

  .task-pick,
  .task-act {
    width: 44px;
  }

  .link-btn {
    min-height: 44px;
    padding: 0 6px;
  }

  .unit {
    min-width: 62px;
    padding-left: 6px;
  }

  .range {
    height: 44px;
  }
}

/* Su schermi stretti il conteggio dell'attività scende sotto il titolo e lascia posto al testo. */
@media (max-width: 480px) {
  .task {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }

  .task-title {
    grid-column: 2;
    grid-row: 1;
    padding-bottom: 0;
  }

  .task-count {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    padding: 0 0 8px;
  }

  .task-pick,
  .task-act {
    grid-row: 1 / span 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
}
