*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --brand: #5a4fcf;
  --brand-dark: #463bb0;
  --protecto: #1e6b3a;
  --protecto-dark: #164f2b;
  --danger: #b3261e;
  --ok: #1e6b3a;
  --warn: #8a5a00;
  --text: #1f2330;
  --muted: #555b6e;
  --line: #e2e4ec;
  --surface: #ffffff;
  --surface-alt: #f6f7fb;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.55;
  color: var(--text);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

h1, h2, h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(90, 79, 207, 0.08);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: #fff;
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  left: 0.5rem;
}

/* Navigation */
.navbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.navbar p {
  margin: 0;
}

.brand {
  color: var(--brand);
  font-size: 1.4rem;
  font-weight: 700;
}

.demo-tag {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Hero */
.hero {
  display: flex;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 0 1rem;
}

.hero-content {
  max-width: 640px;
  color: #fff;
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.lead {
  font-size: 1.15rem;
  margin: 0 0 1.5rem;
}

.auth-section {
  margin: 2rem 0;
}

.protecto-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--protecto);
  color: #fff;
  border: 0;
  padding: 0.95rem 2rem;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease, transform 0.2s ease;
}

.protecto-btn:hover {
  background: var(--protecto-dark);
  transform: translateY(-1px);
}

.protecto-btn:disabled {
  cursor: progress;
  opacity: 0.75;
  transform: none;
}

.auth-note {
  margin: 1rem 0 0;
  font-size: 0.95rem;
}

.auth-status {
  min-height: 1.5em;
  margin: 0.5rem 0 0;
  font-weight: 600;
}

.link-btn {
  display: inline;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.features-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
}

.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem;
  min-width: 150px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 10px;
}

.feature .icon {
  font-size: 2rem;
}

/* Panels and cards */
.panel,
.dashboard {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.15);
  padding: 1.25rem 1.5rem;
  margin: 0 0 1.25rem;
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--line);
}

.dashboard-header h1 {
  font-size: 1.75rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.status-line {
  min-height: 1.5em;
  margin: 0.75rem 0;
  color: var(--muted);
}

.status-line.is-error {
  color: var(--danger);
  font-weight: 600;
}

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

.card {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-width: 0;
}

.card-wide {
  grid-column: 1 / -1;
}

.card h2 {
  color: var(--brand-dark);
  font-size: 1.2rem;
}

.card h3 {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 1rem;
}

.card-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.kv {
  margin: 0;
}

.kv > div {
  display: grid;
  grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.kv > div:last-child {
  border-bottom: 0;
}

.kv dt {
  font-weight: 600;
  color: var(--muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.mono {
  font-family: var(--mono);
  font-size: 0.88rem;
}

.hint {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--muted);
  font-size: 0.85rem;
}

.chip {
  display: inline-block;
  background: rgba(90, 79, 207, 0.12);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 0.05rem 0.6rem;
  margin: 0 0.3rem 0.3rem 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.code {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: #1f2330;
  color: #e8eaf3;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  max-width: 100%;
}

.jwt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 1rem;
}

/* Verification badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  margin-bottom: 0.5rem;
}

.badge-ok {
  background: #e3f4e8;
  color: var(--ok);
  border: 1px solid #9fd3ae;
}

.badge-fail {
  background: #fbe7e6;
  color: var(--danger);
  border: 1px solid #efaaa5;
}

.checks {
  list-style: none;
  margin: 0.25rem 0 0.75rem;
  padding: 0;
}

.checks li {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  gap: 0.25rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--line);
}

.checks li:last-child {
  border-bottom: 0;
}

.check-mark {
  font-weight: 700;
}

.check-pass .check-mark {
  color: var(--ok);
}

.check-fail .check-mark {
  color: var(--danger);
}

.check-skip {
  color: var(--muted);
}

.check-detail {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

/* Notices */
.notice {
  border-left: 6px solid var(--brand);
}

.notice-error {
  border-left-color: var(--danger);
}

.notice-error .notice-title {
  color: var(--danger);
}

.notice-info .notice-title {
  color: var(--brand-dark);
}

.notice-success {
  border-left-color: var(--ok);
}

.notice-success .notice-title {
  color: var(--ok);
}

.notice-warning {
  border-left-color: var(--warn);
}

.notice-warning .notice-title {
  color: var(--warn);
}

.notice p {
  overflow-wrap: anywhere;
}

.tech {
  margin: 0.75rem 0;
}

.tech summary,
.explainer summary {
  cursor: pointer;
  font-weight: 600;
}

/* Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dashboard-header .actions {
  margin-top: 0;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.2s ease;
}

.btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

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

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: #fff;
  color: var(--brand-dark);
  border-color: var(--brand);
}

.btn-secondary:hover {
  background: #f0eeff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #8f1e18;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

/* Demo content */
.demo-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: 0;
}

.demo-content h2 {
  color: #fff;
}

.tasks {
  margin: 0;
  padding-left: 1.25rem;
}

/* Explainer */
.explainer .summary-note {
  font-weight: 400;
  color: var(--muted);
}

.steps {
  padding-left: 1.25rem;
  margin: 1rem 0;
}

.steps li {
  margin-bottom: 0.5rem;
}

.log-title {
  font-size: 1rem;
  margin-top: 1rem;
}

.log {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
}

.log li {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.log time {
  font-family: var(--mono);
  color: var(--muted);
}

.log-text {
  overflow-wrap: anywhere;
}

.log-error .log-text {
  color: var(--danger);
}

/* Callback */
.callback-main {
  display: flex;
  align-items: center;
  justify-content: center;
}

.processing {
  text-align: center;
  max-width: 480px;
  width: 100%;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e6e6f0;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0.5rem auto 1rem;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  .protecto-btn,
  .btn {
    transition: none;
  }
}

/* Footer */
.footer {
  color: #fff;
  text-align: center;
  padding: 1.25rem 1rem;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.12);
}

.footer p {
  margin: 0;
}

/* Responsive */
@media (max-width: 760px) {
  .grid,
  .jwt {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel,
  .dashboard {
    padding: 1rem;
  }

  .card {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 1rem 0.6rem 1.5rem;
  }

  .navbar {
    padding: 0.75rem 1rem;
  }

  .protecto-btn {
    width: 100%;
    justify-content: center;
    padding: 0.9rem 1rem;
  }

  .kv > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.1rem;
  }

  .log li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .dashboard-header .actions,
  .dashboard-header .actions .btn {
    width: 100%;
  }
}
