/* =========================================================
   Open Sign V2 — Less interface. More experience.
   ========================================================= */

@font-face {
  font-family: "Metropolis";
  src: url("./metropolis/Metropolis-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Metropolis";
  src: url("./metropolis/Metropolis-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #faf8f5;
  --surface: #ffffff;
  --stage: #efece6;
  --ink: #141413;
  --muted: #66635c;
  --line: rgba(20, 20, 19, 0.11);
  --line-strong: rgba(20, 20, 19, 0.24);
  --accent: #1652f0;
  --accent-hover: #1143c7;
  --accent-soft: rgba(22, 82, 240, 0.08);
  --on-accent: #ffffff;
  --danger: #d12c2c;
  --font: "Plus Jakarta Sans", "Metropolis", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 68px;
}

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

[hidden] {
  display: none !important;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.35s var(--ease);
}

body[data-view="editor"] {
  background: var(--stage);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

::selection {
  background: rgba(22, 82, 240, 0.18);
}

[tabindex="-1"]:focus {
  outline: none;
}

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

body:has(#fileInput:focus-visible) .dropzone {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 clamp(20px, 4vw, 48px);
  background: rgba(250, 248, 245, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background-color 0.3s;
}

body[data-view="editor"] .site-header {
  background: rgba(239, 236, 230, 0.88);
  border-bottom-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.025em;
}

.doc-meta {
  display: none;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.doc-sep {
  color: var(--line-strong);
}

.doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.doc-pages {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
}

body[data-view="editor"] .doc-meta {
  display: flex;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.github-link svg {
  width: 15px;
  height: 15px;
}

.github-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--surface);
}

body[data-view="editor"] .github-link {
  display: none;
}

body:not([data-view="editor"]) #downloadBtn {
  display: none;
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.16s var(--ease), background-color 0.2s, border-color 0.2s, color 0.2s;
}

.btn:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn.ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.full-w {
  width: 100%;
  min-height: 44px;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}

#downloadBtn .dl-check {
  display: none;
}

#downloadBtn[data-state="done"] .dl-arrow {
  display: none;
}

#downloadBtn[data-state="done"] .dl-check {
  display: block;
}

#downloadBtn .dl-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

#downloadBtn[data-state="done"] .dl-check path {
  animation: draw 0.45s var(--ease) forwards;
}

#downloadBtn[data-state="busy"] {
  opacity: 0.85;
  cursor: progress;
}

#downloadBtn[data-state="busy"] .dl-arrow {
  animation: nudge 0.9s ease-in-out infinite;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ---------- Views ---------- */
main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.view.enter {
  animation: view-in 0.45s var(--ease) both;
}

/* ---------- Homepage ---------- */
.home {
  width: min(860px, 100%);
  margin: auto;
  padding: clamp(24px, 5vh, 56px) clamp(20px, 4vw, 40px) clamp(36px, 6vh, 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(32px, 5vh, 48px);
}

.hero-copy {
  text-align: center;
}

.hero-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(38px, 6.4vw, 68px);
  line-height: 1.04;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.accent-word {
  color: var(--ink);
}

.accent-dot {
  color: var(--accent);
}

.hero-sub {
  max-width: 46ch;
  margin: 16px auto 0;
  color: var(--muted);
  font-size: clamp(16px, 1.5vw, 19px);
  font-weight: 400;
  line-height: 1.55;
}

/* Minimal Architectural Upload Canvas */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 310px;
  padding: 40px 28px 26px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: border-color 0.3s var(--ease), background-color 0.3s var(--ease), transform 0.35s var(--ease);
}

.dz-frame {
  position: absolute;
  inset: -1px;
  pointer-events: none;
}

.dz-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 0 solid var(--ink);
  transition: width 0.35s var(--ease), height 0.35s var(--ease), border-color 0.25s;
}

.dz-corner.tl { top: 0; left: 0; border-top-width: 1.5px; border-left-width: 1.5px; }
.dz-corner.tr { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.dz-corner.bl { bottom: 0; left: 0; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.dz-corner.br { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }

.dz-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 12px 0 24px;
}

.dz-morph {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: transform 0.35s var(--ease), color 0.25s;
}

.dz-morph svg {
  width: 44px;
  height: 44px;
}

.dz-arrow {
  transition: transform 0.35s var(--ease);
}

.dz-prompt {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dz-prompt .when-over {
  display: none;
  color: var(--accent);
}

.dz-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s, transform 0.16s var(--ease);
}

.dz-action svg {
  width: 16px;
  height: 16px;
}

.dz-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sign-mark {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  color: var(--muted);
}

.sign-mark svg {
  width: 12px;
  height: 12px;
  margin-bottom: -4px;
}

.sign-mark .rule {
  flex: 1;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.3s;
}

.dz-privacy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dz-privacy svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

/* Hover, Drag-Over & Morph Reaction */
.dropzone:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.dropzone:hover .dz-corner,
.dropzone.is-over .dz-corner {
  width: 28px;
  height: 28px;
  border-color: var(--accent);
}

.dropzone:hover .dz-morph,
.dropzone.is-over .dz-morph {
  color: var(--accent);
}

.dropzone:hover .dz-arrow {
  transform: translateY(-3px);
}

.dropzone:hover .dz-action {
  background: var(--accent-hover);
}

.dropzone.is-over {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: scale(1.008);
}

.dropzone.is-over .dz-arrow {
  transform: translateY(-5px);
}

.dropzone.is-over .when-idle {
  display: none;
}

.dropzone.is-over .when-over {
  display: inline;
}

.dropzone.is-reacting {
  transform: scale(0.985);
  border-color: var(--accent);
  background: var(--surface);
}

.dropzone.is-reacting .dz-morph {
  transform: scale(1.12);
  color: var(--accent);
}

/* ---------- Processing & Document Scan Animation ---------- */
.process {
  flex: 1;
  min-height: calc(100dvh - var(--header-h));
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.doc-stage {
  width: 176px;
  height: 228px;
  margin-bottom: 22px;
  perspective: 900px;
}

.sheet {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 20px 20px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 20px 44px -26px rgba(20, 20, 19, 0.25);
  transform-origin: top center;
  animation: sheet-unfold 0.65s var(--ease) both;
}

.sheet-fold {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(225deg, var(--bg) 48%, var(--line) 49%, var(--surface) 52%);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-head .badge {
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sheet-body {
  display: grid;
  gap: 10px;
}

.sheet .ln {
  display: block;
  height: 5px;
  border-radius: 2px;
  background: #e5e2da;
}

.sheet .ln.short {
  width: 44px;
  background: #d5d1c7;
}

.sheet .ln.gap {
  margin-top: 8px;
}

.sheet-sign {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-top: 6px;
}

.sheet-sign .x-mark {
  font-size: 11px;
  line-height: 1;
  color: var(--accent);
  font-weight: 700;
}

.sheet-sign .sig-line {
  flex: 1;
  height: 1px;
  background: var(--line-strong);
}

.scan-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 16px 3px rgba(22, 82, 240, 0.45);
  animation: scan-sweep 1.5s ease-in-out 0.25s infinite alternate;
}

.process-status {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.process-status.swap {
  animation: status-swap 0.32s var(--ease);
}

.process-detail {
  margin: 0;
  max-width: min(380px, 82vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
}

/* ---------- PDF Editor ---------- */
.editor {
  padding: 28px clamp(12px, 3vw, 32px) 136px;
}

#pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  min-width: 0;
}

.page {
  position: relative;
  flex: none;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(20, 20, 19, 0.04), 0 20px 44px -26px rgba(20, 20, 19, 0.24);
  scroll-margin-top: 88px;
}

.page canvas.render {
  display: block;
  width: 100%;
  height: 100%;
}

.page.placing {
  cursor: crosshair;
  outline: 1.5px dashed var(--accent);
  outline-offset: 6px;
}

/* Placed Elements */
.item {
  position: absolute;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: 1px dashed transparent;
  animation: pop-in 0.24s var(--ease);
  transition: outline-color 0.15s, box-shadow 0.2s, opacity 0.16s, transform 0.16s;
}

.item:hover {
  outline-color: rgba(22, 82, 240, 0.5);
}

.item:active {
  cursor: grabbing;
}

.item.selected {
  outline: 1.5px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 82, 240, 0.12);
}

.item.leaving {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.item .txt {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 4px;
  font-family: Helvetica, Arial, sans-serif;
  color: #000000;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
}

.item .txt:focus {
  cursor: text;
  background: rgba(22, 82, 240, 0.06);
}

.item .del,
.item .rz {
  position: absolute;
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  transition: opacity 0.16s, transform 0.2s var(--ease);
}

.item.selected .del,
.item.selected .rz {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.item .del {
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  line-height: 1;
}

.item .del:hover {
  background: var(--danger);
}

.item .rz {
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border: 2px solid #ffffff;
  border-radius: 3px;
  background: var(--accent);
  cursor: nwse-resize;
}

.item .rz::after {
  content: "";
  position: absolute;
  inset: -10px;
}

@media (pointer: coarse) {
  .item .rz {
    width: 20px;
    height: 20px;
    right: -10px;
    bottom: -10px;
  }
  .item .del {
    width: 28px;
    height: 28px;
    top: -14px;
    right: -14px;
  }
}

/* Floating Compact Toolbar */
body:not([data-view="editor"]) .dock,
body:not([data-view="editor"]) .pager,
body:not([data-view="editor"]) .hint {
  display: none;
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  width: max-content;
  max-width: calc(100vw - 16px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px -14px rgba(20, 20, 19, 0.22);
  animation: dock-in 0.45s var(--ease) both;
}

.dock-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--line);
}

.tool {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s, transform 0.14s var(--ease);
}

.tool svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.tool:hover:not(:disabled) {
  background: var(--accent-soft);
}

.tool:active:not(:disabled) {
  transform: scale(0.96);
}

.tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tool.armed {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 4px 12px -4px rgba(22, 82, 240, 0.55);
}

.tool.armed:hover:not(:disabled) {
  background: var(--accent-hover);
}

.tool.danger {
  color: var(--danger);
}

.tool.danger:hover:not(:disabled) {
  background: rgba(209, 44, 44, 0.1);
}

.sig-thumb {
  width: 32px;
  height: 20px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.tool.has-sig .ic-place {
  display: none;
}

.hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 64px);
  z-index: 29;
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  animation: hint-in 0.25s var(--ease);
}

.hint:empty {
  display: none;
}

.pager {
  position: fixed;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pager span {
  min-width: 52px;
  text-align: center;
}

.pager button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  transition: background-color 0.2s;
}

.pager button:hover:not(:disabled) {
  background: var(--accent-soft);
}

.pager button:disabled {
  opacity: 0.3;
  cursor: default;
}

.pager svg {
  width: 17px;
  height: 17px;
}

.toast {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--header-h) + 12px);
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.3s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast[data-kind="error"] {
  box-shadow: inset 3px 0 0 var(--danger);
}

/* ---------- Modals ---------- */
dialog {
  width: min(620px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 26px 28px 24px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 32px 80px -24px rgba(20, 20, 19, 0.32);
}

dialog.small {
  width: min(420px, calc(100vw - 24px));
}

dialog.center-dlg {
  text-align: center;
  padding: 32px 28px 26px;
}

dialog[open] {
  animation: dlg-in 0.3s var(--ease);
}

dialog.closing {
  animation: dlg-out 0.18s ease forwards;
}

dialog::backdrop {
  background: rgba(20, 20, 19, 0.38);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s;
}

dialog.closing::backdrop {
  animation: fade-out 0.18s forwards;
}

dialog h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.dlg-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dlg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.dlg-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Signature Tabs & Preview */
.tabs {
  display: flex;
  gap: 24px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  position: relative;
  padding: 8px 0 11px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: color 0.2s;
}

.tabs button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.25s var(--ease);
}

.tabs button:hover,
.tabs button.active {
  color: var(--ink);
}

.tabs button.active::after {
  transform: scaleX(1);
}

.hidden {
  display: none;
}

.tab > * + * {
  margin-top: 12px;
}

.pad-wrap {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.pad-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 1;
  touch-action: none;
  cursor: crosshair;
}

.pad-wrap.guide::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 24%;
  border-bottom: 1px solid var(--line-strong);
  pointer-events: none;
}

.pad-wrap.guide::before {
  content: "\2715";
  position: absolute;
  left: 3%;
  bottom: calc(24% - 9px);
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.pad-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#typedName {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#typedName:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.fonts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.font-opt {
  height: 48px;
  padding: 0 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 24px;
  line-height: 48px;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: border-color 0.2s, background-color 0.2s;
}

.font-opt:hover {
  border-color: var(--line-strong);
}

.font-opt[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-drop {
  display: grid;
  gap: 4px;
  padding: 20px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.file-drop strong {
  font-size: 14px;
}

.file-drop span {
  color: var(--muted);
  font-size: 13px;
}

.file-drop:hover,
.file-drop:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dlg-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
}

.dlg-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.dlg-actions.stacked {
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

/* Download Success Badge */
.success-badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
}

.success-badge svg {
  width: 100%;
  height: 100%;
}

.ring-anim {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.6s var(--ease) forwards;
}

.check-anim {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.4s var(--ease) 0.25s forwards;
}

.link.subtle-link {
  padding: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link.subtle-link:hover {
  color: var(--ink);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  :root {
    --header-h: 60px;
  }

  .site-header {
    gap: 10px;
  }

  body[data-view="editor"] .brand-name {
    display: none;
  }

  .dropzone {
    min-height: 270px;
    padding: 32px 18px 22px;
  }

  .dz-action {
    width: 100%;
    justify-content: center;
  }

  .editor {
    padding-bottom: 124px;
  }

  .dock {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    bottom: max(10px, env(safe-area-inset-bottom));
    justify-content: space-between;
    padding: 5px;
  }

  .dock-sep {
    display: none;
  }

  .tool {
    flex: 1;
    min-width: 0;
    height: 52px;
    flex-direction: column;
    gap: 4px;
    padding: 0 4px;
    font-size: 11px;
  }

  .hint {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 70px);
  }

  .pager {
    right: 8px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 70px);
  }

  .hint:not(:empty) ~ .pager {
    display: none;
  }

  dialog {
    padding: 20px 18px 18px;
  }

  .font-opt {
    font-size: 20px;
  }
}

/* ---------- Keyframes ---------- */
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

@keyframes nudge {
  50% { transform: translateY(3px); }
}

@keyframes sheet-unfold {
  0% {
    opacity: 0;
    transform: translateY(24px) rotateX(-18deg) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes scan-sweep {
  from { transform: translateY(12px); }
  to { transform: translateY(214px); }
}

@keyframes status-swap {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: none; }
}

@keyframes dock-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes hint-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

@keyframes dlg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes dlg-out {
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  to { opacity: 0; }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
  }
  .scan-beam {
    display: none;
  }
}

/* =========================================================
   Navigation Link & About Us Page
   ========================================================= */

.site-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}

.nav-link:hover {
  color: var(--ink);
  background: rgba(20, 20, 19, 0.04);
}

.nav-link[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

body[data-view="editor"] .site-nav {
  display: none;
}

.nav-cta {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

/* ---------- About Page Layout ---------- */
.about-page {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: clamp(36px, 7vh, 72px) clamp(20px, 4vw, 40px) clamp(56px, 8vh, 88px);
  display: flex;
  flex-direction: column;
  gap: clamp(40px, 6vh, 60px);
}

.about-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.about-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.about-eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.about-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(34px, 5.6vw, 58px);
  line-height: 1.06;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.about-lead {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.6;
}

/* Pillars Grid */
.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.about-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}

.about-card:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.about-card-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 2px;
}

.about-card-icon svg {
  width: 19px;
  height: 19px;
}

.about-card h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.about-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

/* Open-Source Architecture Strip */
.about-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.about-section-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.about-section-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.about-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 60ch;
}

.about-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.about-spec {
  padding: 18px 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.about-spec-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.about-spec-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.about-spec-note {
  font-size: 13.5px;
  color: var(--muted);
}

/* Architectural Open-Source Callout */
.about-cta {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: clamp(28px, 4.5vw, 44px) 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.about-cta h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.about-cta p {
  margin: 0;
  max-width: 48ch;
  color: var(--muted);
  font-size: 15px;
}

.about-cta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

/* Image Logo */
.brand-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

/* Responsive Site Footer (Shared across all pages) */
.site-footer {
  margin-top: auto;
  width: 100%;
  border-top: 1px solid var(--line);
  background: rgba(250, 248, 245, 0.72);
  padding: 22px clamp(20px, 4vw, 48px);
  color: var(--muted);
  font-size: 13px;
}

body[data-view="processing"] .site-footer {
  display: none;
}

body[data-view="editor"] .site-footer {
  background: rgba(239, 236, 230, 0.78);
  padding-bottom: calc(max(24px, env(safe-area-inset-bottom)) + 76px);
}

.footer-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 28px;
}

.footer-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-width: 0;
}

.footer-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex: none;
}

.footer-logo {
  display: block;
  height: 24px;
  width: auto;
  max-width: 136px;
  object-fit: contain;
}

.footer-tagline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.footer-links {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  flex: none;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s;
}

.footer-links a:hover,
.footer-links a[aria-current="page"] {
  color: var(--ink);
}

.footer-links a[aria-current="page"] {
  font-weight: 600;
}

@media (max-width: 768px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .footer-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

@media (max-width: 640px) {
  .about-grid,
  .about-specs {
    grid-template-columns: 1fr;
  }

  .header-actions {
    gap: 8px;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 12.5px;
  }

  body[data-view="about"] .github-link span {
    display: none;
  }

  body[data-view="about"] .github-link {
    padding: 7px;
  }

  .about-cta-actions {
    width: 100%;
    flex-direction: column;
  }

  .about-cta-actions .btn {
    width: 100%;
  }

  .brand-logo {
    height: 26px;
    max-width: 136px;
  }

  body[data-view="editor"] .brand-logo {
    height: 24px;
    max-width: 112px;
  }

  .site-footer {
    padding: 20px 20px calc(max(20px, env(safe-area-inset-bottom)));
  }

  body[data-view="editor"] .site-footer {
    padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + 84px);
  }

  .footer-inner,
  .footer-brand {
    align-items: center;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
    gap: 4px 16px;
  }
}
