:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --secondary: #f1f5f9;
  --primary: #2563eb;
  --primary-fg: #ffffff;
  --accent: #eff6ff;
  --destructive: #ef4444;
  --radius: 0.7rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
.font-display, .logo, h3 { font-family: "Sora", sans-serif; }
.accent { color: var(--primary); }
.spacer { flex: 1; }
.divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* ---------- header ---------- */
.site-header {
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--border);
}
.logo { display: inline-flex; align-items: center; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; color: var(--fg); font-size: 16px; }
.logo-mark { display: inline-grid; place-items: center; height: 28px; width: 28px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 13px; margin-right: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.header-file { font-size: 13px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: var(--primary-fg); border: none;
  border-radius: 999px; padding: 8px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: filter .15s, transform .1s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: none; border: 1px solid var(--border); border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 600; color: var(--fg); cursor: pointer; }
.btn-ghost:hover { background: var(--secondary); }
.btn-soft { flex: 1; display: inline-flex; align-items: center; justify-content: center; background: var(--secondary); border: none; border-radius: 10px; padding: 8px 12px; font-size: 12px; font-weight: 500; cursor: pointer; }
.btn-soft:hover:not(:disabled) { background: var(--accent); }
.btn-soft:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn {
  display: grid; place-items: center; height: 34px; min-width: 34px; padding: 0 6px;
  border: none; background: none; border-radius: 8px; color: var(--muted);
  font-size: 17px; cursor: pointer; transition: background .12s, color .12s;
}
.icon-btn:hover:not(:disabled) { background: var(--secondary); color: var(--fg); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.icon-btn.active { background: rgba(37,99,235,.14); color: var(--primary); }

/* ========================================================
   LANDING PAGE STYLES
   ======================================================== */

/* --- nav --- */
.lp-nav {
  position: sticky; top: 0; z-index: 100;
  height: 60px; display: flex; align-items: center; gap: 20px;
  padding: 0 32px; background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.lp-logo { display: inline-flex; align-items: center; gap: 8px; font-family: "Sora", sans-serif; font-weight: 800; font-size: 16px; text-decoration: none; color: var(--fg); letter-spacing: -0.02em; }
.lp-logo-mark { display: inline-grid; place-items: center; height: 30px; width: 30px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; box-shadow: 0 2px 6px rgba(37,99,235,.35); }
.lp-nav-links { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.lp-nav-links a { font-size: 14px; font-weight: 500; text-decoration: none; color: var(--muted); transition: color .15s; }
.lp-nav-links a:hover { color: var(--fg); }
.lp-open-app { margin-left: 16px; padding: 8px 20px; font-size: 14px; }

/* --- hero --- */
.lp-hero {
  background: linear-gradient(160deg, #f0f6ff 0%, #f8fafc 60%);
  padding: 56px 32px 64px;
}
.lp-hero-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 60px;
}
.lp-hero-copy { flex: 1; min-width: 0; }
.lp-hero-media { flex-shrink: 0; width: 42%; max-width: 480px; }
.lp-mockup { width: 100%; border-radius: 16px; box-shadow: 0 24px 60px rgba(2,6,23,.18); border: 1px solid var(--border); }

.lp-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 500; color: var(--primary);
  background: rgba(37,99,235,.08); border: 1px solid rgba(37,99,235,.2);
  border-radius: 999px; padding: 5px 14px; margin-bottom: 20px;
}
.lp-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

.lp-headline {
  font-family: "Sora", sans-serif; font-weight: 800;
  font-size: clamp(30px, 4vw, 48px); line-height: 1.12;
  letter-spacing: -0.03em; color: var(--fg); margin: 0 0 20px;
}
.lp-sub { font-size: 16px; line-height: 1.65; color: var(--muted); margin: 0 0 28px; max-width: 480px; }
.lp-hl { font-weight: 600; }
.hl-yellow { color: #b45309; background: #fef3c7; padding: 1px 4px; border-radius: 3px; }
.hl-blue   { color: #1d4ed8; background: #dbeafe; padding: 1px 4px; border-radius: 3px; }
.hl-green  { color: #15803d; background: #dcfce7; padding: 1px 4px; border-radius: 3px; }
.hl-orange { color: #c2410c; background: #ffedd5; padding: 1px 4px; border-radius: 3px; }

.lp-upload-row { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; }
.lp-drop-zone {
  flex: 1; min-width: 200px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: #fff;
  border: 2px dashed var(--border); border-radius: 12px;
  cursor: pointer; color: var(--fg); transition: border-color .15s, background .15s;
}
.lp-drop-zone:hover, .lp-drop-zone.drag-over { border-color: var(--primary); background: rgba(37,99,235,.03); }
.lp-drop-zone svg { flex-shrink: 0; color: var(--muted); }
.lp-drop-zone strong { font-size: 14px; font-weight: 600; display: block; }
.lp-drop-zone small { font-size: 12px; color: var(--muted); }
.lp-choose-btn { padding: 14px 24px; font-size: 15px; align-self: center; flex-shrink: 0; border-radius: 12px; }

/* --- tools section --- */
.lp-section { padding: 72px 32px; }
.lp-tools-section { background: #f1f5f9; }
.lp-features-section { background: #f1f5f9; border-top: 1px solid var(--border); }
.lp-section-inner { max-width: 960px; margin: 0 auto; }
.lp-section-title { font-family: "Sora", sans-serif; font-size: clamp(22px, 3vw, 30px); font-weight: 700; letter-spacing: -0.02em; text-align: center; margin: 0 0 8px; color: var(--fg); }
.lp-section-sub { font-size: 15px; color: var(--muted); text-align: center; margin: 0 0 40px; }

.lp-tools-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.lp-tool-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 500; color: var(--fg); text-align: center;
  transition: box-shadow .15s;
}
.lp-tool-card:hover { box-shadow: 0 4px 16px rgba(2,6,23,.08); }
.lp-tool-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(37,99,235,.08); display: flex; align-items: center; justify-content: center;
}
.lp-tool-icon svg { width: 20px; height: 20px; stroke: var(--primary); }

/* --- smart features --- */
.lp-features-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.lp-feat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 20px; display: flex; align-items: flex-start; gap: 14px;
}
.lp-feat-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: rgba(37,99,235,.08); display: flex; align-items: center; justify-content: center;
}
.lp-feat-icon svg { width: 20px; height: 20px; stroke: var(--primary); }
.lp-feat-title { font-family: "Sora", sans-serif; font-size: 15px; font-weight: 700; margin: 0 0 6px; color: var(--fg); }
.lp-feat-desc { font-size: 13px; line-height: 1.55; color: var(--muted); margin: 0; }

/* --- privacy CTA --- */
.lp-privacy-section { background: #fff; border-top: 1px solid var(--border); padding: 80px 32px; }
.lp-privacy-inner { max-width: 600px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.lp-privacy-icon { width: 52px; height: 52px; border-radius: 14px; background: rgba(37,99,235,.08); display: flex; align-items: center; justify-content: center; }
.lp-privacy-icon svg { width: 26px; height: 26px; stroke: var(--primary); }
.lp-privacy-title { font-family: "Sora", sans-serif; font-size: clamp(22px, 3vw, 32px); font-weight: 800; letter-spacing: -0.02em; margin: 0; color: var(--fg); line-height: 1.2; }
.lp-privacy-sub { font-size: 15px; line-height: 1.65; color: var(--muted); margin: 0; }
.lp-cta-btn { padding: 14px 32px; font-size: 16px; border-radius: 12px; margin-top: 8px; }

/* --- landing footer --- */
.lp-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 24px 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.lp-footer-logo { font-family: "Sora", sans-serif; font-weight: 700; color: var(--fg); font-size: 14px; }
.lp-footer-note { font-size: 13px; }

/* --- LP top adsense --- */
.adsense-lp-top {
  margin: 12px auto; width: calc(100% - 64px); max-width: 970px; height: 90px;
  display: block;
}

/* --- app page adsense-middle --- */
.adsense-middle { width: 300px; height: 600px; align-self: flex-start; flex-shrink: 0; margin-top: 0; }

/* --- responsive landing --- */
@media (max-width: 860px) {
  .lp-hero-inner { flex-direction: column; gap: 32px; }
  .lp-hero-media { width: 100%; max-width: 100%; }
  .lp-tools-grid { grid-template-columns: repeat(2, 1fr); }
  .lp-features-grid { grid-template-columns: 1fr; }
  .lp-nav-links { display: none; }
  .adsense-middle { display: none; }
}
@media (max-width: 480px) {
  .lp-nav { padding: 0 16px; }
  .lp-hero { padding: 36px 16px 40px; }
  .lp-section { padding: 48px 16px; }
  .lp-upload-row { flex-direction: column; }
  .lp-choose-btn { width: 100%; }
  .adsense-lp-top { width: calc(100% - 32px); }
}

/* ---- legacy .landing-hero kept for reference (hidden) ---- */

/* ---------- AdSense placeholders ---------- */
.adsense-zone {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #b6c2d4;
  background: #e9eef5;
  display: block;
}
.adsense-zone .ad-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.adsense-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.65);
  pointer-events: none;
  background: rgba(0,0,0,0.12);
}
.adsense-top { margin: 14px auto; width: calc(100% - 32px); max-width: 970px; height: 90px; }
.adsense-bottom { margin: 14px auto 24px; width: calc(100% - 32px); max-width: 970px; height: 90px; }
.adsense-right { width: 300px; height: 250px; align-self: flex-start; margin-top: 0; flex-shrink: 0; }

/* ---------- page body ---------- */
.page-body { display: flex; gap: 16px; padding: 0 16px; align-items: stretch; }
.editor-shell {
  flex: 1; min-width: 0; display: flex; height: 78vh; min-height: 520px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}

/* ---------- toolbar ---------- */
.toolbar { width: 56px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0; background: var(--card); border-right: 1px solid var(--border); overflow-y: auto; }
.tool-btn { display: grid; place-items: center; height: 40px; width: 40px; border: none; background: none; border-radius: 10px; color: var(--muted); cursor: pointer; transition: background .12s, color .12s; }
.tool-btn:hover { background: var(--secondary); color: var(--fg); }
.tool-btn.active { background: var(--primary); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tool-btn svg { width: 18px; height: 18px; }
.tool-sep { height: 1px; width: 32px; background: var(--border); margin: 4px 0; }
.tool-btn.danger:hover { background: rgba(239,68,68,.1); color: var(--destructive); }

/* ---------- thumbnails ---------- */
.thumbs { width: 160px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; display: none; }
.thumbs.open { display: block; }
.thumb { position: relative; margin-bottom: 8px; }
.thumb button.thumb-btn { display: block; width: 100%; padding: 0; border: 2px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; cursor: pointer; }
.thumb button.thumb-btn.active { border-color: var(--primary); }
.thumb canvas { width: 100%; display: block; }
.thumb-num { position: absolute; top: 4px; left: 4px; font-size: 10px; padding: 0 5px; border-radius: 4px; background: rgba(255,255,255,.85); border: 1px solid var(--border); }
.thumb-bm { position: absolute; top: 3px; right: 3px; border: none; background: none; cursor: pointer; font-size: 13px; color: var(--muted); padding: 2px; }
.thumb-bm.active { color: var(--primary); }

/* ---------- center ---------- */
.center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.context-bar, .toolbar-top { height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 1px solid var(--border); background: rgba(248,250,252,.6); }
.ctx-label { font-size: 12px; color: var(--muted); }
.swatches { display: flex; gap: 6px; align-items: center; }
.swatch { height: 20px; width: 20px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--fg); transform: scale(1.1); }
.ctx-count { font-size: 12px; color: var(--muted); }
.zoom-val { font-size: 12px; width: 42px; text-align: center; }

/* ---------- workspace ---------- */
.workspace { flex: 1; overflow: auto; padding: 24px; background: #eef2f8; position: relative; }
.workspace.dark { background: #0f172a; }
.workspace.dark canvas.pdf-page { filter: invert(0.92) hue-rotate(180deg); }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.empty-state.hidden { display: none; }
.empty-icon { display: grid; place-items: center; height: 52px; width: 52px; border-radius: 12px; background: var(--secondary); color: var(--muted); font-weight: 700; font-size: 14px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.page-wrap { position: relative; background: #fff; box-shadow: 0 10px 30px rgba(2,6,23,.18); }
.page-wrap canvas.pdf-page { display: block; }
.page-wrap svg.overlay { position: absolute; inset: 0; touch-action: none; }
.html-anno { position: absolute; }
.html-anno.selected { outline: 2px solid var(--primary); border-radius: 4px; }
.note-box { height: 100%; width: 100%; border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,.12); display: flex; flex-direction: column; overflow: hidden; background: #fef3c7; border: 1px solid #f59e0b; }
.note-grip { height: 16px; flex-shrink: 0; background: #fde68a; cursor: move; }
.note-box textarea { flex: 1; width: 100%; resize: none; background: transparent; border: none; outline: none; padding: 6px; color: #78350f; }
.note-box textarea::placeholder { color: #b4884a; }
.text-anno { outline: none; white-space: pre; padding: 0 2px; min-width: 20px; font-family: "Inter", sans-serif; }
.text-anno:empty:before { content: "Text"; color: #9ca3af; }

/* ---------- notes panel ---------- */
.notes-panel { width: 288px; flex-shrink: 0; background: var(--card); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.notes-panel.closed { display: none; }
.np-block { padding: 12px; border-bottom: 1px solid var(--border); }
.np-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.np-sub { margin: 0 0 8px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.layer-btn { text-transform: capitalize; font-size: 12px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--secondary); color: var(--muted); cursor: pointer; }
.layer-btn.on { background: rgba(37,99,235,.1); border-color: rgba(37,99,235,.4); color: var(--primary); }
.np-actions { display: flex; gap: 8px; }
.np-list { flex: 1; overflow-y: auto; padding: 12px; }
.note-item { width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: none; cursor: pointer; }
.note-item.active { border-color: var(--primary); background: rgba(37,99,235,.05); }
.note-item .ni-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: capitalize; }
.note-item .ni-text { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-empty { font-size: 14px; color: var(--muted); text-align: center; padding: 24px 0; }
.bm-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.bm-chip { font-size: 12px; padding: 4px 8px; border-radius: 8px; background: var(--secondary); border: none; cursor: pointer; }
.bm-chip:hover { background: var(--accent); }

/* ---------- footer ---------- */
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; font-family: "Sora", sans-serif; font-weight: 600; }
.foot-note { font-weight: 400; }

/* ---------- signature modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0,0,0,.5); padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3); width: 100%; max-width: 520px; padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.sig-canvas { width: 100%; aspect-ratio: 520/200; border-radius: 12px; border: 2px dashed var(--border); background: var(--bg); touch-action: none; cursor: crosshair; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.sig-hint { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 40; background: var(--primary); color: #fff; border-radius: 999px; padding: 8px 20px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 20px rgba(0,0,0,.2); }

.handle { cursor: nwse-resize; }

@media (max-width: 860px) {
  .thumbs { display: none !important; }
  .notes-panel { display: none; }
  .adsense-right { display: none; }
  .editor-shell { height: 70vh; }
}
