:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --text: #2b2a28;
  --text-dim: #7a766e;
  --accent: #e2673a;
  --accent-soft: #f6d9cc;
  --track: #ece7dc;
  --border: #e6e1d6;
  --shadow: 0 8px 24px rgba(43, 42, 40, 0.08);
}

[data-theme="dark"] {
  --bg: #1c1b19;
  --card: #262421;
  --text: #f2ede4;
  --text-dim: #a49d90;
  --accent: #ef7c50;
  --accent-soft: #4a2f22;
  --track: #33302a;
  --border: #3a3733;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease;
}

.icon-btn:hover { transform: translateY(-1px); }
.icon-btn.active { background: var(--accent-soft); border-color: var(--accent); }

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.mode-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
}

.timer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}

.ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-track {
  fill: none;
  stroke: var(--track);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 628.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s linear, stroke 0.3s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.time {
  font-size: 42px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

.cycle-label {
  font-size: 12px;
  color: var(--text-dim);
}

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 13px 32px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.primary-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.primary-btn.small { padding: 9px 18px; font-size: 13px; width: 100%; margin-top: 4px; }

.stats-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-dim); text-align: center; }

.chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 70px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-fill {
  width: 100%;
  max-width: 22px;
  background: var(--track);
  border-radius: 6px;
  transition: height 0.3s ease, background 0.3s ease;
}

.chart-bar-fill.filled { background: var(--accent); }

.chart-bar-day {
  font-size: 10px;
  color: var(--text-dim);
}

.link-btn {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

/* display: flex below would otherwise beat the [hidden] attribute */
.settings-card[hidden] { display: none; }

.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.settings-card label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
}

.settings-card input {
  width: 70px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

.stats-total {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}

.report-card {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}

.report-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.report-period {
  margin: 4px 0 14px;
  font-size: 11px;
  color: var(--text-dim);
}

.report-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}

.report-row strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* --- pagina statistiche --- */

.app.wide { max-width: 560px; }

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

a.link-btn { text-align: center; }

.empty-state {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.hero-label { font-size: 12px; color: var(--text-dim); }

.hero-value {
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.hero-sub { font-size: 12px; color: var(--text-dim); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.tile-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tile-label { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

.section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}

.section-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.section-note {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 130px;
}

.bar {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.bar-fill {
  width: 100%;
  background: var(--track);
  border-radius: 4px;
}

.bar-fill.filled { background: var(--accent); }

.bar-label {
  font-size: 9px;
  color: var(--text-dim);
  height: 12px;
}

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

.row {
  display: grid;
  grid-template-columns: 84px 1fr 96px;
  align-items: center;
  gap: 10px;
}

.row-label { font-size: 12px; color: var(--text-dim); }

.row-track {
  background: var(--track);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}

.row-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  min-width: 0;
}

.row-value {
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* today sits at the centre of the week strip and is marked as such */
.chart-bar.today .chart-bar-day {
  color: var(--accent);
  font-weight: 700;
}

.chart-bar.today .chart-bar-fill {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
