* { box-sizing: border-box; }

:root {
  --bg: #fff;
  --surface: #f3f3f3;
  --text: #111;
  --border: #111;
  --focus: #005fcc;
  --danger: #8b0000;
  --base-size: 20px;
}

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

button, select { font: inherit; }

button {
  min-height: 64px;
  border: 3px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: .8rem 1.2rem;
  font-weight: 800;
  cursor: pointer;
}

button:disabled { opacity: .5; cursor: not-allowed; }

button:focus-visible, select:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 4px;
}

.install-button {
  margin-top: .75rem;
  background: #f2c94c;
  color: #111;
}

main {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.3rem); }

.card {
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  background: var(--bg);
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

label { display: block; font-weight: 800; margin-bottom: .4rem; }

select {
  min-height: 56px;
  min-width: 150px;
  padding: .5rem;
  border: 3px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.activity {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem;
  margin-top: 1.2rem;
}

.primary { background: var(--text); color: var(--bg); }
.danger { color: var(--danger); border-color: var(--danger); }

.timer { text-align: center; }

.timer-value {
  font-size: clamp(4rem, 16vw, 9rem);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 1rem 0;
}

.status {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 900;
}

.progress {
  height: 30px;
  border: 3px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
}

.progress > div { height: 100%; background: var(--text); }

.high-contrast {
  --bg: #000;
  --surface: #111;
  --text: #fff;
  --border: #fff;
  --focus: #ff0;
  --danger: #ff8080;
}

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

@media (max-width: 600px) {
  main { width: calc(100% - 1rem); padding-top: 1rem; }
  .activity { grid-template-columns: 1fr; }
}

.history-list {
  display: grid;
  gap: .75rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.status-completed { font-weight: 900; }
.status-abandoned { font-weight: 900; color: var(--danger); }

@media (max-width: 600px) {
  .history-item {
    align-items: flex-start;
    flex-direction: column;
  }
}

.app-nav {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.nav-active {
  background: var(--text);
  color: var(--bg);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  background: var(--bg);
}

.stat-card span {
  display: block;
  font-weight: 800;
  margin-bottom: .4rem;
}

.stat-card strong {
  display: block;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.1;
}

.week-progress-list {
  display: grid;
  gap: 1rem;
}

.week-progress {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.week-progress-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .5rem;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.history-actions button {
  min-height: 48px;
}

@media (max-width: 600px) {
  .week-progress-header {
    flex-direction: column;
    gap: .25rem;
  }

  .app-nav {
    position: static;
  }
}

.accessibility-panel {
  display: grid;
  gap: 1rem;
}

.accessibility-panel label {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 800;
}

.accessibility-panel input[type="checkbox"] {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.accessibility-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.accessibility-controls button {
  min-width: 64px;
  min-height: 64px;
  font-size: 1.6rem;
  font-weight: 900;
}

.font-scale-value {
  min-width: 100px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 900;
}

.accessibility-panel select {
  display: block;
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  margin-top: .5rem;
}

@media (max-width: 600px) {
  .app-nav button {
    flex: 1 1 100%;
  }
}


/* Utility used by the application views/navigation. */
.hidden {
  display: none !important;
}

.view {
  width: 100%;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: sticky;
  top: 0.75rem;
  z-index: 10;
}

.nav-button {
  flex: 1 1 180px;
  min-height: 3.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.nav-button.nav-active {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  padding: 1.25rem;
  border: 2px solid currentColor;
  border-radius: 0.75rem;
}

.stat-card span,
.stat-card strong {
  display: block;
}

.stat-card strong {
  margin-top: 0.5rem;
  font-size: 1.5rem;
}

.accessibility-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.accessibility-controls button {
  min-width: 4rem;
  min-height: 3.5rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.font-scale-value {
  min-width: 5rem;
  text-align: center;
  font-weight: 700;
}

.history-list,
.week-progress-list {
  display: grid;
  gap: 0.75rem;
}

.history-item,
.week-progress {
  padding: 1rem;
  border: 1px solid currentColor;
  border-radius: 0.6rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-completed {
  font-weight: 700;
}

.status-abandoned {
  font-weight: 700;
}

@media (max-width: 700px) {
  .app-nav {
    position: static;
  }

  .history-item {
    flex-direction: column;
    align-items: stretch;
  }
}
