@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #111113;
  --surface: #1a1a1e;
  --surface-raised: #222226;
  --surface-hover: #2a2a2f;
  --border: #303036;
  --border-subtle: #26262b;
  --text: #e8e6e1;
  --text-secondary: #9a9893;
  --text-muted: #68665f;
  --accent: #b8a48c;
  --accent-hover: #c9b69e;
  --success: #7eb88a;
  --warning: #c4a35a;
  --danger: #c46b6b;

  /* Metallic gradient tokens */
  --metal-base: linear-gradient(135deg, #2c2c31 0%, #35353b 40%, #2a2a2f 60%, #323238 100%);
  --metal-hover: linear-gradient(135deg, #333339 0%, #3d3d44 40%, #31313a 60%, #3a3a42 100%);
  --metal-sheen: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.03) 45%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 55%, transparent 60%);
  --metal-border: linear-gradient(135deg, #404047 0%, #2d2d33 50%, #3a3a40 100%);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --transition: 0.18s cubic-bezier(0.25, 0.1, 0.25, 1);
}

html { font-size: 15px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

::selection {
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
}

::-moz-selection {
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
}

/* Layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 24px;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 60px;
  padding: 12px 24px;
  background: rgba(26, 26, 30, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.navbar__logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}

.navbar__logo span {
  color: var(--accent);
}

.navbar__links {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color var(--transition);
}

.nav-link:hover {
  color: var(--text);
}

/* Hero Section */
.hero {
  position: relative;
  text-align: center;
  margin-bottom: 72px;
  padding: 40px 0;
}

.slide-up-anim {
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes slideUpFade {
  to { opacity: 1; transform: translateY(0); }
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(184, 164, 140, 0.4);
  animation: pulse-dot-anim 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes pulse-dot-anim {
  to {
    box-shadow: 0 0 0 10px rgba(184, 164, 140, 0);
  }
}

.hero__badge-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(184, 164, 140, 0.08);
  border: 1px solid rgba(184, 164, 140, 0.3);
  padding: 6px 16px;
  border-radius: 100px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(184, 164, 140, 0.15);
  backdrop-filter: blur(8px);
}

.hero__glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(184, 164, 140, 0.15) 0%, rgba(184, 164, 140, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  filter: blur(40px);
  animation: pulse 8s ease-in-out infinite alternate;
}

.hero__glow--alt {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(126, 184, 138, 0.1) 0%, transparent 70%);
  transform: translate(-20%, -30%);
  animation-delay: -4s;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

.hero h1 {
  font-size: 3.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 20px;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.hero h1 span {
  background: linear-gradient(to right, #e8e6e1, #b8a48c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto 32px;
  line-height: 1.6;
}

.hero__badges {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.badge {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge--glass {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  backdrop-filter: blur(4px);
}

.badge--accent {
  background: rgba(184, 164, 140, 0.1);
  border: 1px solid rgba(184, 164, 140, 0.2);
  color: var(--accent);
}

.hero__cta {
  display: inline-block;
  padding: 12px 28px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  font-weight: 700;
  border-radius: 100px;
  font-size: 0.95rem;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 15px rgba(232, 230, 225, 0.2);
}

.hero__cta:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 25px rgba(232, 230, 225, 0.35);
}

/* Drop Zone */
.drop-zone {
  position: relative;
  scroll-margin-top: 4vh;
  background: var(--metal-base);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter var(--transition), box-shadow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.drop-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--metal-sheen);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover {
  border-color: var(--accent);
  filter: brightness(1.06);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.drop-zone:hover::after { opacity: 1; }

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--metal-hover);
  filter: brightness(1.1);
  transform: scale(1.005);
}

.drop-zone__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  stroke: var(--text-muted);
  transition: stroke var(--transition);
}

.drop-zone:hover .drop-zone__icon { stroke: var(--accent); }

.drop-zone__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.drop-zone__hint {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.drop-zone input[type="file"] { display: none; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Textarea */
.text-input {
  position: relative;
}

.text-input textarea {
  display: block;
  width: 100%;
  min-height: 160px;
  max-height: 400px;
  resize: vertical;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.text-input textarea::placeholder { color: var(--text-muted); }
.text-input textarea:focus { border-color: var(--accent); }

.text-input__count {
  text-align: right;
  margin-top: 6px;
  margin-right: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--metal-base);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), filter var(--transition), transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--metal-sheen);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.btn:hover {
  border-color: var(--accent);
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(184, 164, 140, 0.15);
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(0.5px); filter: brightness(0.96); }

.btn--primary {
  background: linear-gradient(135deg, #3a352c 0%, #4a4235 50%, #3a352c 100%);
  border-color: var(--accent);
  color: var(--accent);
}

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

.btn--sm {
  padding: 6px 13px;
  font-size: 0.78rem;
}

.btn svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 20px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.info-row svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  flex-shrink: 0;
}

/* Results */
.results {
  margin-top: 32px;
  display: none;
}

.results.visible { display: block; }

/* Stats Bar */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.stat__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat__value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat__value--accent { color: var(--accent); }
.stat__value--success { color: var(--success); }

/* Savings Bar */
.savings-bar {
  height: 6px;
  background: var(--surface-raised);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.savings-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Next Step Callout */
.next-step-callout {
  background: rgba(167, 243, 208, 0.05);
  border: 1px solid rgba(167, 243, 208, 0.2);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
  animation: slideDownFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.next-step-callout svg {
  width: 28px;
  height: 28px;
  color: #a7f3d0;
  flex-shrink: 0;
  animation: pulseSubtle 2s infinite ease-in-out;
}

.next-step-callout strong {
  color: #a7f3d0;
  font-weight: 600;
  font-size: 0.95rem;
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseSubtle {
  0% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0.7; transform: scale(1); }
}

/* Pages */
.pages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pages-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-nav span {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: center;
}

.page-nav button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.page-nav button:hover { border-color: var(--accent); color: var(--accent); }
.page-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
.page-nav button svg { width: 14px; height: 14px; stroke: currentColor; }

/* Image Preview */
.preview {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}

/* Download bar */
.download-bar {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Processing state */
.processing {
  display: none;
  text-align: center;
  padding: 40px 0;
}

.processing.visible { display: block; }

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing__text {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Info */
.info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.info-row svg { width: 13px; height: 13px; stroke: currentColor; flex-shrink: 0; }

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 40px;
  padding-bottom: 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  color: var(--text);
  font-size: 0.82rem;
  z-index: 100;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Floating Explore Button */
.floating-explore {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(20, 20, 20, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 40px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.floating-explore svg {
  width: 18px;
  height: 18px;
  color: #a1a1aa;
  transition: all 0.3s;
}

.floating-explore:hover {
  background: rgba(40, 40, 40, 0.8);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.floating-explore:hover svg {
  color: #cfa86e;
}

/* Multi-file Layout */
.editor-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.reorder-panel {
  width: 250px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow-y: auto;
}

.reorder-panel.hidden {
  display: none;
}

.reorder-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reorder-panel__hint {
  font-size: 0.65rem;
  opacity: 0.7;
}

.reorder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reorder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text);
  cursor: grab;
  transition: background 0.2s;
}

.reorder-item:active {
  cursor: grabbing;
}

.reorder-item:hover {
  background: rgba(255,255,255,0.06);
}

.reorder-item.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.reorder-item__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.reorder-item__remove {
  background: none;
  border: none;
  color: #ff5f56;
  cursor: pointer;
  padding: 0 4px;
  font-size: 1rem;
  opacity: 0.6;
}

.reorder-item__remove:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 800px) {
  .editor-layout {
    flex-direction: column;
    align-items: stretch;
  }
  .reorder-panel {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app { padding: 28px 16px 60px; }
  .header h1 { font-size: 1.6rem; }
  .drop-zone { padding: 36px 20px; }
  .stats { grid-template-columns: 1fr 1fr; }
}

/* Global Site Footer */
.site-footer { border-top: 1px solid var(--border); padding: 64px 24px 40px; margin-top: 64px; background: var(--bg); }
.footer-grid { max-width: 960px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 48px; }
.footer-col h4 { font-size: 1.1rem; color: var(--text); margin-bottom: 24px; font-weight: 600; }
.footer-col a { display: block; color: var(--text-muted); text-decoration: none; margin-bottom: 12px; transition: color 0.2s; }
.footer-col a:hover { color: var(--accent); }
