/* ==========================================================================
   PermaQR — "print shop" design system
   Warm paper, hard ink rules, vermilion accents, offset letterpress shadows.
   ========================================================================== */

:root {
  --paper:      #ece5d6;
  --paper-2:    #e3dac6;
  --card:       #fbf8f1;
  --card-2:     #f4efe3;
  --ink:        #14120d;
  --ink-2:      #3c372c;
  --ink-soft:   #6b6455;
  --accent:     #d6431a;
  --accent-ink: #fff5f1;
  --blue:       #1b4dd8;
  --ok:         #1c6f45;
  --warn:       #9a6b0f;

  --rule: 2px solid var(--ink);
  --pop: 6px 6px 0 var(--ink);
  --pop-sm: 4px 4px 0 var(--ink);
  --pop-accent: 6px 6px 0 var(--accent);

  --font-display: 'Cabinet Grotesk', 'Arial Black', 'Helvetica Neue', sans-serif;
  --font-body: 'Satoshi', ui-sans-serif, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  --r: 4px;
  --shell: 1160px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(20, 18, 13, 0.16) 1px, transparent 1px),
    radial-gradient(rgba(20, 18, 13, 0.06) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px;
  background-position: 0 0, 11px 11px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

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

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ---------- typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.025em;
}
h1 { font-size: clamp(2.4rem, 6vw, 4.6rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.2rem; letter-spacing: -0.01em; }

.serif {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.tag--accent { color: var(--accent); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- shell ---------- */
.shell {
  width: min(100% - 2.5rem, var(--shell));
  margin-inline: auto;
}
.shell--narrow { width: min(100% - 2.5rem, 720px); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: var(--rule);
  background: var(--paper);
  background-image: linear-gradient(var(--paper), var(--paper));
}
.topbar__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 62px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
.brand__mark {
  width: 26px; height: 26px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 2px;
}
.brand__mark i {
  background: var(--ink);
  border-radius: 1px;
  animation: markPulse 4s ease-in-out infinite;
}
.brand__mark i:nth-child(2), .brand__mark i:nth-child(4),
.brand__mark i:nth-child(6), .brand__mark i:nth-child(8) { background: var(--accent); }
.brand__mark i:nth-child(odd) { animation-delay: 0.4s; }
@keyframes markPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.topnav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
  font-size: 0.9rem;
}
.topnav a {
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.topnav a:hover { border-bottom-color: var(--accent); }
.topnav a.is-active { border-bottom-color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--card);
  --btn-fg: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.62rem 1.15rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: var(--rule);
  border-radius: var(--r);
  box-shadow: var(--pop-sm);
  transition: transform 0.09s ease, box-shadow 0.09s ease, background 0.15s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: var(--pop-sm); }

.btn--accent { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); }
.btn--ink    { --btn-bg: var(--ink);    --btn-fg: var(--paper); }
.btn--ghost  { --btn-bg: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--card); box-shadow: var(--pop-sm); }
.btn--sm { padding: 0.36rem 0.72rem; font-size: 0.8rem; box-shadow: 3px 3px 0 var(--ink); }
.btn--lg { padding: 0.85rem 1.6rem; font-size: 1.05rem; box-shadow: var(--pop); }
.btn--block { width: 100%; }
.btn--danger { --btn-bg: #fff; --btn-fg: #a71d0d; border-color: #a71d0d; box-shadow: 3px 3px 0 #a71d0d; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: var(--rule);
  border-radius: var(--r);
  box-shadow: var(--pop);
  padding: 1.4rem;
}
.card--flat { box-shadow: none; }
.card--tight { padding: 1rem; }
.card__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px dashed rgba(20,18,13,0.3);
}
.card__head h3 { margin-right: auto; }

/* dashed "cut here" panel */
.panel-cut {
  border: 2px dashed rgba(20,18,13,0.4);
  border-radius: var(--r);
  padding: 1.2rem;
  background: rgba(255,255,255,0.35);
}

/* ---------- badges / stamps ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.16rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}
.badge--live { color: var(--ok); }
.badge--paused { color: var(--warn); }
.badge--redirect { color: var(--blue); }
.badge--dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--live.badge--dot::before { animation: blip 2s ease-in-out infinite; }
@keyframes blip { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 2px;
  padding: 0.3rem 0.6rem;
  transform: rotate(-6deg);
  opacity: 0.9;
}

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 1rem; }
.field > .tag { display: block; margin-bottom: 0.35rem; }

.input, .textarea, .select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: var(--rule);
  border-radius: var(--r);
  font-size: 0.95rem;
  transition: box-shadow 0.12s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  box-shadow: var(--pop-sm);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: none; cursor: pointer; }
.input--mono { font-family: var(--font-mono); font-size: 0.85rem; }

.hint { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.3rem; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 42px; height: 22px;
  border: var(--rule);
  border-radius: 999px;
  background: var(--card-2);
  position: relative;
  transition: background 0.16s ease;
  flex: none;
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.16s cubic-bezier(0.4, 1.6, 0.5, 1);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- alerts ---------- */
.alert {
  border: var(--rule);
  border-left-width: 8px;
  border-radius: var(--r);
  padding: 0.75rem 1rem;
  background: var(--card);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}
.alert--error { border-left-color: var(--accent); }
.alert--ok { border-left-color: var(--ok); }
.alert--info { border-left-color: var(--blue); }

/* ---------- layout helpers ---------- */
.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--tight { gap: 0.4rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.divider { height: 1px; background: rgba(20,18,13,0.2); margin: 1.25rem 0; }
.rule-heavy { height: 2px; background: var(--ink); }

.page-head {
  padding: 2.25rem 0 1.5rem;
  border-bottom: var(--rule);
  margin-bottom: 2rem;
}

/* ---------- entrance animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: revealUp 0.65s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes revealUp { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   Landing
   ========================================================================== */
.hero {
  position: relative;
  padding: clamp(3rem, 8vw, 6rem) 0 3.5rem;
  overflow: hidden;
}
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
@media (max-width: 900px) { .hero__grid { grid-template-columns: 1fr; } }

.hero h1 { margin: 0.8rem 0 0; }
.hero h1 em { font-family: 'Instrument Serif', Georgia, serif; font-style: italic; font-weight: 400; color: var(--accent); }
.hero__lede {
  margin-top: 1.4rem;
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  max-width: 46ch;
  color: var(--ink-2);
}
.hero__cta { margin-top: 2rem; display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.7rem;
  border: var(--rule);
  border-radius: 999px;
  background: var(--card);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: '';
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: blip 1.8s ease-in-out infinite;
}

/* the hero demo: fixed QR, cycling destination */
.demo {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.5rem;
  align-items: center;
}
@media (max-width: 560px) { .demo { grid-template-columns: 1fr; justify-items: center; } }

.demo__qr {
  position: relative;
  background: var(--card);
  border: var(--rule);
  border-radius: var(--r);
  box-shadow: var(--pop);
  padding: 0.9rem;
  transform: rotate(-2.5deg);
}
.demo__qr img, .demo__qr svg { width: 148px; height: 148px; }
.demo__qr .stamp { position: absolute; bottom: -14px; left: -18px; background: var(--card); }
.demo__caption { margin-top: 0.55rem; text-align: center; }

.demo__phone {
  position: relative;
  border: var(--rule);
  border-radius: 14px;
  box-shadow: var(--pop);
  background: var(--ink);
  padding: 10px;
  min-height: 320px;
  overflow: hidden;
}
.demo__screen {
  position: relative;
  height: 300px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.demo__slide {
  position: absolute;
  inset: 0;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  opacity: 0;
  animation: slideCycle 13.5s linear infinite;
}
.demo__slide:nth-child(1) { animation-delay: 0s; }
.demo__slide:nth-child(2) { animation-delay: 4.5s; }
.demo__slide:nth-child(3) { animation-delay: 9s; }
@keyframes slideCycle {
  0%   { opacity: 0; transform: translateY(10px); }
  3%   { opacity: 1; transform: none; }
  30%  { opacity: 1; transform: none; }
  34%  { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 0; transform: translateY(-10px); }
}
.demo__title { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.demo__bar {
  border: 1.5px solid currentColor;
  border-radius: 3px;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.demo__meta { margin-top: auto; font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.6; }

.marquee {
  border-block: var(--rule);
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  padding: 0.55rem 0;
  margin: 3rem 0;
}
.marquee__track {
  display: flex;
  gap: 2.5rem;
  width: max-content;
  animation: marquee 32s linear infinite;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  white-space: nowrap;
}
@keyframes marquee { to { transform: translateX(-50%); } }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}
.feature { position: relative; }
.feature__num {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.6rem;
}
.feature h3 { margin-bottom: 0.4rem; }
.feature p { font-size: 0.9rem; color: var(--ink-2); }

.steps { counter-reset: step; display: grid; gap: 0; border: var(--rule); border-radius: var(--r); background: var(--card); box-shadow: var(--pop); overflow: hidden; }
.step { display: grid; grid-template-columns: 66px 1fr; gap: 1rem; padding: 1.15rem 1.3rem; border-bottom: 1px dashed rgba(20,18,13,0.3); }
.step:last-child { border-bottom: 0; }
.step__n {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}
.step h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.step p { font-size: 0.89rem; color: var(--ink-2); }

.footer {
  border-top: var(--rule);
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

/* ==========================================================================
   Auth
   ========================================================================== */
.auth-wrap {
  min-height: calc(100vh - 62px);
  display: grid;
  place-items: center;
  padding: 3rem 0;
}
.auth-card { width: min(100% - 2.5rem, 440px); }
.auth-card h1 { font-size: 2.1rem; margin-bottom: 0.3rem; }
.auth-alt { margin-top: 1.2rem; font-size: 0.88rem; text-align: center; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: var(--rule);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: var(--pop);
  overflow: hidden;
}
.stat {
  padding: 1rem 1.15rem;
  border-right: 1px dashed rgba(20,18,13,0.3);
}
.stat:last-child { border-right: 0; }
.stat__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat__label { margin-top: 0.3rem; }

.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.4rem;
}
.code-card { display: flex; flex-direction: column; gap: 0.9rem; position: relative; }
.code-card__top { display: flex; gap: 0.9rem; align-items: flex-start; }
.code-card__qr {
  flex: none;
  width: 84px; height: 84px;
  padding: 5px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: #fff;
}
.code-card__qr img { width: 100%; height: 100%; }
.code-card h3 {
  font-size: 1.08rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.code-card__url {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  word-break: break-all;
  line-height: 1.4;
}
.code-card__stats {
  display: flex;
  gap: 1.1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(20,18,13,0.3);
  margin-top: auto;
}
.code-card__stat b {
  font-family: var(--font-display);
  font-size: 1.15rem;
  display: block;
  line-height: 1;
}

.empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
}
.empty h2 { margin-bottom: 0.6rem; }

/* sparkline / bar chart */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 56px; }
.spark span {
  flex: 1;
  min-width: 2px;
  background: var(--ink);
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  transition: background 0.15s;
  transform-origin: bottom;
  animation: growBar 0.5s cubic-bezier(0.2,0.9,0.3,1) backwards;
}
.spark span:hover { background: var(--accent); }
@keyframes growBar { from { transform: scaleY(0); } }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 170px;
  padding: 0.75rem;
  border: var(--rule);
  border-radius: var(--r);
  background: repeating-linear-gradient(
    to top,
    transparent, transparent 33px,
    rgba(20,18,13,0.12) 33px, rgba(20,18,13,0.12) 34px
  );
}
.chart span {
  flex: 1;
  background: var(--ink);
  min-height: 3px;
  border-radius: 2px 2px 0 0;
  position: relative;
  animation: growBar 0.55s cubic-bezier(0.2,0.9,0.3,1) backwards;
  animation-delay: calc(var(--i) * 12ms);
}
.chart span:hover { background: var(--accent); }
.chart span::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -6px);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.2rem 0.4rem;
  border-radius: 2px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 5;
}
.chart span:hover::after { opacity: 1; }

.bars { display: grid; gap: 0.6rem; }
.bar-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 0.75rem; align-items: center; font-size: 0.88rem; }
.bar-row__track { position: relative; height: 22px; background: var(--card-2); border: 1.5px solid var(--ink); border-radius: 2px; overflow: hidden; }
.bar-row__fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); animation: growWide 0.6s cubic-bezier(0.2,0.9,0.3,1) backwards; }
.bar-row__text { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 0.5rem; font-size: 0.76rem; font-weight: 600; mix-blend-mode: normal; }
@keyframes growWide { from { transform: scaleX(0); transform-origin: left; } }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.4rem 0.6rem;
  border-bottom: var(--rule);
}
.table td { padding: 0.55rem 0.6rem; border-bottom: 1px dashed rgba(20,18,13,0.25); }
.table tr:last-child td { border-bottom: 0; }

/* ==========================================================================
   Editor
   ========================================================================== */
.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.8rem;
  align-items: start;
}
@media (max-width: 1040px) { .editor { grid-template-columns: 1fr; } }

.editor__aside { position: sticky; top: 82px; display: grid; gap: 1.2rem; }
@media (max-width: 1040px) { .editor__aside { position: static; } }

/* the permanent-code ticket */
.ticket {
  position: relative;
  background: var(--card);
  border: var(--rule);
  border-radius: var(--r);
  box-shadow: var(--pop);
  overflow: hidden;
}
.ticket__head {
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.ticket__body { padding: 1.1rem; text-align: center; }
.ticket__qr {
  width: 190px;
  margin: 0 auto;
  padding: 10px;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
}
.ticket__qr img { width: 100%; }
.ticket__perf {
  height: 12px;
  background-image: radial-gradient(circle at 6px 6px, var(--paper) 5px, transparent 5.5px);
  background-size: 12px 12px;
  border-block: 1px dashed rgba(20,18,13,0.4);
}
.ticket__url {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  word-break: break-all;
  background: var(--card-2);
  border: 1.5px dashed rgba(20,18,13,0.35);
  border-radius: 3px;
  padding: 0.5rem;
  margin-top: 0.9rem;
  text-align: left;
}
.ticket__foot { padding: 0 1.1rem 1.1rem; display: grid; gap: 0.5rem; }

.links-list { display: grid; gap: 0.75rem; }

.link-item {
  border: var(--rule);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: var(--pop-sm);
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: start;
  padding: 0.7rem 0.8rem;
  transition: box-shadow 0.14s ease, transform 0.14s ease, opacity 0.14s;
}
.link-item.is-dragging { opacity: 0.4; transform: scale(0.99); }
.link-item.is-over { box-shadow: 0 -3px 0 var(--accent), var(--pop-sm); }
.link-item.is-off { background: var(--card-2); opacity: 0.72; }

.link-item__grip {
  cursor: grab;
  padding-top: 0.4rem;
  display: grid;
  grid-template-columns: repeat(2, 3px);
  gap: 3px;
  justify-content: center;
  align-content: start;
  color: var(--ink-soft);
}
.link-item__grip i { width: 3px; height: 3px; background: currentColor; border-radius: 50%; }
.link-item__grip:active { cursor: grabbing; }
.link-item__fields { display: grid; gap: 0.4rem; min-width: 0; }
.link-item__row { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 0.4rem; }
.link-item__actions { display: grid; gap: 0.35rem; justify-items: end; }

.icon-btn {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--card);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.12s, transform 0.09s;
}
.icon-btn:hover { background: var(--accent); color: var(--accent-ink); }
.icon-btn:active { transform: translate(1px, 1px); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 0.6rem; }
.theme-swatch {
  border: var(--rule);
  border-radius: var(--r);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: none;
  text-align: left;
  transition: transform 0.1s, box-shadow 0.1s;
}
.theme-swatch:hover { transform: translate(-1px,-1px); box-shadow: var(--pop-sm); }
.theme-swatch.is-selected { box-shadow: var(--pop-sm); border-color: var(--accent); }
.theme-swatch__preview { height: 46px; padding: 6px; display: grid; gap: 4px; align-content: center; }
.theme-swatch__preview i { display: block; height: 7px; border-radius: 2px; }
.theme-swatch__name {
  display: block;
  padding: 0.28rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-top: 1.5px solid var(--ink);
  background: var(--card);
}

.seg { display: inline-flex; border: var(--rule); border-radius: var(--r); overflow: hidden; }
.seg button {
  padding: 0.42rem 0.85rem;
  background: var(--card);
  border: 0;
  border-right: 1.5px solid var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.seg button:last-child { border-right: 0; }
.seg button.is-active { background: var(--ink); color: var(--paper); }

.savebar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  margin-top: 1.5rem;
  background: var(--ink);
  color: var(--paper);
  border: var(--rule);
  border-radius: var(--r);
  box-shadow: var(--pop-accent);
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.savebar .tag { color: rgba(236,229,214,0.75); }
.savebar .btn { box-shadow: none; border-color: var(--paper); }
.savebar__status { margin-left: auto; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; }
.savebar__status.is-dirty { color: #ffbe6b; }
.savebar__status.is-saved { color: #9be7b6; }
.savebar__status.is-error { color: #ff9d8a; }

.revision-list { display: grid; gap: 0.4rem; max-height: 260px; overflow-y: auto; }
.revision {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border: 1.5px dashed rgba(20,18,13,0.35);
  border-radius: 3px;
  font-size: 0.8rem;
  background: var(--card-2);
}
.revision time { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-soft); }
.revision .btn { margin-left: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 120%);
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--paper);
  box-shadow: var(--pop-accent);
  border-radius: var(--r);
  padding: 0.6rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 200;
  transition: transform 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
  max-width: min(90vw, 520px);
  text-align: center;
}
.toast.is-visible { transform: translate(-50%, 0); }
.toast.is-error { box-shadow: 6px 6px 0 #ff5a3c; }

/* live preview inside editor */
.preview-frame {
  border: var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink);
  padding: 8px;
  box-shadow: var(--pop);
}
.preview-frame iframe {
  width: 100%;
  height: 520px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  display: block;
}

/* ---------- utility ---------- */
.copy-field {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.copy-field input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 0.45rem 0.55rem;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: #fff;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 640px) {
  .topnav { gap: 0.85rem; font-size: 0.82rem; }
  .topnav .btn { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
  .stat { border-right: 0; border-bottom: 1px dashed rgba(20,18,13,0.3); }
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs { border: var(--rule); border-radius: var(--r); background: var(--card); box-shadow: var(--pop); overflow: hidden; }
.tabs__nav { display: flex; border-bottom: var(--rule); }
.tabs__btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--card-2);
  border: 0;
  border-right: 1.5px solid var(--ink);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  transition: background 0.12s ease;
}
.tabs__btn:last-child { border-right: 0; }
.tabs__btn:hover { background: var(--paper); }
.tabs__btn.is-active { background: var(--ink); color: var(--paper); }
.tabs__panel { padding: 0; }
.tabs__panel.is-hidden { display: none; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }

@media (max-width: 640px) {
  .tabs__btn { font-size: 0.82rem; padding: 0.6rem 0.75rem; }
}
