.rd { --ink: #312f28; --pane: #b1afa8; --hdr: 57px; }

.rd h1[tabindex="-1"]:focus, .rd h2[tabindex="-1"]:focus { outline: none; }

.rd-stage {
  position: relative; isolation: isolate; display: flex; flex-direction: column;
  min-height: calc(100vh - var(--hdr)); min-height: calc(100svh - var(--hdr));
  padding: clamp(16px, 3.4svh, 44px) 0 clamp(20px, 4.4svh, 56px);
  background:
    url("/assets/dither/ramp-down.png") left bottom / 16px 64px repeat-x,
    linear-gradient(var(--lift), var(--lift)) left top / 100% calc(100% - 64px) no-repeat;
}
.rd-grid {
  flex: 1; display: grid; min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr);
  grid-template-areas: "device ." "device intro" "device card" "device .";
  column-gap: clamp(32px, 3.4vw, 44px);
}

.rd-intro { grid-area: intro; margin-bottom: clamp(12px, 2.2svh, 22px); }
.rd-kicker { display: inline-flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.rd-pill {
  position: relative; display: inline-block; padding: 3px 9px 2px; border-radius: 6px; background: var(--pane); color: var(--ink);
  font-weight: 800; letter-spacing: 0.1em; isolation: isolate;
}
.rd-pill::after {
  content: ""; position: absolute; z-index: -1; inset: 0; transform: translate(2px, 3px); border-radius: 6px;
  background-image: repeating-conic-gradient(var(--pane) 0 25%, transparent 0 50%); background-size: 4px 4px; opacity: 0.6; image-rendering: pixelated;
}
.rd-intro h1 { margin-top: 14px; font-size: clamp(1.8rem, min(3vw, 4.8svh), 3rem); line-height: 1.05; letter-spacing: -0.035em; }
.rd-kicker + h1 { margin-top: 14px; }
.rd-lede { max-width: 440px; margin-top: 10px; color: var(--muted); font-size: clamp(0.95rem, 1.1vw, 1.05rem); line-height: 1.5; }

.pd { --pd-x: 1; --pd-y: 0.5; grid-area: device; position: relative; min-height: 260px; margin: 0; }
.pd-dev { position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: hidden; }
.pd-body { position: absolute; inset: 0; }
.pd-img, .pd-glass {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; max-width: none;
  -webkit-user-select: none; user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.pd-glass { mix-blend-mode: screen; }
.pd-screen {
  position: absolute; left: 0; top: 0; width: 400px; height: 240px; transform-origin: 0 0; line-height: 0;
  background: var(--pane); backface-visibility: hidden;
}
.pd-screen canvas { position: absolute; left: 0; top: 0; width: 400px; height: 240px; image-rendering: crisp-edges; image-rendering: pixelated; }
.pd.is-soft .pd-screen canvas { image-rendering: auto; }
.pd-crank { position: absolute; left: 0; top: 0; background-repeat: no-repeat; background-position: 0 0; pointer-events: none; }
@keyframes pd-blink { 50% { opacity: 0; } 100% { opacity: 0; } }
.pd-code { animation: pd-blink 1s steps(1, end) infinite; }

.rd-card {
  grid-area: card; position: relative; padding: 20px 22px; border-radius: 16px; text-align: left;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 40px 80px -40px rgba(0, 0, 0, 0.9);
}
.rd-step-books { margin-top: 14px; }
.rd-label { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; line-height: 22px; color: var(--text); }
.rd-n {
  flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px;
  background: var(--pane); color: var(--ink); font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.rd-hint {
  height: 2.8em; margin-top: 6px; overflow: hidden; font-size: 12.5px; line-height: 1.4; color: var(--faint);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.rd-hint.is-error { color: var(--error); }

.rd-code-field { position: relative; margin-top: 10px; }
.rd-code-field input {
  display: block; width: 100%; height: 56px; padding: 0 52px 0 20px; border: 0; border-radius: 10px;
  background: var(--pane); color: var(--ink); caret-color: var(--ink);
  font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px var(--line-strong);
  transition: box-shadow 150ms ease;
}
.rd-code-field input::placeholder { color: rgba(49, 47, 40, 0.34); opacity: 1; }
.rd-code-field input:focus { outline: none; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.16), 0 0 0 2px var(--focus); }
.rd-code-field input[aria-invalid="true"] { box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.16), 0 0 0 2px var(--error); }
.rd-code-field input[readonly] { cursor: default; }
.rd-code-ok {
  position: absolute; right: 18px; top: 50%; width: 24px; height: 24px; color: var(--ink); pointer-events: none;
  transform: translate(10px, -50%) scale(0.6); clip-path: inset(0 100% 0 0);
  transition: transform 200ms var(--ease-out), clip-path 200ms var(--ease-out);
}
.rd-code-field.is-valid .rd-code-ok { transform: translate(0, -50%) scale(1); clip-path: inset(0 0 0 0); }

.rd-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rd-meter { display: flex; align-items: center; gap: 14px; font-size: 12px; line-height: 1; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-meter-item { position: relative; display: inline-flex; align-items: baseline; padding-bottom: 6px; }
.rd-meter-v { color: var(--muted); }
.rd-meter-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, 0.07); }
.rd-meter-bar i {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--p, 0));
  background: repeating-conic-gradient(var(--pane) 0 25%, rgba(177, 175, 168, 0.55) 0 50%) 0 0 / 2px 2px;
  transition: transform 220ms var(--ease-out);
}
.rd-meter.is-over .rd-meter-v.is-over { color: var(--error); }
.rd-meter-bar.is-over i { background: var(--error); }

.rd-drop { position: relative; isolation: isolate; display: flex; flex-direction: column; margin-top: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.015); transition: background-color 150ms ease; }
.rd-drop::before {
  content: ""; position: absolute; z-index: -1; inset: 0; padding: 2px; border-radius: 12px; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.2) 0 25%, transparent 0 50%) 0 0 / 4px 4px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.rd-drop::after {
  content: ""; position: absolute; z-index: -1; inset: 2px; border-radius: 10px; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(rgba(177, 175, 168, 0.07) 0 25%, transparent 0 50%) 0 0 / 4px 4px;
  transition: opacity 150ms ease;
}
.rd-drop.is-over { background: rgba(255, 255, 255, 0.035); }
.rd-drop.is-over::before { background: repeating-conic-gradient(var(--pane) 0 25%, transparent 0 50%) 0 0 / 4px 4px; }
.rd-drop.is-over::after { opacity: 1; }

.rd-tray { position: relative; height: 258px; padding: 6px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
.rd-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 20px;
  text-align: center; cursor: pointer;
}
.rd-empty[hidden] { display: none; }
.rd-drop-icon { width: 32px; height: 32px; color: var(--muted); }
.rd-drop-title { margin-top: 10px; font-weight: 600; font-size: 16px; }
.rd-drop-hint { max-width: 300px; margin-top: 4px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
@media (hover: hover) and (pointer: fine) {
  .rd-drop:not(.is-locked) .rd-empty:hover .rd-drop-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
}

.rd-tray-foot { position: relative; display: flex; align-items: center; min-height: 52px; padding: 6px 12px; box-shadow: inset 0 1px 0 var(--line); }
.rd-add { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rd-add[hidden] { display: none; }
.rd-add-or { margin-left: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--faint); font-size: 12.5px; }
.rd-full, .rd-notice { font-size: 12.5px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.rd-full { color: var(--muted); }
.rd-notice { color: var(--error); }
.rd-full[hidden], .rd-notice[hidden] { display: none; }
.rd-btn {
  flex: none; height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--text); cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 120ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .rd-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); } }
.rd-btn:active:not(:disabled) { transform: scale(0.96); }
.rd-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rd-btn:disabled { color: var(--faint); cursor: default; }

.rd-list { list-style: none; margin: 0; padding: 0; }
.rd-list > li {
  position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
  min-height: 46px; padding: 3px 6px 3px 8px; margin-bottom: 4px; border-radius: 9px;
  background: var(--surface-2); box-shadow: 0 0 0 1px var(--line);
}
.rd-list > li:last-child { margin-bottom: 0; }
.rd-cover {
  position: relative; width: 30px; height: 40px; border-radius: 2px; overflow: hidden; line-height: 0;
  background: var(--pane); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.rd-cover canvas { width: 30px; height: 40px; image-rendering: crisp-edges; image-rendering: pixelated; }
.rd-cover canvas[hidden] { display: none; }
.rd-cover span {
  position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; line-height: 1;
  font-family: var(--mono); font-size: 7.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink);
}
.rd-cover::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 6px; height: 12px;
  background: repeating-linear-gradient(var(--ink) 0 1px, transparent 1px 4px); opacity: 0.5;
}
.rd-cover.has-thumb::before, .rd-cover.has-thumb span { display: none; }
.rd-text { min-width: 0; }
.rd-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; line-height: 19px; }
.rd-state { display: flex; align-items: center; gap: 8px; min-width: 0; height: 18px; font-size: 12.5px; line-height: 18px; color: var(--muted); }
.rd-state-t { flex: none; display: inline-flex; align-items: center; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.rd-state-t svg { width: 14px; height: 14px; flex: none; }
.rd-state-t > span { overflow: hidden; text-overflow: ellipsis; }
.rd-meta { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--faint); }
.rd-meta::before { content: "\00b7\00a0"; }
.rd-meta:empty::before { content: none; }
.rd-bar { position: relative; flex: 1; height: 4px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.rd-bar[hidden], .rd-meta[hidden] { display: none; }
.rd-bar i { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--p, 0)); background: var(--text); transition: transform 160ms linear; }
.rd-list > li[data-state="converting"] .rd-bar i, .rd-list > li[data-state="queued"] .rd-bar i {
  background: repeating-conic-gradient(var(--pane) 0 25%, rgba(177, 175, 168, 0.35) 0 50%) 0 0 / 4px 4px;
}
.rd-list > li[data-state="ready"] .rd-state, .rd-list > li[data-state="delivered"] .rd-state { color: var(--text); }
.rd-list > li[data-state="error"] .rd-state, .rd-list > li[data-state="failed"] .rd-state { height: auto; align-items: flex-start; color: var(--error); }
.rd-list > li[data-state="error"] .rd-state-t, .rd-list > li[data-state="failed"] .rd-state-t { flex: 1; white-space: normal; line-height: 1.35; padding: 1px 0 3px; }
.rd-list > li[data-state="error"] .rd-cover, .rd-list > li[data-state="failed"] .rd-cover { filter: grayscale(1) brightness(0.55); }
.rd-list > li[data-state="waiting"] .rd-state-t::after { content: "..."; display: inline-block; overflow: hidden; width: 0; margin-left: -4px; vertical-align: bottom; animation: rd-dots 1.6s steps(4, end) infinite; }
@keyframes rd-dots { to { width: 1.1em; } }
.rd-x {
  grid-column: 3; align-self: center; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: var(--faint); cursor: pointer; transition: background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}
.rd-x svg { width: 13px; height: 13px; }
@media (hover: hover) and (pointer: fine) { .rd-x:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); } }
.rd-x:active { transform: scale(0.92); }
.rd-x:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.rd-x[hidden] { display: none; }

.rd-foot { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.rd-status { flex: 1; min-width: 0; display: flex; align-items: center; height: 4.2em; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.rd-status > span { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.rd-status.is-error { color: var(--error); }
.rd-status.is-ok { color: var(--text); }
.rd-send-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 156px; height: 46px; padding: 0 20px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--text); color: var(--bg); font: inherit; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap;
  transition: transform 120ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}
@media (hover: hover) and (pointer: fine) { .rd-send-btn:hover:not(:disabled) { background: #ffffff; } }
.rd-send-btn:active:not(:disabled) { transform: scale(0.97); }
.rd-send-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.rd-send-btn:disabled { background: rgba(255, 255, 255, 0.1); color: var(--faint); cursor: default; }

.rd-fly { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.rd-fly-card {
  position: absolute; left: 0; top: 0; width: 30px; height: 40px; border-radius: 2px; overflow: hidden; line-height: 0;
  background: var(--pane); transform-origin: 50% 50%; will-change: transform;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 12px 22px -8px rgba(0, 0, 0, 0.7);
}
.rd-fly-card canvas { width: 30px; height: 40px; image-rendering: crisp-edges; image-rendering: pixelated; }
.rd-fly-card span {
  position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; line-height: 1;
  font-family: var(--mono); font-size: 7.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink);
}
.rd-fly-card.no-thumb::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 6px; height: 12px;
  background: repeating-linear-gradient(var(--ink) 0 1px, transparent 1px 4px); opacity: 0.5;
}

.rd-faq { padding: 96px 0 128px; }
.rd-faq h2 { max-width: 720px; margin: 0 auto; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.15; }
.rd-faq-list { max-width: 720px; margin: 28px auto 0; }
.rd-faq details { border-radius: 12px; transition: background-color 150ms ease; }
.rd-faq details + details { margin-top: 6px; }
.rd-faq details[open] { background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.rd-faq summary {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 14px 20px;
  list-style: none; cursor: pointer; border-radius: 12px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow 150ms ease, color 150ms ease;
}
.rd-faq details[open] summary { box-shadow: none; }
.rd-faq summary::-webkit-details-marker { display: none; }
.rd-faq summary::after {
  content: ""; flex: none; width: 9px; height: 9px; margin: -4px 4px 0 0; border-right: 1.75px solid var(--muted); border-bottom: 1.75px solid var(--muted);
  transform: rotate(45deg); transition: transform 200ms var(--ease-out);
}
.rd-faq details[open] summary::after { transform: translateY(4px) rotate(-135deg); }
@media (hover: hover) and (pointer: fine) { .rd-faq details:not([open]) summary:hover { box-shadow: inset 0 0 0 1px var(--line-strong); } }
.rd-faq summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rd-faq-a { padding: 0 20px 20px; color: var(--muted); max-width: 64ch; }

@media (min-width: 900px) and (max-height: 979px) {
  .rd-kicker { display: none; }
  .rd-intro h1 { margin-top: 0; }
}
@media (min-width: 900px) and (max-height: 820px) {
  .rd-lede { display: none; }
  .rd-card { padding: 16px 20px; }
  .rd-tray { height: 200px; }
}

@media (max-width: 899px) {
  .rd-stage { padding: 14px 0 18px; }
  .rd-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "intro" "device" "card";
  }
  .rd-intro { text-align: center; margin-bottom: 0; }
  .rd-intro h1 { font-size: clamp(1.45rem, 6vw, 2.2rem); }
  .rd-lede { margin-left: auto; margin-right: auto; }
  .pd { --pd-x: 0.5; height: clamp(150px, 25svh, 300px); min-height: 0; margin: 8px 0 0; }
  .rd-card { align-self: stretch; display: flex; flex-direction: column; margin-top: 12px; padding: 14px 14px 14px; border-radius: 14px; }
  .rd-step-books { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin-top: 10px; }
  .rd-drop { flex: 1 1 auto; min-height: 0; }
  .rd-tray { flex: 1 1 0; height: auto; min-height: 132px; }
  .rd-hint { height: 4.2em; -webkit-line-clamp: 3; }
  .rd-foot { flex-direction: column; align-items: stretch; gap: 6px; margin-top: 10px; }
  .rd-send-btn { width: 100%; }
  .rd-status { flex: none; justify-content: center; height: 2.8em; text-align: center; }
  .rd-status > span { -webkit-line-clamp: 2; }
  .rd-faq { padding: 80px 0 96px; }
}
@media (max-width: 899px) and (max-height: 760px) {
  .rd-stage { padding: 10px 0 12px; }
  .rd-intro h1 { font-size: clamp(1.3rem, 5.4vw, 1.8rem); }
  .pd { height: clamp(96px, 16svh, 200px); margin-top: 6px; }
  .rd-card { margin-top: 8px; padding: 12px 12px 12px; }
  .rd-hint { height: 2.8em; -webkit-line-clamp: 2; }
  .rd-step-books { margin-top: 6px; }
  .rd-tray { min-height: 100px; }
  .rd-foot { margin-top: 8px; gap: 4px; }
}
@media (max-width: 600px) {
  .rd-kicker, .rd-lede { display: none; }
  .rd-intro h1 { margin-top: 0; }
  .rd-code-field input { height: 50px; font-size: 26px; padding-left: 16px; }
  .rd-hint { margin-top: 4px; font-size: 12px; }
  .rd-label { font-size: 14px; }
  .rd-meter { gap: 10px; font-size: 11.5px; }
  .rd-meter-k { display: none; }
  .rd-list > li { min-height: 44px; padding: 2px 4px 2px 6px; column-gap: 10px; }
  .rd-tray-foot { min-height: 46px; padding: 6px 8px; }
  .rd-add-or { display: none; }
  .rd-faq summary { padding: 12px 16px; font-size: 15px; }
  .rd-faq-a { padding: 0 16px 16px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .pd-code { animation: none; opacity: 1; }
  .rd-list > li[data-state="waiting"] .rd-state-t::after { animation: none; width: auto; }
  .rd-code-ok, .rd-meter-bar i, .rd-bar i { transition: none; }
}
