:root {
  --bg: #f5f1ea;
  --fg: #1c1d21;
  --muted: #6b6a66;
  --card: #ffffff;
  --accent: #1f5f8b;
  --accent-press: #174a6d;
  --ok: #2e8b57;
  --err: #c0392b;
  --ring: rgba(31, 95, 139, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #f1efe9;
    --muted: #9a9890;
    --card: #1e2127;
    --accent: #3b8fc9;
    --accent-press: #2f77a9;
    --ok: #3fb070;
    --err: #e5604f;
    --ring: rgba(59, 143, 201, 0.22);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 20px)
    calc(env(safe-area-inset-right) + 20px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 20px);
  max-width: 480px;
  margin: 0 auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }

.lang {
  display: flex;
  background: var(--card);
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.lang button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.steps {
  list-style: none;
  margin-top: 24px;
  display: grid;
  gap: 12px;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.05rem;
  line-height: 1.35;
}
.num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.center {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.open {
  width: min(68vw, 300px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 0 0 14px var(--ring), 0 12px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.open:active:not(:disabled) { transform: scale(0.96); background: var(--accent-press); }
.open:disabled { cursor: default; }

.icon { width: 64px; height: 64px; fill: currentColor; }
.icon-check, .spinner { display: none; }

.spinner {
  width: 56px;
  height: 56px;
  border: 5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.open.is-loading .icon-key { display: none; }
.open.is-loading .spinner { display: block; }

.open.is-ok { background: var(--ok); box-shadow: 0 0 0 14px color-mix(in srgb, var(--ok) 22%, transparent), 0 12px 30px rgba(0, 0, 0, 0.2); }
.open.is-ok .icon-key { display: none; }
.open.is-ok .icon-check { display: block; }

.open.is-wait { opacity: 0.55; }

.open.is-err { background: var(--err); box-shadow: 0 0 0 14px color-mix(in srgb, var(--err) 22%, transparent), 0 12px 30px rgba(0, 0, 0, 0.2); }

.status {
  min-height: 3em;
  text-align: center;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--muted);
}
.status.ok { color: var(--ok); font-weight: 600; }
.status.err { color: var(--err); font-weight: 600; }
