* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1a1a1a;
  background: #f3f4f6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo { font-size: 22px; }
.tagline { color: #6b7280; font-size: 13px; }

/* Landing */
.landing {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.hero h1 {
  font-size: 44px;
  line-height: 1.1;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  text-align: center;
}
.hero .sub {
  color: #4b5563;
  font-size: 18px;
  max-width: 640px;
  margin: 0 auto 36px;
  text-align: center;
  line-height: 1.5;
}

.drop-zone {
  display: block;
  border: 2px dashed #c7cbd1;
  background: #fff;
  border-radius: 16px;
  padding: 54px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.drop-zone:hover, .drop-zone.drag {
  border-color: #2563eb;
  background: #eff6ff;
  transform: translateY(-1px);
}
.drop-icon { font-size: 48px; margin-bottom: 10px; }
.drop-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.drop-sub { color: #6b7280; font-size: 14px; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 36px;
}
.feature {
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-size: 14px;
  line-height: 1.5;
  color: #374151;
}
.feature b { color: #111; }

.seo {
  margin-top: 64px;
  color: #374151;
  line-height: 1.7;
}
.seo h2 { font-size: 22px; margin: 24px 0 8px; }
.seo ol { padding-left: 20px; }
.seo li { margin-bottom: 4px; }

/* Editor */
.editor { padding-bottom: 60px; }

.toolbar {
  position: sticky;
  top: 56px;
  z-index: 40;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.tool {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #111;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.1s ease;
  font-weight: 500;
}
.tool:hover { background: #e5e7eb; }
.tool.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.tool.primary {
  background: #10b981;
  color: white;
  border-color: #10b981;
  font-weight: 600;
}
.tool.primary:hover { background: #059669; }
.tool.danger:hover { background: #fee2e2; color: #b91c1c; }
.sep {
  width: 1px;
  height: 22px;
  background: #e5e7eb;
  margin: 0 4px;
}
.spacer { flex: 1; }

.control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}
.control input[type="number"] {
  width: 56px;
  padding: 5px 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}
.control input[type="color"] {
  width: 32px;
  height: 30px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.control select {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.tool.toggle { min-width: 32px; padding: 7px 10px; font-size: 14px; }
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.toggle-wrap input { margin: 0; }

.hint {
  text-align: center;
  padding: 10px;
  color: #6b7280;
  font-size: 13px;
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
}

/* Pages */
.pages {
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.page {
  position: relative;
  background: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.page canvas { display: block; }
.edit-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
.edit-layer.tool-text { cursor: text; }
.edit-layer.tool-erase { cursor: crosshair; }
.edit-layer.tool-move { cursor: default; }

/* Edit items */
.item {
  position: absolute;
  min-width: 10px;
  min-height: 10px;
  box-sizing: border-box;
}
/* In Text/Erase tool mode, existing items don't capture the click —
   this lets you place new text or draw erase on top of them. */
.edit-layer:not(.tool-move) .item { pointer-events: none; }
.item.text {
  background: transparent;
  color: #111;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.15;
  padding: 0;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: visible;
  outline: none;
  border: 1px dashed transparent;
}
.item.text:hover { border-color: #9ca3af; }
.item.text.selected {
  border-color: #2563eb;
  background: rgba(37,99,235,0.04);
}
.item.text[contenteditable="true"] {
  cursor: text;
  border-color: #2563eb;
  background: rgba(37,99,235,0.06);
}
.item.erase {
  background: white;
  border: 1px dashed transparent;
}
.item.erase:hover { border-color: #9ca3af; }
.item.erase.selected { border-color: #2563eb; }

/* Resize handle */
.handle {
  position: absolute;
  width: 12px; height: 12px;
  background: #2563eb;
  border: 2px solid white;
  border-radius: 50%;
  right: -7px; bottom: -7px;
  cursor: nwse-resize;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  display: none;
  user-select: none;
}
.item.selected .handle { display: block; }

.erase-drawing {
  position: absolute;
  background: rgba(255,255,255,0.7);
  border: 1px dashed #2563eb;
  pointer-events: none;
}

/* Status toast */
.status {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
.status.show { opacity: 1; }

.foot {
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  padding: 24px;
}

@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .hero .sub { font-size: 15px; }
  .tagline { display: none; }
  .toolbar { top: 50px; }
}
