:root {
  --bg: #f7f7f8;
  --fg: #1f2937; /* slate-800 */
  --muted: #6b7280; /* slate-500 */
  --card: #ffffff;
  --primary: #2563eb; /* blue-600 */
  --primary-press: #1e40af; /* blue-800 */
  --ring: rgba(37, 99, 235, 0.35);
  --border: #e5e7eb;
  --anchor-offset: 40px; /*Anchor offset for sticky header */
}

.theme-dark {
  --bg: #111827; /* gray-900 */
  --fg: #e5e7eb; /* gray-200 */
  --muted: #9ca3af; /* gray-400 */
  --card: #0b1220;
  --primary: #93c5fd; /* blue-300 */
  --primary-press: #60a5fa; /* blue-400 */
  --ring: rgba(147, 197, 253, 0.35);
  --border: #1f2937; /* gray-800 */
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    "Apple Color Emoji",
    "Segoe UI Emoji";
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.site-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand__logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-block;
  background-color: transparent;
  background-image: -webkit-image-set(
    url("images/apple-touch-icon.png") type("image/png") 1x,
    url("images/apple-touch-icon.png") type("image/png") 2x
  );
  background-image: url("images/apple-touch-icon.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

.app {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.card {
  width: min(760px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.countdown-card {
  display: grid;
  gap: 18px;
}

.countdown-card.is-reached {
  box-shadow:
    0 0 0 1px color-mix(in srgb, #ef4444 45%, transparent),
    0 18px 40px rgba(239, 68, 68, 0.14);
}

.title {
  margin: 0;
  text-align: center;
  font-size: clamp(32px, 5vw, 48px);
}

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

.metric {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.metric__value {
  font-size: clamp(34px, 6vw, 62px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric__label {
  margin-top: 8px;
  color: var(--muted);
  text-transform: lowercase;
}

.status {
  min-height: 20px;
  text-align: center;
  color: var(--muted);
}

.reached-indicator {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid #fca5a5;
  border-radius: 14px;
  background: color-mix(in srgb, #ef4444 10%, var(--card));
  animation: reachedPulse 1.8s ease-in-out infinite;
}

.reached-indicator[hidden] {
  display: none;
}

.reached-indicator__pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, #ef4444 18%, var(--card));
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reached-indicator__title {
  font-size: clamp(20px, 3.5vw, 28px);
  line-height: 1.1;
}

@keyframes reachedPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.015);
  }
}

.theme-dark .reached-indicator__pill {
  color: #fecaca;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.controls--tight {
  justify-content: flex-start;
}

.preset-categories {
  display: grid;
  gap: 10px;
}

.preset-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--card) 92%, var(--bg));
}

.preset-group__toggle {
  appearance: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

.preset-group.is-open .preset-group__toggle {
  border-bottom-color: var(--border);
}

.preset-group__panel {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 10px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  min-width: 84px;
  transition:
    box-shadow 0.15s ease,
    transform 0.02s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

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

.btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.btn--primary:active {
  background: var(--primary-press);
}

.btn--ghost {
  background: transparent;
}

.btn--chip {
  min-width: 0;
  padding: 8px 12px;
  font-weight: 500;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.edit-form {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.edit-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.edit-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--fg);
}

.hints {
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

.site-footer .wrap {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}

.site-footer a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  text-decoration-thickness: 2px;
}

.site-footer a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-radius: 4px;
}

.bmc {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .card {
    padding: 18px;
  }

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

  .header-actions .bmc {
    display: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  font-size: large;
}
