:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1113;
  color: #f3f7f7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #0d1113;
  --surface: #171d20;
  --surface-strong: #1f272b;
  --line: rgba(255, 255, 255, 0.11);
  --muted: #95a0a3;
  --text: #f3f7f7;
  --teal: #63d9d6;
  --lime: #b8eb6b;
  --orange: #ffb45a;
  --red: #ff6f70;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(99, 217, 214, 0.10), transparent 34rem),
    linear-gradient(145deg, #0d1113 0%, #121012 46%, #0f1512 100%);
}

body {
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 9vw, 4.8rem);
  line-height: 0.95;
  font-weight: 850;
}

h2 {
  font-size: 1rem;
}

.status-text {
  max-width: 36rem;
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.state-badge.is-running {
  border-color: rgba(184, 235, 107, 0.45);
  background: rgba(184, 235, 107, 0.12);
  color: var(--lime);
}

.counter-panel,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 29, 32, 0.86);
  box-shadow: var(--shadow);
}

.counter-panel {
  display: grid;
  place-items: center;
  min-height: clamp(260px, 40vh, 460px);
  padding: 28px 18px;
}

.jump-count {
  font-size: clamp(5.8rem, 28vw, 15rem);
  line-height: 0.9;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.jump-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: clamp(1.1rem, 4vw, 1.8rem);
  font-weight: 750;
}

.jump-count.bump {
  animation: bump 180ms ease-out;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  55% {
    transform: scale(1.035);
    color: var(--lime);
  }
  100% {
    transform: scale(1);
  }
}

.meter-wrap {
  width: min(640px, 100%);
  margin-top: 28px;
}

.meter-track {
  position: relative;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lime), var(--teal), var(--orange), var(--red));
  transition: width 90ms linear;
}

.threshold-marker {
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.92);
}

.meter-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  min-height: 122px;
  padding: 16px;
}

.metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 28px;
  margin-bottom: 16px;
  border-radius: 999px;
  background: rgba(99, 217, 214, 0.12);
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.control-strip {
  display: grid;
  grid-template-columns: 1fr 0.48fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.ghost-button,
.mini-button,
.segment {
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button,
.ghost-button {
  min-height: 58px;
  padding: 0 18px;
}

.primary-button {
  background: var(--teal);
  color: #051012;
}

.primary-button.is-running {
  background: var(--red);
  color: #160305;
}

.ghost-button,
.mini-button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.mini-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 14px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.panel-title-stack {
  display: grid;
  gap: 4px;
}

.panel-title-stack span {
  color: var(--muted);
  font-size: 0.78rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
}

.switch-row input {
  position: relative;
  width: 52px;
  height: 30px;
  min-height: 30px;
  border-radius: 999px;
  appearance: none;
  background: rgba(255, 255, 255, 0.13);
  padding: 0;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-row input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f3f7f7;
  transition: transform 160ms ease;
}

.switch-row input:checked {
  border-color: rgba(99, 217, 214, 0.62);
  background: rgba(99, 217, 214, 0.32);
}

.switch-row input:checked::before {
  transform: translateX(22px);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0;
}

.segment {
  min-height: 38px;
  padding: 0 10px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.9rem;
}

.segment.is-active {
  border-color: rgba(99, 217, 214, 0.42);
  background: rgba(99, 217, 214, 0.16);
  color: var(--teal);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label span,
.range-label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: rgba(99, 217, 214, 0.78);
  box-shadow: 0 0 0 3px rgba(99, 217, 214, 0.13);
}

input[type="range"] {
  accent-color: var(--teal);
  padding: 0;
}

progress {
  width: 100%;
  height: 12px;
  margin: 12px 0 14px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
}

progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.11);
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--teal), var(--lime));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--teal), var(--lime));
}

.pill-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.range-label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.range-label input {
  grid-column: 1 / -1;
}

.range-label strong {
  color: var(--teal);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.error-text {
  min-height: 20px;
  margin-top: 12px;
  color: var(--orange);
  font-size: 0.9rem;
  line-height: 1.35;
}

.error-text.is-success {
  color: var(--lime);
}

.history-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.cloud-sync {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.cloud-sync .history-actions {
  margin-bottom: 0;
}

.cloud-sync span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.cloud-sync input {
  font-size: 0.86rem;
  letter-spacing: 0;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-empty {
  color: var(--muted);
}

.history-summary {
  padding: 10px 12px;
  border: 1px solid rgba(99, 217, 214, 0.18);
  border-radius: 8px;
  background: rgba(99, 217, 214, 0.08);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.history-item strong {
  font-size: 1rem;
}

.history-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-inline: 14px;
  }

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

  .state-badge {
    width: fit-content;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 112px;
    padding: 14px;
  }

  .control-strip {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .pill-row {
    grid-template-columns: 1fr;
  }
}
