:root {
  --green: #2f6f4f;
  --green-dark: #245a40;
  --green-tint: #eaf3ee;
  --ink: #16241d;
  --muted: #5f6f66;
  --bg: #f7faf8;
  --card: #ffffff;
  --line: #dfe8e2;
  --danger: #b3261e;
  --radius: 14px;
  --pad: max(20px, env(safe-area-inset-left));
}

@media (prefers-color-scheme: dark) {
  :root {
    --green: #5cbd8f;
    --green-dark: #4aa87d;
    --green-tint: #16241d;
    --ink: #e8f0ea;
    --muted: #9db0a5;
    --bg: #0f1713;
    --card: #16211b;
    --line: #263229;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    var(--pad)
    max(24px, env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

section { display: flex; flex-direction: column; flex: 1; }

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

h1 {
  font-size: 1.35rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 4px 0 20px;
}

/* States (loading / result / error) fill the space and center */
.state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.pass-date {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.pass-image {
  width: 100%;
  max-width: 420px;
  height: auto;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

/* Spinner */
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

.error-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  display: grid;
  place-items: center;
}
#error-message { max-width: 34ch; color: var(--ink); }

/* Form */
form { display: flex; flex-direction: column; gap: 16px; }

label { display: flex; flex-direction: column; gap: 6px; }
label > span { font-size: 0.9rem; font-weight: 550; color: var(--ink); }
label em { color: var(--green); font-style: normal; }

input, select {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent);
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  margin-top: 4px;
}
.btn-ghost { background: transparent; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px;
  margin: -8px;
  cursor: pointer;
  border-radius: 10px;
  display: inline-flex;
}
.icon-btn:active { color: var(--green); }

[hidden] { display: none !important; }
