:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #14182b;
  --muted: #5b6380;
  --line: #dde2f0;
  --accent: #3b3bf0;
  --accent-hover: #2929c9;
  --accent-soft: #e9e9ff;
  --danger: #c62839;
  --success: #12795a;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #181c30;
    --text: #eef0fa;
    --muted: #9aa2c4;
    --line: #2a3050;
    --accent: #7c7cff;
    --accent-hover: #9a9aff;
    --accent-soft: #23274a;
    --danger: #ff7a87;
    --success: #4fd1a5;
  }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1, h2 { line-height: 1.2; margin: 0 0 0.6rem; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 650; }

p { margin: 0 0 1rem; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

ul, ol { padding-left: 1.25rem; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--text);
}
.logo:hover { color: var(--accent); }

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header nav a {
  display: block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}
.site-header nav a:hover { background: var(--accent-soft); color: var(--text); }
.site-header nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) 1rem 3rem;
}

.tool { text-align: center; }

.lead {
  max-width: 52ch;
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.4rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.drop-zone {
  padding: clamp(2rem, 7vw, 4rem) 1.5rem;
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: 16px;
  transition: border-color 0.15s, background-color 0.15s;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-title {
  margin-bottom: 0.25rem;
  font-size: 1.35rem;
  font-weight: 650;
}

.drop-or {
  margin-bottom: 1rem;
  color: var(--muted);
}
.file-section {
  margin-top: 2rem;
  text-align: left;
}

.file-section-head { margin-bottom: 1rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.92rem; }

.file-list {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.file-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  cursor: grab;
  transition: border-color 0.15s, opacity 0.15s;
}
.file-item:hover { border-color: var(--accent); }
.file-item:active { cursor: grabbing; }

.file-item.dragging { opacity: 0.4; }
.file-item.drag-over { border-top: 3px solid var(--accent); }

.file-name {
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.btn-remove {
  padding: 0.35rem 0.7rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--danger);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn-remove:hover { border-color: var(--danger); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.actions #merge-btn { margin-left: auto; }

.status {
  min-height: 1.6rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-weight: 500;
}
.status.error { color: var(--danger); }
.status.success { color: var(--success); }

.result {
  margin-top: 1.5rem;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.result .btn { margin: 0.35rem; }

.ad-slot {
  min-height: 90px;
  margin: 2.5rem 0;
}

.info {
  max-width: 68ch;
  margin: 0 auto;
}
.info h2 { margin-top: 2rem; }
.info li { margin-bottom: 0.4rem; }

details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}
summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 0.5rem; color: var(--accent); }
details p { margin: 0; color: var(--muted); }

.site-footer {
  padding: 2rem 1rem;
  text-align: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer p { margin: 0; }

@media (max-width: 560px) {
  .file-item {
    grid-template-columns: 1fr auto;
  }
  .file-meta { grid-column: 1; grid-row: 2; }
  .btn-remove { grid-column: 2; grid-row: 1 / span 2; }

  .actions .btn { flex: 1 1 100%; text-align: center; }
  .actions #merge-btn { margin-left: 0; order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

.options {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.options legend { padding: 0 0.4rem; font-weight: 650; }

.option { display: block; padding: 0.4rem 0; cursor: pointer; }
.option input { margin-right: 0.5rem; accent-color: var(--accent); }

.field { margin: 0.4rem 0 0.8rem 1.6rem; }
.field label { display: block; margin-bottom: 0.3rem; font-size: 0.92rem; color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.field-row .field { margin: 0; }

input[type="text"], select {
  width: 100%;
  min-width: 12rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); }

.notice {
  margin-bottom: 1.5rem;
  padding: 0.8rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.92rem;
}

.image-item { grid-template-columns: auto 1fr auto; cursor: default; }
.image-item:active { cursor: default; }
.item-text { display: flex; flex-direction: column; min-width: 0; }
.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.item-actions { display: flex; gap: 0.4rem; align-items: center; }
.btn-move {
  width: 2.1rem; height: 2.1rem;
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  font: inherit; cursor: pointer;
}
.btn-move:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-move:disabled { opacity: 0.35; cursor: not-allowed; }

@media (max-width: 560px) {
  .image-item { grid-template-columns: auto 1fr; }
  .image-item .item-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .image-item .btn-remove { grid-column: auto; grid-row: auto; }
  .field { margin-left: 0; }
}

:root {
  --glass: rgba(255, 255, 255, 0.78);
  --grad: linear-gradient(135deg, #4a4af5, #8a3ffc);
  --shadow: 0 10px 30px rgba(60, 60, 160, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass: rgba(24, 28, 48, 0.78);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(91, 91, 255, 0.25), transparent 40%),
    radial-gradient(circle at 85% 0%, rgba(255, 95, 162, 0.2), transparent 40%),
    radial-gradient(circle at 50% 35%, rgba(34, 211, 197, 0.14), transparent 45%),
    var(--bg);
  background-repeat: no-repeat;
  background-size: 100% 600px, 100% 600px, 100% 600px, auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.logo { display: inline-flex; align-items: center; gap: 0.55rem; }
.logo img { display: block; width: 32px; height: 32px; }

.tool-icon {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0 auto 1rem;
  filter: drop-shadow(0 10px 18px rgba(80, 60, 200, 0.35));
  animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.tool h1 {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}
.badges li {
  padding: 0.3rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.badges li::before { content: "✓ "; color: var(--success); }

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(90, 60, 230, 0.35);
}
.btn-primary:hover { background: var(--grad); color: #fff; filter: brightness(1.1); }

.drop-zone {
  border-color: #a9a9f5;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragover {
  background: var(--accent-soft);
}
.options, .result, details, .file-item { box-shadow: var(--shadow); }

.info {
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.info h2:first-child { margin-top: 0; }
details { background: var(--bg); box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .tool-icon { animation: none; }
}