/* QR Label Desk — light press / sticky preview */
/* Fonts loaded via <link> in HTML pages (avoid CSS @import latency). */

:root {
  --ink: #12141a;
  --ink-soft: #3d4450;
  --muted: #7a8290;
  --paper: #f3f1ec;
  --sheet: #ffffff;
  --line: #e4e0d8;
  --line-strong: #cdc7bb;
  --accent: #1d4ed8;
  --accent-soft: #e8eefc;
  --danger: #c0352b;
  --ok: #1f7a4c;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(18, 20, 26, 0.04), 0 18px 40px rgba(18, 20, 26, 0.07);
  --font: "Figtree", system-ui, sans-serif;
  --display: "Bricolage Grotesque", "Figtree", sans-serif;
  --wrap: min(1120px, calc(100% - 2rem));
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(29, 78, 216, 0.08), transparent 55%),
    linear-gradient(180deg, #ebe8e1 0%, var(--paper) 40%, #eceae4 100%);
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}
a:hover {
  color: #153eb0;
}

.wrap {
  width: var(--wrap);
  margin-inline: auto;
}
.wrap--text {
  max-width: 40rem;
}

/* —— topbar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(243, 241, 236, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__in {
  width: var(--wrap);
  margin-inline: auto;
  min-height: 3.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
.brand:hover {
  color: var(--accent);
}
.brand__mark {
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid var(--ink);
  background:
    linear-gradient(var(--ink), var(--ink)) 2px 2px / 5px 5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) calc(100% - 2px) 2px / 5px 5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 2px calc(100% - 2px) / 5px 5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 8px 8px / 4px 4px no-repeat;
}

.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.menu a {
  color: var(--ink-soft);
  text-decoration: none;
}
.menu a:hover,
.menu a.is-on {
  color: var(--accent);
}

/* ads */
.ad-slot {
  width: var(--wrap);
  margin: 0.85rem auto;
  padding: 0.7rem;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
}
.ad-slot-hint {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* —— desk intro —— */
.desk-intro {
  width: var(--wrap);
  margin: 1.35rem auto 0.85rem;
  animation: rise 0.45s ease both;
}
.desk-intro h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.85rem, 4vw, 2.55rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.desk-intro p {
  margin: 0.45rem 0 0;
  max-width: 34rem;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

/* —— mode tabs —— */
.modes {
  width: var(--wrap);
  margin: 0 auto 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.3rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 999px;
  animation: rise 0.45s ease 0.05s both;
}
.modes button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modes button span {
  display: none;
}
.modes button:hover {
  color: var(--ink);
  background: rgba(18, 20, 26, 0.04);
}
.modes button.is-on {
  background: var(--ink);
  color: #fff;
}

/* —— stage: form | sticky preview —— */
.stage {
  width: var(--wrap);
  margin: 0 auto 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 1rem;
  align-items: start;
  animation: rise 0.45s ease 0.1s both;
}
.stage[data-mode="scan"] {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
}

.panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.35rem;
}
.panel__title {
  margin: 0 0 0.25rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.panel__desc {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.sec {
  margin: 0 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf9f6;
  overflow: hidden;
}
.sec > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.7rem 0.85rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  user-select: none;
}
.sec > summary::-webkit-details-marker {
  display: none;
}
.sec > summary::after {
  content: "+";
  font-weight: 700;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.sec[open] > summary::after {
  content: "–";
}
.sec__body {
  padding: 0 0.85rem 0.9rem;
  border-top: 1px solid var(--line);
}

.field {
  margin-bottom: 0.8rem;
}
.field:last-child {
  margin-bottom: 0;
}
.field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}
.field-hint {
  margin: 0.28rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  font: 500 0.95rem/1.4 var(--font);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.58rem 0.7rem;
}
.field textarea {
  min-height: 5.5rem;
  resize: vertical;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.field--check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
}
.field--check input {
  width: auto;
  accent-color: var(--accent);
}
.field--check label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}

.style-bar__label {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}
.swatch {
  appearance: none;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  padding: 0;
  background: linear-gradient(135deg, var(--sw-a) 50%, var(--sw-b) 50%);
}
.swatch.is-on {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.emoji-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.emoji-chip {
  appearance: none;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  font-size: 1.15rem;
  cursor: pointer;
}
.emoji-chip.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.emoji-box__hint {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.62rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.btn:hover {
  background: #153eb0;
}
.btn:active {
  transform: translateY(1px);
}
.btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff;
}
.btn--danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid rgba(192, 53, 43, 0.35);
}
.btn--danger:hover {
  background: rgba(192, 53, 43, 0.06);
}
.btn--block {
  width: 100%;
  justify-content: center;
}

.msg {
  margin: 0.65rem 0 0;
  font-size: 0.86rem;
  color: var(--ok);
  font-weight: 600;
}
.msg.is-err {
  color: var(--danger);
}

.faq-block {
  margin-top: 0.85rem;
  font-size: 0.86rem;
  color: var(--muted);
}
.faq-block summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink-soft);
}

/* —— preview sticky —— */
.preview {
  position: sticky;
  top: 4.2rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.preview__label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.preview__frame {
  background: #f7f6f2;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}
.preview__frame--card {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(18, 20, 26, 0.04);
}
.preview__frame--sheet {
  overflow: auto;
  align-items: stretch;
}
.preview__frame--sheet canvas {
  max-width: 100%;
  height: auto;
}
.preview__frame canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.preview__title {
  margin: 0 0 0.55rem;
  width: 100%;
  text-align: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  word-break: break-word;
}
.preview__foot {
  margin: 0.45rem 0 0;
  width: 100%;
  text-align: center;
  font-weight: 600;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}
.preview__foot .foot-line--muted {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78em;
  font-weight: 500;
  color: var(--muted);
  word-break: break-all;
}
.preview__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}
.preview__payload {
  max-height: 4.2rem;
  overflow: auto;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: #f7f6f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  word-break: break-all;
}
.preview-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.preview-actions .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* scan */
.scan-view {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0a0a;
  border-radius: var(--radius);
  overflow: hidden;
}
.scan-view video,
.scan-view canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-view canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.scan-view__corners {
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(29, 78, 216, 0.85);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  border-radius: 4px;
}
.scan-meta {
  margin: 0.65rem 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.scan-type {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.scan-history {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 8.5rem;
  overflow: auto;
}
.scan-history li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-soft);
  word-break: break-all;
  cursor: pointer;
}
.scan-history li:hover {
  color: var(--accent);
}

/* pages */
.page {
  padding: 2rem 0 3rem;
}
.page h1,
.prose h1 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: clamp(1.7rem, 3.5vw, 2.2rem);
  margin: 0 0 0.7rem;
}
.lede {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
}
.prose h2 {
  font-family: var(--display);
  font-size: 1.2rem;
  margin: 1.75rem 0 0.5rem;
  color: var(--ink);
}
.prose p,
.prose li {
  color: var(--ink-soft);
}
.prose code {
  font-family: ui-monospace, monospace;
  font-size: 0.88em;
  background: #ebe8e1;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.post-list a {
  font-family: var(--display);
  font-weight: 750;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}
.post-list a:hover {
  color: var(--accent);
}
.post-list .meta {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.foot {
  border-top: 1px solid var(--line);
  padding: 1.75rem 0 2.25rem;
  background: rgba(255, 255, 255, 0.35);
}
.foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.15rem;
  margin-bottom: 0.85rem;
}
.foot__links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.foot__links a:hover {
  color: var(--accent);
}
.foot__legal,
.foot p {
  margin: 0.25rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 880px) {
  .stage,
  .stage[data-mode="scan"] {
    grid-template-columns: 1fr;
  }
  .preview {
    position: static;
    order: -1;
  }
  .modes {
    border-radius: var(--radius);
  }
  .modes button {
    flex: 1 1 auto;
    text-align: center;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .topbar__in {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.55rem 0;
  }
}
