:root {
  --bg: #f4f7fb;
  --card: rgba(255,255,255,.78);
  --text: #142033;
  --muted: #64748b;
  --line: rgba(15,23,42,.12);
  --accent: #142033;
  --shadow: 0 24px 70px rgba(15,23,42,.10);
  --radius: 28px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 6%, rgba(56,189,248,.18), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(168,85,247,.12), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, select { font: inherit; }
button { cursor: pointer; }
.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 0;
  display: flex;
  align-items: center;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #111827, #334155);
  box-shadow: 0 12px 28px rgba(15,23,42,.16);
  letter-spacing: -0.05em;
  font-weight: 800;
}
.page {
  width: min(1280px, calc(100% - 32px));
  margin: 42px auto 48px;
}
.hero { max-width: 760px; margin-bottom: 30px; }
.eyebrow {
  margin: 0 0 12px;
  color: #0284c7;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 13px;
}
h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.055em;
  font-weight: 720;
}
.lead {
  max-width: 670px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.8vw, 20px);
  line-height: 1.55;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(560px, 735px) minmax(220px, 320px);
  gap: 18px;
  align-items: start;
  justify-content: center;
  max-width: 1080px;
  margin: 0 auto;
}
.workspace.is-batch {
  grid-template-columns: minmax(0, 1fr) minmax(150px, 190px) 320px;
  max-width: 1280px;
}
.dropzone {
  position: relative;
  min-height: 650px;
  border: 2px solid rgba(15,23,42,.18);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(22px);
  touch-action: pan-y;
}
.dropzone.dragover {
  border-color: #0284c7;
  background: rgba(240,249,255,.92);
  outline: 3px solid #0284c7;
  outline-offset: 3px;
}
.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 28px;
}
.upload-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: #142033;
  color: #fff;
  font-size: 42px;
  line-height: 1;
  margin-bottom: 18px;
}
.empty-state h2 { margin: 0 0 10px; font-size: 28px; letter-spacing: -0.03em; font-weight: 720; }
.empty-state p { max-width: 430px; margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.editor {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}
.hidden { display: none !important; }
#imageCanvas {
  max-width: 100%;
  max-height: 100%;
  user-select: none;
}
.crop-box {
  position: absolute;
  border: 3px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.48), 0 18px 40px rgba(0,0,0,.28);
  border-radius: 14px;
  cursor: move;
  touch-action: none;
}
.grid-line { position: absolute; background: rgba(255,255,255,.55); }
.grid-line--v1 { left: 33.33%; top: 0; width: 1px; height: 100%; }
.grid-line--v2 { left: 66.66%; top: 0; width: 1px; height: 100%; }
.grid-line--h1 { top: 33.33%; left: 0; height: 1px; width: 100%; }
.grid-line--h2 { top: 66.66%; left: 0; height: 1px; width: 100%; }
.handle {
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border: 3px solid #142033;
  border-radius: 999px;
}
.handle--tl { top: -10px; left: -10px; cursor: nwse-resize; }
.handle--tr { top: -10px; right: -10px; cursor: nesw-resize; }
.handle--bl { bottom: -10px; left: -10px; cursor: nesw-resize; }
.handle--br { bottom: -10px; right: -10px; cursor: nwse-resize; }

.photo-selector {
  max-height: 650px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.photo-selector__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.photo-selector__head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
  font-weight: 720;
}
.photo-selector__head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.photo-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}
.photo-item {
  width: 100%;
  border: 2px solid transparent;
  border-radius: 16px;
  background: rgba(255,255,255,.78);
  padding: 7px;
  text-align: left;
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.photo-item:hover {
  transform: translateY(-1px);
  border-color: rgba(20,32,51,.22);
}
.photo-item.active {
  border-color: #142033;
  background: #fff;
}
.photo-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 11px;
  background: #e2e8f0;
}
.photo-item span {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: grid;
  gap: 18px;
}
.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  box-shadow: 0 18px 45px rgba(15,23,42,.07);
  backdrop-filter: blur(18px);
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: -0.03em;
  font-weight: 720;
}
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.ratio-btn {
  min-height: 70px;
  border: 2px solid rgba(15,23,42,.16);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  font-size: 22px;
  font-weight: 750;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.ratio-btn:hover { transform: translateY(-2px); }
.ratio-btn.active {
  border-color: #142033;
  color: #fff;
  background: #142033;
}
.panel-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.panel-compact label { color: var(--muted); font-weight: 700; }
select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.btn {
  width: 100%;
  border: 0;
  border-radius: 20px;
  min-height: 58px;
  padding: 14px 18px;
  font-weight: 760;
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary, .btn-download {
  color: white;
  background: linear-gradient(135deg, #142033, #334155);
  box-shadow: 0 18px 38px rgba(15,23,42,.18);
}
.btn-ghost {
  background: rgba(255,255,255,.75);
  border: 1px solid var(--line);
  color: var(--text);
}
.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.batch-panel {
  display: grid;
  gap: 14px;
}
.batch-panel strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}
.batch-panel span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.batch-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.mini-btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}
.mini-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.features {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.features article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.66);
}
.features strong { display: block; margin-bottom: 5px; font-weight: 720; }
.features span { color: var(--muted); font-size: 14px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, calc(100% - 32px));
  padding: 14px 18px;
  border-radius: 18px;
  color: #fff;
  background: rgba(20,32,51,.94);
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  z-index: 20;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .page { margin-top: 28px; }
  .workspace { grid-template-columns: 1fr; }
  .dropzone { min-height: 520px; }
  .controls { grid-template-columns: 1fr; }
  .ratio-grid { grid-template-columns: repeat(3, 1fr); }
  .features { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { width: min(100% - 20px, 1180px); }
  .brand__text { font-size: 14px; }
  .page { width: min(100% - 20px, 1180px); margin-top: 24px; }
  h1 { font-size: clamp(34px, 12vw, 48px); line-height: 1.06; }
  .lead { font-size: 16px; }
  .dropzone { min-height: 420px; border-radius: 22px; }
  .ratio-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .ratio-btn { min-height: 58px; font-size: 18px; border-radius: 16px; }
  .panel { padding: 16px; border-radius: 22px; }
  .panel-compact { align-items: stretch; flex-direction: column; }
  .empty-state h2 { font-size: 23px; }
}


.seo-text {
  margin-top: 28px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.58);
  color: var(--muted);
  line-height: 1.65;
}
.seo-text h2 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 720;
}
.seo-text p {
  margin: 0;
  max-width: 980px;
}
.seo-text p + p {
  margin-top: 10px;
}


.replace-overlay {
  position: absolute;
  inset: 18px;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 2px dashed rgba(2,132,199,.75);
  border-radius: 22px;
  background: rgba(255,255,255,.72);
  color: #142033;
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 760;
  text-align: center;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: scale(.985);
  transition: opacity .18s ease, transform .18s ease;
  backdrop-filter: blur(12px);
}
.replace-overlay.show {
  opacity: 1;
  transform: scale(1);
}
