:root {
  --bg: #0c0e14;
  --panel: #161922;
  --panel-2: #1c2030;
  --text: #f2f4fa;
  --muted: #9aa3c0;
  --accent: #ff6b4a;
  --accent-2: #ffb84d;
  --accent-3: #ffd080;
  --ok: #3dd68c;
  --warn: #ffb84d;
  --danger: #ff6b6b;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0,0,0,.4);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
.bg-blobs {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 8% -12%, rgba(255,107,74,.32), transparent 60%),
    radial-gradient(700px 400px at 92% 5%, rgba(255,184,77,.22), transparent 55%),
    radial-gradient(500px 360px at 50% 110%, rgba(255,107,74,.12), transparent 50%),
    var(--bg);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
  background: rgba(12,14,20,.78);
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-icon { border-radius: 8px; }
.brand strong { display: block; font-size: 1.2rem; letter-spacing: -.02em; }
.tagline { display: block; font-size: .78rem; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: .6rem; }
.badge {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .28rem .55rem; border-radius: 999px;
}
.badge.free { background: rgba(255,184,77,.2); color: var(--warn); }
.badge.pro { background: rgba(61,214,140,.2); color: var(--ok); }

.layout {
  display: grid;
  grid-template-columns: 1.35fr .85fr .75fr;
  gap: 1rem;
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}
.panel {
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 .9rem;
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
}
.panel h3 {
  margin: 0 0 .5rem;
  font-size: .88rem;
  color: var(--text);
}

.drop-panel {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  outline: none;
  padding: 0;
  overflow: hidden;
}
.drop-panel.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,107,74,.45), var(--shadow);
}
.drop-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .5rem;
  padding: 2rem 1.5rem;
}
.drop-icon { font-size: 2.5rem; }
.drop-inner h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.drop-inner p { margin: 0; color: var(--muted); max-width: 32ch; font-size: .95rem; }

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background:
    linear-gradient(45deg, #12151f 25%, transparent 25%),
    linear-gradient(-45deg, #12151f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #12151f 75%),
    linear-gradient(-45deg, transparent 75%, #12151f 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #0a0b10;
  min-height: 420px;
  padding: .75rem;
}
.canvas-wrap[hidden], .drop-inner[hidden] { display: none !important; }
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}
.viewer[hidden] { display: none !important; }
.page-nav {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  padding: .55rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.25);
  font-size: .9rem;
}
.btn.sm { padding: .35rem .7rem; font-size: .82rem; }
.canvas-wrap {
  position: relative;
}
#pageCanvas, #drawCanvas {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 720px);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
#drawCanvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  touch-action: none;
  max-width: 100%;
  max-height: min(70vh, 720px);
}
.page-list {
  list-style: none; margin: .5rem 0 0; padding: 0;
  font-size: .85rem; color: var(--muted);
}
.page-list li {
  padding: .3rem 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.page-list li.has-redact { color: var(--accent-2); font-weight: 650; }
.page-list li button {
  background: none; border: none; color: inherit; cursor: pointer;
  font: inherit; padding: 0; text-align: left; width: 100%;
}
.info-panel h3 {
  margin: 1rem 0 .35rem;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.tool-row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.tool-btn {
  flex: 1;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35);
  color: var(--text);
  border-radius: 10px;
  padding: .55rem .7rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.tool-btn.active {
  border-color: var(--accent);
  background: rgba(255,107,74,.22);
  box-shadow: 0 0 0 2px rgba(255,107,74,.25);
}
.mode-hint { margin: 0 0 1rem; font-size: .8rem; color: var(--muted); }

.free-note {
  background: rgba(255,184,77,.1);
  border: 1px solid rgba(255,184,77,.25);
  border-radius: 12px;
  padding: .75rem .85rem;
  font-size: .85rem;
  color: #f0d9a8;
  margin-bottom: 1rem;
}
.free-note strong { color: var(--warn); }
.free-note[hidden] { display: none !important; }
.linkish {
  background: none; border: none; color: var(--accent-3);
  cursor: pointer; font: inherit; font-weight: 600; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
}
.free-note .linkish { display: inline; margin-left: .25rem; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.btn {
  border: none; cursor: pointer; font: inherit; font-weight: 650;
  border-radius: 999px; padding: .55rem 1rem;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
a.btn {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; box-sizing: border-box;
}
.btn.ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.1);
}
.btn.wide { flex: 1 1 140px; }

.suggestions {
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: .75rem;
  margin-bottom: 1rem;
  max-height: 220px;
  overflow: auto;
}
.suggestions[hidden] { display: none !important; }
.suggestions ul { list-style: none; margin: 0; padding: 0; }
.suggestions li {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .45rem 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: .85rem;
}
.suggestions li:last-child { border-bottom: none; }
.suggest-label {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
}
.suggest-kind {
  font-size: .65rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent-2); font-weight: 700; margin-right: .35rem;
}
.privacy { margin: 0; font-size: .8rem; color: var(--muted); text-align: center; }

.how-list {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: .9rem;
}
.how-list li { margin-bottom: .35rem; }
.how-list code {
  background: rgba(0,0,0,.35);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .85em;
}
.meta-box {
  background: rgba(0,0,0,.3);
  border-radius: 10px;
  padding: .75rem;
  margin-bottom: .85rem;
}
.preview-meta { margin: 0; font-size: .82rem; color: var(--muted); }
.warn-box {
  margin: 0;
  font-size: .82rem;
  color: #f0d9a8;
  background: rgba(255,184,77,.08);
  border: 1px solid rgba(255,184,77,.2);
  border-radius: 10px;
  padding: .65rem .75rem;
}

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .85rem; }
.field span { font-size: .82rem; color: var(--muted); }
input[type="text"] {
  appearance: none;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  border-radius: 10px;
  padding: .55rem .7rem;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,107,74,.25);
}

.footer {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: .75rem 1.25rem;
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: .85rem;
}

.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5,7,16,.75);
  display: grid; place-items: center;
  padding: 1rem;
}
.modal-card {
  width: min(420px, 100%);
  background: linear-gradient(165deg, #23263a, #161922);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 1.4rem 1.35rem 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
}
.modal-close {
  position: absolute; top: .6rem; right: .75rem;
  background: none; border: none; color: var(--muted);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-card h2 { margin: 0 0 .4rem; font-size: 1.35rem; }
.modal-lead { margin: 0 0 .85rem; color: var(--muted); font-size: .95rem; }
.perk-list { margin: 0 0 1rem; padding-left: 1.1rem; color: var(--text); font-size: .9rem; }
.perk-list li { margin-bottom: .25rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.hint { color: var(--danger); font-size: .85rem; margin: -.4rem 0 .6rem; }
.tiny { margin: 0; font-size: .75rem; color: var(--muted); }

/* Free-tier ads */
.ad-region {
  position: relative;
  background: repeating-linear-gradient(
    -45deg, #ffe566, #ffe566 12px, #ffd000 12px, #ffd000 24px
  );
  color: #111;
  border: 3px solid #111;
  border-radius: 10px;
  padding: 0.65rem 0.85rem 0.65rem 2.6rem;
  margin: 0.5rem 0;
  box-shadow: 4px 4px 0 #111;
  font-size: 0.88rem;
  line-height: 1.35;
  font-weight: 650;
}
.ad-region[hidden] { display: none !important; }
.ad-label {
  position: absolute; left: 0.4rem; top: 0.4rem;
  background: #111; color: #ffe566;
  font-size: 0.65rem; font-weight: 800;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.2rem 0.4rem; border-radius: 4px;
}
.ad-inner { color: #111; }
.ad-inner strong { font-weight: 800; }
.ad-sticky-top {
  position: sticky; top: 0; z-index: 20;
  margin: 0; border-radius: 0;
  border-left: none; border-right: none; border-top: none;
  box-shadow: 0 4px 0 #111;
}
.ad-wrap-mid, .ad-wrap-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.ad-download { margin: 0 0 0.85rem; }
.ad-footer { margin-bottom: 0.5rem; }
.ad-region .adsbygoogle {
  display: block; min-height: 60px; background: transparent;
}

.cross-promo {
  flex-basis: 100%;
  text-align: center;
  margin: .35rem 0 0;
  padding: .65rem .75rem .15rem;
  border-top: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  font-size: .8rem;
  color: var(--muted);
}
.cross-promo-intro { margin: 0 0 .35rem; }
.cross-promo-hub { margin: 0 0 .35rem; }
.cross-promo-hub a, .cross-promo-list a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.cross-promo-hub a:hover, .cross-promo-list a:hover { color: var(--text); }
.cross-promo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.cross-promo-list .cross-buy { font-weight: 600; color: var(--accent, var(--text)); }

/* Louder Unlock / Buy CTAs (conversion) */
.btn.unlock-cta {
  font-weight: 800;
  font-size: 0.98rem;
  min-height: 44px;
  padding: 0.7rem 1.15rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.12) inset;
  letter-spacing: 0.01em;
}
.top-actions .btn.unlock-cta {
  white-space: nowrap;
}
.free-note-cta {
  display: flex;
  margin-top: 0.65rem;
}
.free-note-cta .btn.unlock-cta {
  width: 100%;
}
.unlock-inline {
  margin-bottom: 0.55rem;
}
.unlock-inline[hidden] { display: none !important; }
.soft-path {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-unlock-btn,
.footer-buy-btn {
  text-decoration: none;
}
.footer .btn.unlock-cta {
  min-height: 44px;
}

/* Unlock modal mobile */
.modal {
  align-items: end;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}
@media (min-width: 520px) {
  .modal { align-items: center; place-items: center; }
}
.modal-card {
  max-height: min(92vh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  width: min(420px, 100%);
  margin-bottom: 0;
}
.modal-card #buyBtn,
.modal-card #applyKeyBtn {
  min-height: 48px;
  width: 100%;
}
.modal-card input[type="text"] {
  min-height: 44px;
  font-size: 16px; /* avoid iOS zoom */
  width: 100%;
}
.modal-close {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
}

/* Slim sticky Unlock bar (free tier only) */
.sticky-unlock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
  background: rgba(12,14,20,.94);
  border-top: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 -8px 28px rgba(0,0,0,.35);
}
.sticky-unlock[hidden] { display: none !important; }
.sticky-unlock-copy {
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}
.sticky-unlock .btn.unlock-cta {
  flex-shrink: 0;
  min-height: 44px;
}
body.has-sticky-unlock {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
@media (max-width: 420px) {
  .topbar { padding: 0.75rem 0.85rem; gap: 0.5rem; }
  .tagline { display: none; }
  .sticky-unlock-copy { font-size: 0.75rem; }
}
