:root {
  color-scheme: light dark;
  --bg: #f7f3ec;
  --bg-soft: #eef3ea;
  --ink: #181714;
  --muted: rgba(24, 23, 20, 0.62);
  --card: rgba(255, 251, 244, 0.86);
  --line: rgba(255, 255, 255, 0.66);
  --accent: #405261;
  --sage: #788f73;
  --warm: #b48f6b;
  --danger: #8f4d4d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1115;
    --bg-soft: #161c20;
    --ink: #f8f5ee;
    --muted: rgba(248, 245, 238, 0.68);
    --card: rgba(27, 31, 35, 0.72);
    --line: rgba(255, 255, 255, 0.10);
    --accent: #aebfcc;
    --sage: #93aa8d;
    --warm: #c4a17b;
    --danger: #d18484;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 2%, rgba(120, 143, 115, 0.25), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 34px 20px 48px;
}

.repere-card,
.empty-state,
.code-card,
.revoked-card {
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--card);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px);
}

.repere-card {
  overflow: hidden;
}

.hero {
  min-height: 230px;
  padding: 22px;
  display: flex;
  align-items: flex-end;
  background:
    radial-gradient(circle at 28% 42%, rgba(255, 255, 255, 0.42), transparent 7rem),
    radial-gradient(circle at 66% 35%, rgba(180, 143, 107, 0.22), transparent 9rem),
    linear-gradient(135deg, rgba(64, 82, 97, 0.82), rgba(120, 143, 115, 0.58));
}

.hero.has-image {
  padding: 0;
  min-height: auto;
}

.hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.category-pill,
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  font-size: 0.86rem;
  font-weight: 700;
}

.content {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.35rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.description {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.38;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.repere-actions {
  display: flex;
  margin-top: 24px;
}

.steps {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.36);
  border: 1px solid var(--line);
}

@media (prefers-color-scheme: dark) {
  .step {
    background: rgba(255, 255, 255, 0.05);
  }
}

.step-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.92rem;
  font-weight: 800;
}

.step p {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.34;
  font-weight: 650;
}

.step-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 12px;
}

.step .note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 500;
}

.footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.empty-state,
.code-card,
.revoked-card {
  padding: 28px;
}

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  margin-bottom: 22px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--sage));
  font-weight: 850;
  font-size: 1.6rem;
}

.code-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.code-input {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.44);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}

.primary-button {
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  color: white;
  background: linear-gradient(135deg, #405261, #5f7380);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button,
.plain-button {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.36);
  font-weight: 800;
  cursor: pointer;
}

.plain-button {
  min-height: 42px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), white 28%);
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.collection {
  display: grid;
  gap: 18px;
}

.reader-panel {
  padding: 24px;
  min-height: 520px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 22px;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.42), transparent 8rem),
    linear-gradient(145deg, rgba(255, 251, 244, 0.74), rgba(238, 243, 234, 0.72));
}

@media (prefers-color-scheme: dark) {
  .reader-panel {
    background:
      radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.08), transparent 8rem),
      linear-gradient(145deg, rgba(24, 30, 35, 0.9), rgba(14, 18, 22, 0.92));
  }

  .secondary-button {
    background: rgba(255, 255, 255, 0.08);
  }
}

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

.reader-count,
.reader-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 850;
}

.reader-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(64, 82, 97, 0.14);
}

.reader-progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--accent));
  transition: width 220ms ease;
}

.reader-stage {
  display: grid;
  align-items: center;
}

.reader-step,
.reader-finish {
  display: none;
}

.reader-step.is-active,
.reader-finish:not([hidden]) {
  display: block;
}

.reader-step h2,
.reader-finish h2 {
  margin: 14px 0 0;
  font-size: clamp(2.35rem, 9vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.reader-image {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 24px;
  margin-top: 16px;
}

.reader-note,
.reader-finish p:not(.eyebrow) {
  max-width: 34rem;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1.12rem, 3vw, 1.4rem);
  line-height: 1.36;
  font-weight: 600;
}

.reader-controls {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  gap: 12px;
}

.reader-controls .primary-button,
.reader-controls .secondary-button,
.repere-actions .primary-button {
  width: 100%;
}

@media (max-width: 560px) {
  .shell {
    padding: 18px 12px 34px;
  }

  .repere-card,
  .empty-state,
  .code-card,
  .revoked-card {
    border-radius: 26px;
  }

  .content,
  .reader-panel {
    padding: 20px;
  }

  .reader-panel {
    min-height: 500px;
  }

  .reader-top {
    align-items: flex-start;
    flex-direction: column-reverse;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-progress div {
    transition: none;
  }
}
