:root {
  --bg: #F5F0E8;
  --ink: #111111;
  --accent-yellow: #FFE45C;
  --accent-blue: #A8C7FA;
  --success: #3DDC84;
  --warning: #FFE45C;
  --orange: #FF8A3D;
  --danger: #FF5252;
  --muted: #5c5c5c;
  --border: 3px solid var(--ink);
  --shadow-hard: 6px 6px 0 0 var(--ink);
  --shadow-hard-sm: 4px 4px 0 0 var(--ink);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  border-bottom: var(--border);
  background: var(--accent-yellow);
  padding: 14px 20px;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.logo { font-weight: 700; font-size: 22px; letter-spacing: 0.5px; }
.subtitle { font-size: 12px; letter-spacing: 2px; font-weight: 500; opacity: 0.8; }

.badge {
  display: inline-block;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 8px 12px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
  background: #fff;
}
.badge-neutral { background: #fff; }
.badge-ok { background: var(--success); }
.badge-error { background: var(--danger); color: #fff; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  width: 100%;
  flex: 1;
}

.hero { margin: 20px 0 32px; }
.hero h1 {
  font-size: clamp(32px, 6vw, 64px);
  line-height: 0.95;
  margin: 0 0 14px;
  letter-spacing: -1px;
  font-weight: 700;
}
.hero-desc {
  font-size: 16px;
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.card {
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  padding: 22px;
}
.input-card { padding: 26px; }

.field-label {
  display: block;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-size: 13px;
}
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
  outline: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
input[type="text"]:focus {
  box-shadow: 6px 6px 0 0 var(--accent-blue);
  transform: translate(-1px, -1px);
}
input[type="text"][aria-invalid="true"] {
  box-shadow: 6px 6px 0 0 var(--danger);
}
.field-help {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 20px;
}
.field-help code {
  background: var(--accent-yellow);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.btn {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 14px;
  padding: 14px 22px;
  border: var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-hard-sm);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #fffbe6; }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 0 var(--ink); }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}
.btn-primary { background: var(--accent-yellow); }
.btn-primary:hover { background: #ffd92e; }
.btn-ghost { background: #fff; }
.btn-small { padding: 9px 14px; font-size: 12px; }

.loading-card { text-align: center; margin-top: 24px; }
.spinner {
  width: 44px; height: 44px;
  margin: 6px auto 16px;
  border: 5px solid var(--ink);
  border-top-color: var(--accent-yellow);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-weight: 700; letter-spacing: 2px; margin: 0 0 6px; }
.loading-detail { color: var(--muted); margin: 0; font-size: 14px; }

.error-card { margin-top: 24px; background: #fff0f0; }
.error-title {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  margin: 0 0 10px;
  color: #b30000;
}
.error-detail { margin: 0 0 16px; color: var(--ink); font-weight: 500; }

.result-section { margin-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.result-main {
  background: var(--accent-blue);
  border: var(--border);
}
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.result-eyebrow {
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 12px;
}
.remaining-big {
  font-size: clamp(48px, 10vw, 88px);
  font-weight: 700;
  margin: 6px 0 0;
  line-height: 1;
  letter-spacing: -2px;
}
.result-sub {
  margin: 6px 0 20px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  opacity: 0.85;
}
.progress-wrap { margin-top: 8px; }
.progress-bar {
  height: 22px;
  background: #fff;
  border: var(--border);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow-hard-sm);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--success);
  transition: width 0.6s cubic-bezier(.2,.8,.2,1), background 0.3s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  margin-top: 10px;
  letter-spacing: 1px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
}
.metric-label {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--muted);
}
.metric-value {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.5px;
}
.result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.muted { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 3px solid var(--accent-yellow);
  box-shadow: var(--shadow-hard-sm);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 999;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.site-footer {
  border-top: var(--border);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
}

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
  .remaining-big { font-size: 56px; }
  .hero h1 { font-size: 40px; }
}