:root {
  --pt-bg: #0b1220;
  --pt-card: #141c2f;
  --pt-border: rgba(96, 165, 250, 0.2);
  --pt-accent: #3b82f6;
  --pt-accent2: #22d3ee;
  --pt-muted: #94a3b8;
}

body {
  margin: 0;
  background: var(--pt-bg);
  color: #f1f5f9;
  font-family: Sarabun, Sarabun, system-ui, sans-serif;
}

.wrap {
  width: min(1100px, 100% - 2rem);
  margin-inline: auto;
}

.ad-wrap {
  margin-top: 0.85rem;
  margin-bottom: 0.35rem;
}

.ad-wrap--bottom {
  margin-top: 2rem;
  margin-bottom: 1.25rem;
}

.hero {
  background: linear-gradient(145deg, #1e3a5f 0%, #0f172a 50%, #0c4a6e 100%);
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--pt-border);
}

.hero-inner h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.hero-sub {
  margin: 0.45rem 0 1rem;
  color: #cbd5e1;
  max-width: 42rem;
  line-height: 1.5;
}

.tool-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tool-tab {
  border: 1px solid var(--pt-border);
  background: rgba(15, 23, 42, 0.5);
  color: #e2e8f0;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s;
}

.tool-tab:hover {
  border-color: var(--pt-accent);
  transform: translateY(-1px);
}

.tool-tab.active {
  background: linear-gradient(120deg, var(--pt-accent), #2563eb);
  border-color: transparent;
  color: #fff;
}

.main {
  padding: 1.25rem 0 3rem;
}

.panel.hidden {
  display: none !important;
}

.panel {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.drop-zone {
  border: 2px dashed var(--pt-border);
  border-radius: 16px;
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--pt-card);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.drop-zone.small {
  padding: 1.25rem;
}

.drop-zone.dragover {
  border-color: var(--pt-accent2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
  transform: scale(1.005);
}

.drop-icon {
  font-size: 2rem;
}

.hint {
  color: var(--pt-muted);
  font-size: 0.875rem;
  margin: 0.75rem 0;
  line-height: 1.5;
}

.file-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
}

.file-row {
  display: grid;
  grid-template-columns: auto 72px 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--pt-card);
  border: 1px solid var(--pt-border);
  border-radius: 12px;
  cursor: grab;
  transition: box-shadow 0.2s, transform 0.2s ease, opacity 0.2s ease;
}

.file-row.dragging {
  opacity: 0.45;
}

.file-row.drag-over {
  outline: 2px solid var(--pt-accent);
  outline-offset: 2px;
}

.file-thumb {
  width: 72px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--pt-border);
  background: #0f172a;
}

.row-title {
  font-weight: 600;
}

.row-meta {
  font-size: 0.78rem;
  color: var(--pt-muted);
}

.btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(120deg, var(--pt-accent), #2563eb);
  color: #fff;
}

.btn.ghost {
  background: rgba(148, 163, 184, 0.1);
  color: #e2e8f0;
  border-color: var(--pt-border);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-row.spread {
  justify-content: space-between;
}

.row.gap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 1rem;
}

.fld {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.fld.row-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.fld select {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--pt-border);
  background: #1e293b;
  color: #fff;
}

.preview-frame {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--pt-card);
  border-radius: 12px;
  border: 1px solid var(--pt-border);
}

.preview-frame.hidden {
  display: none;
}

.preview-frame iframe {
  width: 100%;
  height: min(640px, 70vh);
  border: none;
  border-radius: 8px;
  background: #fff;
}

.size-compare {
  display: flex;
  gap: 2rem;
  padding: 1rem;
  background: var(--pt-card);
  border-radius: 12px;
  margin-top: 0.75rem;
}

.size-compare.hidden {
  display: none;
}

.size-compare span {
  display: block;
  font-size: 0.75rem;
  color: var(--pt-muted);
}

.queue-list {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--pt-muted);
}

.sign-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 840px) {
  .sign-tools {
    grid-template-columns: 1fr;
  }
  .file-row {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }
  .file-thumb {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
  }
}

.sign-draw-card,
.sign-place-card {
  background: var(--pt-card);
  border: 1px solid var(--pt-border);
  border-radius: 14px;
  padding: 1rem;
}

#sign-canvas {
  width: 100%;
  max-width: 440px;
  border-radius: 10px;
  border: 1px solid var(--pt-border);
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.pdf-stage-wrap {
  position: relative;
  margin-top: 0.5rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--pt-border);
  background: #0f172a;
  min-height: 200px;
}

#sign-bg-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.sig-stamp {
  position: absolute;
  cursor: grab;
  border: 2px dashed rgba(59, 130, 246, 0.6);
  border-radius: 8px;
  touch-action: none;
}

.sig-stamp:active {
  cursor: grabbing;
}

#sig-stamp-inner {
  display: block;
  background: transparent;
}

.form-fields {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.form-fields.hidden {
  display: none;
}

.form-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
}

.form-fields input[type="text"] {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--pt-border);
  background: #1e293b;
  color: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: var(--pt-card);
  border: 1px solid var(--pt-border);
  border-radius: 16px;
  padding: 1.25rem;
  max-width: 900px;
  width: 100%;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 0.65rem;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.picker-tile {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.35rem;
  cursor: pointer;
  background: #0f172a;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s ease;
}

.picker-tile.selected {
  border-color: var(--pt-accent);
  transform: scale(1.02);
}

.picker-tile canvas,
.picker-tile img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

.toast {
  position: sticky;
  top: 12px;
  z-index: 50;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--pt-border);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
}
