:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-page: #f9fafb;
  --surface-subtle: #f3f4f6;
  --content: #111827;
  --content-secondary: #374151;
  --content-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #111827;
  --accent-hover: #1f2937;
  --accent-content: #ffffff;
  --danger: #b42318;
  --danger-hover: #912018;
  --danger-surface: #fff6f5;
  --success: #16803c;
  --success-surface: #ecfdf3;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--content);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.portal-card {
  width: min(100%, 460px);
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 18px 55px rgb(17 24 39 / 8%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 34px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-name {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.heading-block {
  margin-bottom: 30px;
}

.compact-heading {
  margin-bottom: 22px;
}

h1 {
  margin: 0 0 10px;
  font-size: 29px;
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 650;
}

p {
  margin: 0;
  color: var(--content-muted);
  font-size: 15px;
  line-height: 1.55;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--content-secondary);
  font-size: 13px;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 50px;
  padding: 13px 15px;
  color: var(--content);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  outline: none;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  text-align: center;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(17 24 39 / 10%);
}

.field-help {
  margin: 8px 2px 22px;
  font-size: 12px;
}

.primary-button,
.danger-button,
.secondary-button {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.primary-button {
  color: var(--accent-content);
  background: var(--accent);
  border: 1px solid var(--accent);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.danger-button {
  color: #ffffff;
  background: #b42318;
  border: 1px solid #b42318;
}

.danger-button:hover:not(:disabled) {
  background: #912018;
  border-color: #912018;
}

.secondary-button {
  color: var(--content-secondary);
  background: transparent;
  border: 1px solid var(--border-strong);
}

.secondary-button:hover:not(:disabled) {
  background: var(--surface-subtle);
}

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

.back-button {
  display: inline-flex;
  gap: 6px;
  margin: -5px 0 24px;
  padding: 0;
  color: var(--content-muted);
  background: transparent;
  border: 0;
  font-size: 13px;
}

.back-button:hover {
  color: var(--content);
}

.device-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.device-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  color: var(--content);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
}

.device-option[aria-checked="true"] {
  border-color: var(--content);
  box-shadow: 0 0 0 1px var(--content);
}

.device-symbol {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--surface-subtle);
  border-radius: 10px;
  font-size: 18px;
}

.device-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.device-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-date {
  color: var(--content-muted);
  font-size: 12px;
}

.radio-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

.device-option[aria-checked="true"] .radio-mark {
  border: 5px solid var(--content);
}

.warning-box {
  display: grid;
  gap: 4px;
  margin: 18px 0;
  padding: 13px 14px;
  color: var(--content-secondary);
  background: var(--danger-surface);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
}

.warning-box strong {
  color: var(--danger);
}

.turnstile-container:not(:empty) {
  min-height: 65px;
  display: grid;
  place-items: center;
  margin: 14px 0;
}

.message {
  margin: 14px 0;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.error-message {
  color: var(--danger);
  background: var(--danger-surface);
}

.result-view {
  text-align: center;
}

.result-view p {
  margin-bottom: 24px;
}

.result-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
  border-radius: 18px;
  font-size: 27px;
  font-weight: 650;
}

.success-icon {
  color: var(--success);
  background: var(--success-surface);
}

.neutral-icon {
  color: var(--content);
  background: var(--surface-subtle);
}

.success-note {
  margin: 0 0 22px;
  padding: 11px;
  color: var(--success);
  background: var(--success-surface);
  border-radius: 10px;
  font-size: 13px;
}

.spinner {
  width: 15px;
  height: 15px;
  display: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 650ms linear infinite;
}

.is-loading .spinner {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

footer {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 30px;
  color: var(--content-muted);
  font-size: 12px;
}

footer a {
  color: var(--content-secondary);
  font-weight: 600;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

@media (max-width: 540px) {
  .page-shell {
    display: block;
    padding: 0;
  }

  .portal-card {
    min-height: 100vh;
    padding: 28px 22px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  h1 {
    font-size: 27px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
