/* qready — themed after marchproducts.com
   Fonts: Libre Baskerville (headings) + Source Sans 3 (body)
   Palette: navy / warm-gold / cream */
:root {
  --navy: #0b263a;
  --navy-mid: #102a3e;
  --gold: #ff9a55;
  --gold-light: #ffb07a;
  --gold-pale: #ffe8d6;
  --cream: #f7f4ef;
  --cream-dark: #ede8df;
  --warm-white: #fdfbf8;
  --text: #1c1c1c;
  --text-mid: #4a4a4a;
  --text-light: #8a8a8a;
  --rule: #ddd8cf;
  --serif: "Libre Baskerville", Georgia, serif;
  --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 28px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { width: 34px; height: 34px; display: block; }
.brand .word { font-family: var(--serif); font-weight: 700; font-size: 24px; letter-spacing: -0.01em; }
.tagline { color: rgba(255,255,255,.7); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.nav-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  padding: 9px 16px; border-radius: 4px; font-family: var(--sans); font-size: 13px;
  font-weight: 600; letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
}
.nav-btn:hover { border-color: var(--gold); color: var(--gold-light); }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 28px;
  max-width: 1080px; margin: 36px auto; padding: 0 28px; align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--warm-white); border: 1px solid var(--rule); border-radius: 8px;
  padding: 28px;
}
.preview-panel { position: sticky; top: 28px; text-align: center; }
@media (max-width: 860px) { .preview-panel { position: static; } }

h2 {
  font-family: var(--sans); font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-light); margin: 28px 0 14px;
}
h2:first-of-type { margin-top: 4px; }

/* ---------- form ---------- */
label { display: block; font-size: 13px; color: var(--text-mid); margin-bottom: 14px; font-weight: 600; }
input, select {
  display: block; width: 100%; margin-top: 5px; padding: 11px 13px;
  border: 1px solid var(--rule); border-radius: 4px; font-size: 15px; color: var(--text);
  background: #fff; font-family: var(--sans); font-weight: 400;
}
input::placeholder { color: var(--text-light); }
input:focus, select:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-pale);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.addr { margin-bottom: 14px; }
.addr summary { cursor: pointer; color: var(--navy); font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.addr summary:hover { color: var(--gold); }

/* ---------- mode toggle ---------- */
.mode-toggle { display: flex; gap: 10px; margin-bottom: 22px; }
.mode {
  flex: 1; padding: 13px; border: 1px solid var(--rule); border-radius: 6px; background: #fff;
  cursor: pointer; font-family: var(--sans); font-size: 15px; font-weight: 700; color: var(--text);
}
.mode small { display: block; font-weight: 400; font-size: 11px; color: var(--text-light); margin-top: 3px; letter-spacing: .02em; }
.mode.active { border-color: var(--navy); background: var(--navy); color: #fff; }
.mode.active small { color: rgba(255,255,255,.75); }

/* ---------- buttons ---------- */
button { font-family: var(--sans); }
.primary {
  width: 100%; padding: 15px; background: var(--navy); color: #fff; border: 0;
  border-radius: 4px; font-size: 14px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; cursor: pointer; transition: background .15s;
}
.primary:hover { background: var(--gold); color: var(--navy); }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.ghost {
  padding: 10px 15px; background: #fff; border: 1px solid var(--rule); border-radius: 4px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--navy);
}
.ghost:hover { border-color: var(--gold); color: var(--gold); }
.ghost.block { display: block; text-align: center; text-decoration: none; margin-top: 14px; }

/* ---------- preview ---------- */
.qr-frame { display: inline-flex; flex-direction: column; align-items: center; padding: 12px; }
.qr-canvas { line-height: 0; }
.qr-canvas canvas, .qr-canvas svg { display: block; max-width: 100%; height: auto; border-radius: 4px; }

.preview-head { font-family: var(--serif); font-weight: 700; font-size: 22px; color: var(--navy);
  margin: 0 0 6px; letter-spacing: -0.01em; }
.placeholder { color: var(--text-mid); font-size: 14px; margin: 14px 0; line-height: 1.6; }

.downloads { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.dl {
  flex: 1; max-width: 130px; padding: 11px; border: 1px solid var(--navy); background: #fff;
  border-radius: 4px; font-weight: 700; font-size: 13px; letter-spacing: .05em; cursor: pointer; color: var(--navy);
}
.dl:hover { background: var(--navy); color: #fff; }
.dl:disabled { opacity: .35; cursor: not-allowed; border-color: var(--rule); color: var(--text-light); }

/* ---------- link box ---------- */
.linkbox { margin-top: 24px; text-align: left; border-top: 1px solid var(--rule); padding-top: 20px; }
.linkbox h3 { font-family: var(--serif); margin: 0 0 12px; font-size: 18px; color: var(--navy); }
.copyrow { display: flex; gap: 8px; margin-bottom: 8px; }
.copyrow input { font-size: 13px; margin-top: 0; }
.hint { font-size: 12.5px; color: var(--text-mid); line-height: 1.55; margin: 4px 0 14px; }

.banner { background: var(--gold-pale); border: 1px solid var(--gold-light); color: #7a3d12; padding: 13px 15px;
  border-radius: 6px; font-size: 13px; margin-bottom: 18px; }
.error { color: #b91c1c; font-size: 14px; margin-top: 12px; }
.hidden { display: none !important; }

.sitefoot {
  text-align: center; color: var(--text-light); font-size: 12px; padding: 36px 16px;
  letter-spacing: .03em; border-top: 1px solid var(--rule); margin-top: 24px;
}

/* ---------- modal (stats + my generations) ---------- */
.modal { position: fixed; inset: 0; background: rgba(11,38,58,.6); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card {
  background: var(--warm-white); border-radius: 8px; padding: 28px; max-width: 520px; width: 100%;
  max-height: 88vh; overflow: auto; position: relative; border: 1px solid var(--rule);
}
.modal-card h2 { font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--navy);
  text-transform: none; letter-spacing: -0.01em; margin: 0 0 16px; }
.modal-card h3 { font-family: var(--sans); font-size: 12px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-light); margin: 20px 0 10px; }
.modal-close { position: absolute; top: 14px; right: 18px; border: 0; background: none;
  font-size: 28px; cursor: pointer; color: var(--text-light); line-height: 1; }
.modal-close:hover { color: var(--navy); }

.stat-big { text-align: center; margin: 12px 0 20px; }
.stat-big span { font-family: var(--serif); font-size: 52px; font-weight: 700; color: var(--gold); display: block; }
.stat-big small { color: var(--text-mid); letter-spacing: .03em; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-bottom: 16px; }
.bars .bar { flex: 1; background: var(--navy); border-radius: 2px 2px 0 0; min-height: 2px; }
.statlist { list-style: none; padding: 0; margin: 0; }
.statlist li { display: flex; justify-content: space-between; padding: 9px 0;
  border-bottom: 1px solid var(--rule); font-size: 14px; }

/* my generations list */
.gen-list { list-style: none; padding: 0; margin: 0; }
.gen-item { border: 1px solid var(--rule); border-radius: 6px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.gen-item .gname { font-weight: 700; color: var(--navy); }
.gen-item .gmeta { font-size: 12px; color: var(--text-light); margin: 2px 0 10px; }
.gen-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gen-actions a, .gen-actions button {
  font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--rule); background: #fff; color: var(--navy); text-decoration: none;
}
.gen-actions a:hover, .gen-actions button:hover { border-color: var(--gold); color: var(--gold); }
.gen-actions .danger { color: #b91c1c; border-color: #f0c9c9; }
.gen-actions .danger:hover { background: #fdeaea; color: #b91c1c; border-color: #e3a5a5; }
.gen-empty { color: var(--text-mid); font-size: 14px; }
.gen-tools { display: flex; gap: 10px; margin: 4px 0 20px; }

/* ---------- QR name field ---------- */
.qr-name-label {
  display: block; background: var(--cream); border: 1px solid var(--rule);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 22px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-light);
}
.qr-name-label input {
  margin-top: 8px; font-size: 16px; font-weight: 600; text-transform: none; letter-spacing: normal; color: var(--text);
}
.field-note { display: block; margin-top: 8px; font-size: 11.5px; font-weight: 400;
  text-transform: none; letter-spacing: normal; color: var(--text-light); line-height: 1.45; }

/* ---------- QR stage + loading overlay ---------- */
.qr-stage { position: relative; display: inline-block; }
.qr-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; border-radius: 8px;
  background: rgba(253, 251, 248, 0.86); backdrop-filter: blur(2px);
  color: var(--navy); font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.qr-loading.error { color: #b91c1c; background: rgba(253, 234, 234, 0.9); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--gold-pale); border-top-color: var(--gold);
  animation: qr-spin 0.8s linear infinite;
}
.qr-loading.error .spinner { display: none; }
@keyframes qr-spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.acct-email { color: rgba(255,255,255,.85); font-size: 13px; margin-right: 4px; }
.auth-card label { color: var(--text-mid); }
.auth-actions { display: flex; gap: 10px; margin-top: 6px; }
.auth-actions .primary { width: auto; flex: 1; }
.auth-actions .ghost { flex: 1; }

/* ---------- full-screen lock gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: var(--navy); padding: 24px;
}
.gate.hidden { display: none !important; }
.gate-card {
  width: 100%; max-width: 360px; text-align: center; color: #fff;
}
.gate-logo { width: 64px; height: 64px; margin: 0 auto 16px; display: block; }
.gate-card h1 { font-family: var(--serif); font-size: 34px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.gate-sub { color: rgba(255,255,255,.75); font-size: 14px; margin: 0 0 22px; }
.gate-card input {
  margin: 0 0 14px; padding: 14px; font-size: 16px; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 6px;
}
.gate-card input::placeholder { color: rgba(255,255,255,.5); }
.gate-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,154,85,.25); }
.gate-card .primary { background: var(--gold); color: var(--navy); }
.gate-card .primary:hover { background: var(--gold-light); }
.gate-card .error { color: #ffb4b4; }

/* ---------- persistent sidebar ---------- */
.shell { display: flex; align-items: flex-start; }
.sidebar {
  width: 270px; flex: none; align-self: stretch;
  background: var(--warm-white); border-right: 1px solid var(--rule);
  padding: 20px 16px; position: sticky; top: 0; max-height: 100vh; overflow: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-title { font-family: var(--sans); font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-light); }
.sidebar .ghost.block { width: 100%; margin-top: 14px; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-item { display: flex; align-items: stretch; gap: 6px; margin-bottom: 8px; }
.side-select {
  flex: 1; text-align: left; background: #fff; border: 1px solid var(--rule); border-radius: 6px;
  padding: 10px 12px; cursor: pointer; color: var(--text); font-family: var(--sans); overflow: hidden;
}
.side-select:hover { border-color: var(--gold); }
.side-item.active .side-select { border-color: var(--navy); background: var(--navy); color: #fff; }
.side-select .sname { display: block; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-select .scode { display: block; font-size: 11px; color: var(--text-light); margin-top: 2px; }
.side-item.active .side-select .scode { color: rgba(255,255,255,.7); }
.side-del {
  flex: none; width: 34px; border: 1px solid var(--rule); background: #fff; border-radius: 6px;
  cursor: pointer; color: var(--text-light); font-size: 18px; line-height: 1;
}
.side-del:hover { border-color: #e3a5a5; color: #b91c1c; background: #fdeaea; }
.side-empty { color: var(--text-light); font-size: 13px; padding: 6px 2px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); }
}

/* ---------- sidebar item: thumbnail + date ---------- */
.side-select { display: flex; align-items: center; gap: 10px; }
.side-thumb {
  width: 46px; height: 46px; flex: none; background: #fff; border: 1px solid var(--rule);
  border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; line-height: 0;
}
.side-thumb canvas, .side-thumb svg { width: 40px; height: 40px; display: block; }
.side-text { min-width: 0; display: flex; flex-direction: column; }
.sdate { font-size: 11px; color: var(--text-light); margin-top: 1px; }
.side-item.active .sdate { color: rgba(255,255,255,.6); }

/* ---------- sticky top nav + preview layering ---------- */
.topbar { position: sticky; top: 0; z-index: 40; }
.sidebar { top: 70px; max-height: calc(100vh - 70px); }
.preview-panel { top: 94px; }
@media (max-width: 860px) { .preview-panel { top: 0; } }

/* ---------- QR stage with ghost placeholder ---------- */
.qr-stage {
  position: relative; width: 304px; max-width: 100%; min-height: 304px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.qr-ghost {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  opacity: .12; filter: grayscale(1); pointer-events: none;
}
.qr-ghost.hidden { display: none; }
.qr-ghost canvas, .qr-ghost svg { width: 260px; height: 260px; }
