/* ==========================================================================
   Cairn Vault — warm editorial design system
   Trae-style workspace structure · Apple restraint · Claude palette
   ========================================================================== */

:root {
  --paper: #f6f2e9;
  --paper-2: #efe8da;
  --paper-3: #e7ddcb;
  --card: #fbf8f1;
  --white: #fffdf8;

  --ink: #1a1713;
  --ink-2: #4d473d;
  --ink-3: #837b6c;
  --ink-4: #a9a091;

  --line: rgba(26, 23, 19, 0.12);
  --line-strong: rgba(26, 23, 19, 0.24);

  --accent: #c25e3a;
  --accent-deep: #9c4526;
  --accent-soft: rgba(194, 94, 58, 0.12);
  --olive: #5d6b4a;
  --olive-soft: rgba(93, 107, 74, 0.13);
  --amber: #9a6b2f;
  --amber-soft: rgba(154, 107, 47, 0.14);

  --glass: rgba(246, 242, 233, 0.72);
  --rail: #1c1915;

  --shadow-s: 0 1px 2px rgba(26, 23, 19, 0.05), 0 10px 24px -18px rgba(26, 23, 19, 0.35);
  --shadow-m: 0 2px 4px rgba(26, 23, 19, 0.05), 0 28px 60px -32px rgba(26, 23, 19, 0.45);

  --serif: "Fraunces", "Songti SC", "Noto Serif SC", Georgia, serif;
  --sans: "Manrope", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", "Menlo", "Consolas", monospace;

  --r-s: 10px;
  --r-m: 16px;
  --r-l: 22px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-pop: cubic-bezier(0.34, 1.4, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 620px at 78% -12%, rgba(194, 94, 58, 0.09), transparent 62%),
    radial-gradient(900px 520px at -8% 18%, rgba(93, 107, 74, 0.07), transparent 60%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

::selection {
  background: var(--accent);
  color: var(--white);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- grain */

.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.11'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- utils */

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.muted {
  color: var(--ink-3);
}

.kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------------------------------------------------------------- brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 4px;
}

.brand-name {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform 0.3s var(--ease), background 0.25s, color 0.25s, border-color 0.25s,
    box-shadow 0.3s var(--ease);
}

.btn:active {
  transform: translateY(1px) scale(0.995);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-dark {
  background: var(--ink);
  color: var(--paper);
}

.btn-dark:hover:not(:disabled) {
  background: #0e0c09;
  box-shadow: 0 12px 26px -14px rgba(26, 23, 19, 0.7);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: var(--white);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-deep);
  box-shadow: 0 12px 26px -14px rgba(194, 94, 58, 0.8);
  transform: translateY(-1px);
}

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

.btn-ghost:hover:not(:disabled) {
  background: rgba(26, 23, 19, 0.05);
  border-color: var(--ink-3);
}

.btn-block {
  width: 100%;
}

.btn .arrow {
  transition: transform 0.35s var(--ease);
}

.btn:hover .arrow {
  transform: translateX(3px);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: transparent;
  transition: background 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  background: rgba(26, 23, 19, 0.05);
  border-color: var(--line-strong);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.pill-btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 70px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 26px;
}

.topnav-link {
  position: relative;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 6px 0;
  transition: color 0.2s;
}

.topnav-link:hover {
  color: var(--ink);
}

.topnav-link.is-active {
  color: var(--ink);
}

.topnav-link.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1.5px;
  background: var(--accent);
}

.topnav-divider {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
}

/* ---------------------------------------------------------------- hero */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(280px, 0.68fr);
  gap: 72px;
  padding: 104px 0 92px;
  align-items: start;
}

.hero-copy > * {
  animation: rise 0.78s var(--ease-out) both;
}

.hero-copy > *:nth-child(1) {
  animation-delay: 40ms;
}

.hero-copy > *:nth-child(2) {
  animation-delay: 110ms;
}

.hero-copy > *:nth-child(3) {
  animation-delay: 180ms;
}

.hero-copy > *:nth-child(4) {
  animation-delay: 250ms;
}

.hero-title {
  margin: 22px 0 26px;
  font-family: var(--serif);
  font-size: clamp(48px, 6.4vw, 82px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 144;
}

.hero-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

.hero-lede {
  max-width: 46ch;
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--ink-2);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.ledger {
  border-left: 1px solid var(--line-strong);
  padding-left: 34px;
  animation: rise 0.82s 140ms var(--ease-out) both;
}

.ledger-head {
  color: var(--ink-3);
  padding-bottom: 14px;
}

.ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
  border-top: 1px dashed var(--line-strong);
}

.ledger-label {
  font-size: 12.5px;
  color: var(--ink-2);
}

.ledger-value {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.ledger-note {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- library */

.library {
  padding-bottom: 96px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.section-title h2 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.section-kicker {
  color: var(--ink-3);
}

.library-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 15px;
  min-width: 258px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.55);
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

.search:focus-within {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search svg {
  color: var(--ink-3);
  flex: none;
}

.search input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--ink);
}

.search input::placeholder {
  color: var(--ink-4);
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.45);
}

.segmented button {
  height: 32px;
  padding: 0 15px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  transition: background 0.25s, color 0.25s;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--ink);
  color: var(--paper);
}

/* ---------------------------------------------------------------- cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(305px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 236px;
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: linear-gradient(168deg, #fdfaf4 0%, var(--card) 62%, #f8f3e8 100%);
  box-shadow: var(--shadow-s);
  cursor: pointer;
  overflow: hidden;
  animation: card-in 0.62s var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 8) * 42ms + 70ms);
  transition: transform 0.42s var(--ease-out), box-shadow 0.42s var(--ease-out),
    border-color 0.32s var(--ease-soft);
}

.card--soft {
  animation: card-swap 0.34s var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 10) * 12ms);
}

.card:active {
  transform: translateY(-1px) scale(0.996);
  transition-duration: 0.14s;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px 160px at 88% -10%, rgba(194, 94, 58, 0.08), transparent 70%);
  opacity: 0;
  transition: opacity 0.42s var(--ease-soft);
  pointer-events: none;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(26, 23, 19, 0.22);
  box-shadow: var(--shadow-m);
}

.card:hover::after {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-index {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--ink-4);
}

.file-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(26, 23, 19, 0.06);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}

.card-title {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 400;
  line-height: 1.22;
  letter-spacing: -0.015em;
  margin-bottom: 9px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: 13px;
  line-height: 1.66;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 43px;
}

.card-meta {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  flex-wrap: wrap;
}

.card-meta .sep {
  color: var(--ink-4);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.chip::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.chip-code {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: rgba(194, 94, 58, 0.22);
}

.chip-terms {
  color: var(--olive);
  background: var(--olive-soft);
  border-color: rgba(93, 107, 74, 0.24);
}

.chip-open {
  color: var(--ink-2);
  background: rgba(26, 23, 19, 0.05);
  border-color: var(--line);
}

.card-arrow {
  width: 30px;
  height: 30px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  font-size: 14px;
  transition: transform 0.42s var(--ease-out), background 0.32s var(--ease-soft),
    color 0.32s var(--ease-soft), border-color 0.32s var(--ease-soft);
}

.card:hover .card-arrow {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  transform: rotate(-45deg);
}

/* ---------------------------------------------------------------- empty */

.empty {
  padding: 74px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-l);
  text-align: center;
  color: var(--ink-3);
  background: rgba(255, 253, 248, 0.35);
  animation: soft-in 0.45s var(--ease-out) both;
}

.empty.is-loading p {
  animation: soft-pulse 1.6s var(--ease-in-out) infinite;
}

.empty.is-loading::after {
  content: "";
  display: block;
  width: 168px;
  height: 2px;
  margin: 20px auto 0;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 220% 100%;
  opacity: 0.7;
  animation: sweep 1.5s var(--ease-in-out) infinite;
}

.empty h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.empty p {
  font-size: 13px;
}

/* ---------------------------------------------------------------- footer */

.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 32px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
}

.foot .mono {
  font-size: 9.5px;
  letter-spacing: 0.16em;
}

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 23, 19, 0.46);
  backdrop-filter: blur(9px) saturate(120%);
  -webkit-backdrop-filter: blur(9px) saturate(120%);
  animation: fade 0.34s var(--ease-soft) both;
}

.modal-panel {
  position: relative;
  width: min(740px, 100%);
  max-height: min(88vh, 860px);
  overflow: auto;
  border: 1px solid rgba(255, 253, 248, 0.5);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(26, 23, 19, 0.06);
  padding: 30px 34px 34px;
  animation: panel-in 0.46s var(--ease-out) both;
  overscroll-behavior: contain;
}

.modal.is-closing .modal-backdrop {
  animation: fade-out 0.22s var(--ease-in-out) both;
}

.modal.is-closing .modal-panel {
  animation: panel-out 0.22s var(--ease-in-out) both;
}

.modal-panel--wide {
  width: min(820px, 100%);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  border: 1px solid var(--line);
  transition: background 0.24s var(--ease-soft), transform 0.4s var(--ease-out),
    border-color 0.24s var(--ease-soft);
  z-index: 2;
}

.modal-close:hover {
  background: rgba(26, 23, 19, 0.06);
  transform: rotate(90deg);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-right: 44px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.modal-head .file-chip {
  margin-top: 6px;
  flex: none;
}

.modal-head h3 {
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 7px;
}

.modal-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: none;
}

/* stepper */

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 22px 0 4px;
  padding: 0;
}

.stepper li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
  white-space: nowrap;
}

.stepper li:not(:last-child)::after {
  content: "";
  width: 42px;
  height: 1px;
  margin: 0 14px;
  background: var(--line-strong);
  transition: background 0.5s var(--ease-out);
}

.stepper li.is-done:not(:last-child)::after {
  background: var(--olive);
}

.stepper .step-num {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: background 0.34s var(--ease-out), color 0.34s var(--ease-out),
    border-color 0.34s var(--ease-out), transform 0.34s var(--ease-out);
}

.stepper li.is-active {
  color: var(--ink);
}

.stepper li.is-active .step-num {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.stepper li.is-done {
  color: var(--olive);
}

.stepper li.is-done .step-num {
  background: var(--olive-soft);
  border-color: rgba(93, 107, 74, 0.4);
  color: var(--olive);
}

/* step panes */

.step-pane {
  padding-top: 26px;
  animation: pane-in 0.42s var(--ease-out) both;
}

.step-pane.is-loading .step-note {
  animation: soft-pulse 1.5s var(--ease-in-out) infinite;
}

.step-pane h4 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.step-note {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-3);
  margin-bottom: 16px;
}

.terms-box {
  max-height: 222px;
  overflow: auto;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--white);
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.terms-box::-webkit-scrollbar,
.modal-panel::-webkit-scrollbar {
  width: 8px;
}

.terms-box::-webkit-scrollbar-thumb,
.modal-panel::-webkit-scrollbar-thumb {
  background: rgba(26, 23, 19, 0.18);
  border-radius: 99px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 18px 0 22px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check .box {
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: var(--white);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.check .box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg) scale(0.4);
  opacity: 0;
  transition: transform 0.26s var(--ease-pop), opacity 0.2s var(--ease-soft);
}

.check input:checked + .box {
  background: var(--accent);
  border-color: var(--accent);
}

.check input:checked + .box::after {
  opacity: 1;
  transform: rotate(42deg) scale(1);
}

.check input:focus-visible + .box {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.step-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.step-hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  text-transform: none;
}

/* code entry */

.code-wrap {
  margin: 20px 0 8px;
}

.code-input {
  width: 100%;
  height: 66px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  background: var(--white);
  font-family: var(--mono);
  font-size: 23px;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.code-input::placeholder {
  color: var(--ink-4);
  letter-spacing: 0.22em;
  font-size: 17px;
}

.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.code-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.form-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid rgba(194, 94, 58, 0.25);
  border-radius: 9px;
  padding: 10px 13px;
  animation: shake 0.36s var(--ease);
}

/* ready */

.ready {
  text-align: center;
  padding: 18px 0 4px;
}

.ready-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--olive);
  background: var(--olive-soft);
  border: 1px solid rgba(93, 107, 74, 0.32);
  animation: pop 0.5s var(--ease) both;
}

.ready h4 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.ready .step-note {
  max-width: 44ch;
  margin: 0 auto 24px;
}

.ready .btn {
  height: 48px;
  padding: 0 30px;
}

.ready .step-hint {
  display: block;
  margin-top: 14px;
  text-transform: none;
  font-size: 10px;
  color: var(--ink-4);
}

.receipt {
  margin: 24px auto 0;
  max-width: 400px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-m);
  padding: 4px 18px;
  text-align: left;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  font-size: 12px;
  border-bottom: 1px dashed var(--line);
}

.receipt-row:last-child {
  border-bottom: 0;
}

.receipt-row span:first-child {
  color: var(--ink-3);
}

.receipt-row span:last-child {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
}

/* tutorial video */

.tutorial {
  margin: 22px auto 0;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tutorial .btn {
  height: 42px;
  padding: 0 22px;
  font-size: 13px;
}

.video-shell {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #12100d;
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 40px -24px rgba(26, 23, 19, 0.6);
  animation: soft-in 0.42s var(--ease-out) both;
}

.video-shell video {
  display: block;
  width: 100%;
  max-height: 360px;
  background: #12100d;
}

.tutorial .form-error {
  width: 100%;
  margin-top: 0;
  text-align: left;
}

/* version history */

.version-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(26, 23, 19, 0.06);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  text-transform: uppercase;
  vertical-align: middle;
}

.version-history {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
  text-align: left;
}

.version-history--public {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.version-history-head {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.version-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-top: 1px dashed var(--line);
  font-size: 12px;
}

.version-row .version-note {
  color: var(--ink-2);
  line-height: 1.55;
}

.version-row.is-current .version-note {
  color: var(--ink);
  font-weight: 600;
}

.version-row .version-date {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  color: var(--ink-4);
  white-space: nowrap;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-actions .btn {
  height: 38px;
  padding: 0 16px;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- toast */

.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 130;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.42s var(--ease-out) both;
}

.toast.is-out {
  animation: toast-out 0.28s var(--ease-in-out) both;
}

.toast .toast-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.toast.toast--ok .toast-mark {
  background: #9bb07a;
}

.toast.toast--error .toast-mark {
  background: #e08a6a;
}

/* ================================================================== */
/*  Admin                                                              */
/* ================================================================== */

body.admin {
  background: var(--paper);
}

/* ---------------- login ---------------- */

.login-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  min-height: 100vh;
}

.login-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 52px;
  background-color: var(--rail);
  background-image:
    radial-gradient(720px 520px at 82% 8%, rgba(194, 94, 58, 0.3), transparent 62%),
    radial-gradient(520px 380px at 6% 92%, rgba(93, 107, 74, 0.22), transparent 60%);
  color: var(--paper);
  overflow: hidden;
}

.login-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.14'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.login-aside .brand {
  position: relative;
  z-index: 1;
}

.login-aside .brand-name {
  color: var(--paper);
}

.login-aside .brand-sub {
  color: rgba(246, 242, 233, 0.5);
}

.login-quote {
  position: relative;
  z-index: 1;
  max-width: 460px;
}

.login-quote .eyebrow {
  color: rgba(246, 242, 233, 0.62);
  margin-bottom: 26px;
}

.login-quote h1 {
  font-family: var(--serif);
  font-size: clamp(40px, 4.4vw, 62px);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: #f7f2e8;
}

.login-quote h1 em {
  font-style: italic;
  color: #e79a72;
}

.login-quote p {
  margin-top: 26px;
  max-width: 38ch;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(246, 242, 233, 0.66);
}

.login-aside-foot {
  position: relative;
  z-index: 1;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: rgba(246, 242, 233, 0.4);
}

.login-main {
  display: grid;
  place-items: center;
  padding: 44px;
  background:
    radial-gradient(760px 420px at 100% 0%, rgba(194, 94, 58, 0.06), transparent 60%),
    var(--paper);
}

.login-card {
  width: min(400px, 100%);
  animation: rise 0.7s var(--ease) both;
}

.login-card h2 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 14px 0 8px;
}

.login-card > .muted {
  font-size: 13.5px;
  margin-bottom: 30px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field > span {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 9px;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.input-shell input {
  width: 100%;
  height: 48px;
  padding: 0 66px 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--white);
  font-size: 14.5px;
  letter-spacing: 0.04em;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.input-shell input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-shell .reveal {
  position: absolute;
  right: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  transition: background 0.2s, color 0.2s;
}

.input-shell .reveal:hover {
  background: rgba(26, 23, 19, 0.06);
  color: var(--ink);
}

.login-card .btn {
  margin-top: 8px;
}

.login-hint {
  margin-top: 20px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  text-transform: none;
  line-height: 1.7;
}

.login-card .form-error {
  margin: 0 0 14px;
}

/* ---------------- shell ---------------- */

.admin-shell {
  display: grid;
  grid-template-columns: 66px 300px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 0;
  background: var(--rail);
  color: rgba(246, 242, 233, 0.55);
  border-right: 1px solid rgba(0, 0, 0, 0.25);
}

.rail-brand {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(246, 242, 233, 0.07);
  margin-bottom: 12px;
}

.rail-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: rgba(246, 242, 233, 0.5);
  transition: background 0.2s, color 0.2s;
}

.rail-btn:hover {
  background: rgba(246, 242, 233, 0.08);
  color: rgba(246, 242, 233, 0.9);
}

.rail-btn.is-active {
  background: rgba(246, 242, 233, 0.1);
  color: #f6f2e9;
}

.rail-btn.is-active::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.rail-spacer {
  flex: 1;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 22px 16px;
}

.sidebar-head h2 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-top: 5px;
}

.sidebar .search {
  margin: 0 18px 14px;
  min-width: 0;
  height: 38px;
  background: rgba(255, 253, 248, 0.6);
}

.res-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.res-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 11px 11px;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.26s var(--ease-soft), border-color 0.26s var(--ease-soft),
    box-shadow 0.26s var(--ease-soft), transform 0.26s var(--ease-out);
}

.res-item:hover {
  background: rgba(255, 253, 248, 0.62);
  transform: translateX(2px);
}

.res-item:active {
  transform: translateX(0) scale(0.995);
}

.res-item.is-active {
  background: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow-s);
}

.res-item .file-chip {
  height: 22px;
  padding: 0 7px;
  font-size: 9px;
  background: rgba(26, 23, 19, 0.05);
}

.res-item-main {
  min-width: 0;
}

.res-item-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-item-meta {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}

.res-item.is-gated .res-item-dot {
  opacity: 1;
}

.sidebar-foot {
  padding: 14px 18px 20px;
  border-top: 1px solid var(--line);
}

.sidebar-foot .btn {
  height: 42px;
  font-size: 13px;
}

.stage {
  min-width: 0;
  overflow-y: auto;
  padding: 30px 38px 64px;
  background:
    radial-gradient(900px 420px at 96% -6%, rgba(194, 94, 58, 0.05), transparent 62%),
    var(--paper);
}

.stage-inner {
  max-width: 940px;
  margin: 0 auto;
  animation: rise 0.42s var(--ease-out) both;
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-strong);
  flex-wrap: wrap;
}

.stage-head-main {
  min-width: 0;
  flex: 1;
}

.stage-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.title-input {
  width: 100%;
  max-width: 560px;
  border: 0;
  background: transparent;
  padding: 2px 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s;
}

.title-input:hover {
  border-bottom-color: var(--line-strong);
}

.title-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.stage-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  text-transform: none;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
}

.stage-actions .btn {
  height: 40px;
  padding: 0 18px;
  font-size: 12.5px;
}

.save-state {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--olive);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.38s var(--ease-out), transform 0.38s var(--ease-out);
  text-transform: uppercase;
}

.save-state.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.panels {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 24px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(26, 23, 19, 0.03);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-head h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.panel-head p {
  font-size: 12px;
  color: var(--ink-3);
}

.panel-body {
  display: flex;
  flex-direction: column;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 15px 0;
  border-top: 1px dashed var(--line);
  cursor: pointer;
}

.switch-row:first-child {
  border-top: 0;
  padding-top: 2px;
}

.switch-row:last-child {
  padding-bottom: 2px;
}

.switch-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}

.switch-copy small {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.55;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  background: rgba(26, 23, 19, 0.16);
  transition: background 0.25s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.28s var(--ease);
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row input:checked + .switch {
  background: var(--accent);
}

.switch-row input:checked + .switch::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-area,
.panel textarea,
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-area:focus,
.panel textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.panel-note {
  margin-top: 10px;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  text-transform: none;
  line-height: 1.6;
}

/* code generator */

.code-gen {
  display: grid;
  grid-template-columns: 82px 82px minmax(110px, 1fr) minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.5);
  margin-bottom: 20px;
}

.mini-field {
  display: block;
}

.mini-field span {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 7px;
  white-space: nowrap;
}

.mini-field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.mini-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.code-gen .btn {
  height: 38px;
  padding: 0 18px;
  font-size: 12px;
}

.codes-table {
  border-top: 1px solid var(--line);
}

.codes-head,
.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 66px 64px minmax(96px, 0.9fr) 116px;
  gap: 10px;
  align-items: center;
}

.codes-head {
  padding: 12px 4px 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  text-transform: uppercase;
}

.code-row {
  padding: 12px 4px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  border-radius: 8px;
  transition: background 0.26s var(--ease-soft);
}

.code-row:hover {
  background: rgba(255, 253, 248, 0.6);
}

.code-value {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.status--active {
  color: var(--olive);
  background: var(--olive-soft);
}

.status--expired {
  color: var(--ink-3);
  background: rgba(26, 23, 19, 0.06);
}

.status--exhausted {
  color: var(--amber);
  background: var(--amber-soft);
}

.status--revoked {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.code-usage {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-2);
}

.code-usage b {
  font-weight: 500;
  color: var(--ink);
}

.code-date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  line-height: 1.5;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.row-actions button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.row-actions button:hover {
  background: rgba(26, 23, 19, 0.06);
  border-color: var(--line);
  color: var(--ink);
}

.row-actions button.is-danger:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: rgba(194, 94, 58, 0.25);
}

.codes-empty {
  padding: 26px 8px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

.file-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.file-meta {
  min-width: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}

.file-sub--video {
  color: var(--olive);
}

.danger-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-deep);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(194, 94, 58, 0.3);
  transition: background 0.2s;
}

.danger-link:hover {
  background: var(--accent-soft);
}

/* empty stage */

.stage-empty {
  height: 100%;
  min-height: 480px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  padding: 48px 32px;
  background: rgba(255, 253, 248, 0.38);
}

.stage-empty .mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.stage-empty h3 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.stage-empty p {
  max-width: 34ch;
  margin: 0 auto 24px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-3);
}

/* ---------------- admin modal / upload ---------------- */

.admin-modal .modal-panel {
  width: min(660px, 100%);
  padding: 28px 30px 30px;
}

.admin-modal h3.modal-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.admin-modal .modal-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 22px;
}

.dropzone {
  display: block;
  width: 100%;
  border: 1.5px dashed var(--line-strong);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.6);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
  margin-bottom: 20px;
}

.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.is-drag {
  transform: scale(1.006);
}

.dropzone .dz-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--paper-2);
  color: var(--ink-2);
}

.dropzone strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.dropzone small {
  font-size: 11.5px;
  color: var(--ink-3);
}

.dropzone--video {
  padding: 16px 20px;
}

.dropzone--video .dz-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  border-radius: 10px;
}

.dz-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--paper-2);
  text-align: left;
}

.dz-file .file-meta {
  flex: 1;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.admin-modal .field {
  margin-bottom: 0;
}

.admin-modal .field input,
.admin-modal .field textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--white);
  font-size: 13.5px;
}

.admin-modal .field textarea {
  height: auto;
  padding: 12px 14px;
  line-height: 1.7;
  resize: vertical;
}

.admin-modal .field input:focus,
.admin-modal .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.upload-options {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 4px 16px;
  background: rgba(255, 253, 248, 0.55);
}

.upload-options .switch-row {
  padding: 12px 0;
}

.progress {
  height: 4px;
  border-radius: 99px;
  background: rgba(26, 23, 19, 0.1);
  overflow: hidden;
  margin: 18px 0 0;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.32s var(--ease-out);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* confirm dialog */

.confirm-modal .modal-panel {
  width: min(440px, 100%);
  padding: 30px;
}

.confirm-modal h3 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.confirm-modal p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-3);
  margin-bottom: 22px;
}

.btn-danger {
  background: var(--accent-deep);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: #853619;
}

/* ---------------------------------------------------------------- animations */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes card-swap {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes soft-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes soft-pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

@keyframes sweep {
  from {
    background-position: 180% 0;
  }
  to {
    background-position: -80% 0;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.982);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes panel-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.986);
  }
}

@keyframes pane-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  70% {
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  55% {
    transform: translateX(2px);
  }
  80% {
    transform: translateX(-1px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(5px) scale(0.985);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    padding: 76px 0 68px;
  }

  .ledger {
    border-left: 0;
    border-top: 1px solid var(--line-strong);
    padding: 6px 0 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 26px;
  }

  .ledger-head {
    grid-column: 1 / -1;
  }

  .ledger-row {
    border-top: 0;
    border-right: 1px dashed var(--line-strong);
    padding: 16px 0 6px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .ledger-row:nth-child(4) {
    border-right: 0;
  }

  .ledger-note {
    grid-column: 1 / -1;
  }

  .code-gen {
    grid-template-columns: 1fr 1fr;
  }

  .code-gen .btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .admin-shell {
    grid-template-columns: 60px 252px minmax(0, 1fr);
  }

  .stage {
    padding: 24px 24px 52px;
  }

  .codes-head,
  .code-row {
    grid-template-columns: minmax(0, 1.3fr) 62px 62px 116px;
  }

  .code-date {
    display: none;
  }

  .codes-head span:nth-child(4) {
    display: none;
  }
}

@media (max-width: 860px) {
  .login-wrap {
    grid-template-columns: 1fr;
  }

  .login-aside {
    min-height: 280px;
    padding: 30px 32px;
  }

  .login-quote h1 {
    font-size: 38px;
  }

  .login-quote p {
    margin-top: 16px;
  }

  .login-aside-foot {
    display: none;
  }

  .login-main {
    padding: 44px 32px 64px;
  }

  .admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .rail {
    flex-direction: row;
    padding: 0 14px;
    gap: 6px;
    border-right: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  }

  .rail-brand {
    margin: 0 8px 0 0;
    width: 32px;
    height: 32px;
  }

  .rail-btn.is-active::before {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: -8px;
    width: auto;
    height: 2px;
  }

  .rail-spacer {
    flex: 1;
  }

  .sidebar {
    max-height: 244px;
  }

  .stage {
    overflow: visible;
  }

  .stage-empty {
    min-height: 320px;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    height: 62px;
    padding: 0 20px;
  }

  .topnav {
    gap: 14px;
  }

  .topnav-link:first-child,
  .topnav-divider {
    display: none;
  }

  main {
    padding: 0 20px;
  }

  .hero {
    padding: 58px 0 54px;
  }

  .hero-title {
    font-size: clamp(40px, 11vw, 58px);
  }

  .ledger {
    grid-template-columns: 1fr;
  }

  .ledger-row {
    border-right: 0;
    border-top: 1px dashed var(--line-strong);
  }

  .ledger-head {
    padding-bottom: 4px;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .library-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .segmented {
    justify-content: space-between;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .foot {
    padding: 22px 20px 34px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding: 26px 22px 30px;
    animation-name: sheet-in;
  }

  .stepper li:not(:last-child)::after {
    width: 18px;
    margin: 0 8px;
  }

  .stepper li {
    font-size: 9px;
    gap: 6px;
  }

  .modal-head h3 {
    font-size: 24px;
  }

  .code-input {
    font-size: 19px;
    letter-spacing: 0.22em;
    height: 58px;
  }

  .code-gen {
    grid-template-columns: 1fr 1fr;
  }

  .stage {
    padding: 20px 16px 44px;
  }

  .title-input {
    font-size: 27px;
  }

  .stage-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .codes-head {
    display: none;
  }

  .code-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 14px 4px;
  }

  .code-row .code-usage,
  .code-row .code-date {
    display: block;
    grid-column: 1 / 2;
  }

  .code-row .status {
    grid-column: 2 / 3;
    grid-row: 1;
    justify-self: end;
  }

  .code-row .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .toast-stack {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
