:root {
  color-scheme: dark;
  --bg: #090d18;
  --bg-soft: #10162b;
  --panel: rgba(16, 22, 42, 0.78);
  --panel-strong: rgba(22, 30, 58, 0.92);
  --text: #f7f8ff;
  --muted: #aeb8da;
  --subtle: #7f8aaf;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #8b5cf6;
  --accent-2: #00d9ff;
  --success: #35d07f;
  --warning: #ffcc66;
  --danger: #ff6b7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7ff;
  --bg-soft: #ecf1ff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text: #101827;
  --muted: #536079;
  --subtle: #7a8499;
  --line: rgba(16, 24, 39, 0.13);
  --shadow: 0 24px 70px rgba(73, 84, 124, 0.18);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.32), transparent 30rem),
    radial-gradient(circle at top right, rgba(0, 217, 255, 0.16), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1440px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}

.eyebrow, .section-kicker {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: clamp(2.25rem, 6vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.075em;
}
h2 { margin-bottom: 0; font-size: 1.18rem; }
.subtitle { margin: 0; color: var(--muted); font-size: 1rem; }

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel-strong);
  padding: 8px 14px 8px 8px;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.theme-switch:hover { transform: translateY(-1px); border-color: rgba(0, 217, 255, 0.5); }
.switch-track {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.28);
  border: 1px solid var(--line);
  transition: background 260ms ease;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #dbe7ff);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  transition: transform 260ms cubic-bezier(.2,.8,.2,1), background 260ms ease;
}
html[data-theme="dark"] .switch-track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
html[data-theme="dark"] .switch-thumb { transform: translateX(22px); background: #071122; }

.three-panel-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(440px, 1.16fr) minmax(330px, 0.88fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  padding: 22px;
}

.section-heading { margin-bottom: 18px; }
.compact-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.file-name { margin: 8px 0 0; color: var(--subtle); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel-strong);
  padding: 8px 14px;
  transition: transform 180ms ease, border-color 180ms ease, opacity 180ms ease;
}
.ghost-button:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(139, 92, 246, 0.52); }
.ghost-button:disabled { cursor: not-allowed; opacity: 0.45; }

.drop-zone {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  gap: 10px;
  overflow: hidden;
  border: 1.5px dashed rgba(139, 92, 246, 0.62);
  border-radius: var(--radius-md);
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.13), rgba(0, 217, 255, 0.07)),
    var(--panel-strong);
  text-align: center;
  box-shadow: 0 0 0 rgba(0, 217, 255, 0);
  animation: dropZonePulse 3.2s ease-in-out infinite;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), border-color 220ms ease, background 220ms ease, box-shadow 220ms ease;
}
.drop-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(circle at center, rgba(0, 217, 255, 0.22), transparent 62%),
    linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(0, 217, 255, 0.12));
  opacity: 0.36;
  transform: scale(0.985);
  animation: dropZoneColorPulse 3.2s ease-in-out infinite;
}
.drop-zone:hover, .drop-zone.is-dragging {
  transform: translateY(-5px) scale(1.01);
  border-color: var(--accent-2);
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.26), rgba(0, 217, 255, 0.16)),
    var(--panel-strong);
  box-shadow: 0 20px 55px rgba(0, 217, 255, 0.12);
}
.drop-zone:hover::before, .drop-zone.is-dragging::before {
  opacity: 0.62;
}
.drop-zone.has-image { border-color: rgba(53, 208, 127, 0.58); }
.drop-zone.has-image::before {
  background:
    radial-gradient(circle at center, rgba(53, 208, 127, 0.18), transparent 62%),
    linear-gradient(135deg, rgba(53, 208, 127, 0.14), rgba(0, 217, 255, 0.08));
}
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.drop-zone strong { color: var(--text); font-size: 1.08rem; }

@keyframes dropZonePulse {
  0%, 100% {
    border-color: rgba(139, 92, 246, 0.56);
    box-shadow: 0 0 0 rgba(0, 217, 255, 0);
  }
  50% {
    border-color: rgba(0, 217, 255, 0.68);
    box-shadow: 0 0 28px rgba(0, 217, 255, 0.12);
  }
}

@keyframes dropZoneColorPulse {
  0%, 100% {
    opacity: 0.28;
    transform: scale(0.985);
  }
  50% {
    opacity: 0.58;
    transform: scale(1.015);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drop-zone,
  .drop-zone::before {
    animation: none;
  }
}
.drop-art {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 1.9rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.settings-card { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel-strong); padding: 14px; }
.setting-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-row label { color: var(--text); font-weight: 850; }
.setting-row p { margin: 5px 0 0; color: var(--subtle); font-size: 0.82rem; line-height: 1.45; }
.input-with-unit { display: flex; align-items: center; min-width: 128px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.04); }
.input-with-unit input { width: 68px; border: 0; outline: 0; padding: 10px 0 10px 14px; color: var(--text); background: transparent; font-weight: 900; }
.input-with-unit span { padding-right: 12px; color: var(--subtle); font-size: 0.82rem; font-weight: 850; }

.message { margin-top: 16px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); background: var(--panel-strong); line-height: 1.5; }
.message.is-warning { border-color: rgba(255, 204, 102, 0.55); color: var(--warning); }
.message.is-danger { border-color: rgba(255, 107, 122, 0.55); color: var(--danger); }

.preview-panel { min-height: 640px; }
.preview-frame {
  position: relative;
  display: grid;
  min-height: 540px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(45deg, rgba(128, 128, 128, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(128, 128, 128, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(128, 128, 128, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(128, 128, 128, 0.08) 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
  background-size: 24px 24px;
}
canvas { image-rendering: pixelated; }
#previewCanvas { display: none; max-width: 100%; max-height: 540px; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28); }
.empty-preview { display: grid; place-items: center; color: var(--subtle); font-weight: 850; }

.hero-metric {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(0, 217, 255, 0.08)), var(--panel-strong);
}
.metric-label, .stat-card span { color: var(--subtle); font-size: 0.78rem; font-weight: 950; letter-spacing: 0.08em; text-transform: uppercase; }
.hero-metric strong { font-size: clamp(3.7rem, 6.5vw, 5.6rem); line-height: 0.88; letter-spacing: -0.08em; }
.badge { display: inline-flex; width: fit-content; align-items: center; justify-content: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,0.04); font-weight: 900; }
.badge.good { border-color: rgba(53, 208, 127, 0.48); color: var(--success); }
.badge.danger { border-color: rgba(255, 107, 122, 0.55); color: var(--danger); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { min-height: 92px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel-strong); }
.stat-card span { display: block; margin-bottom: 10px; }
.stat-card strong { font-size: 1.18rem; letter-spacing: -0.03em; }
.notes { margin-top: 14px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--muted); background: var(--panel-strong); font-size: 0.9rem; line-height: 1.55; }
.notes p { margin-bottom: 8px; }
.notes p:last-child { margin-bottom: 0; }


.app-footer {
  margin-top: 22px;
  padding: 16px 10px 4px;
  color: var(--subtle);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.app-footer p { margin: 0; }

@media (max-width: 1120px) {
  .three-panel-grid { grid-template-columns: 1fr 1fr; }
  .results-panel { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .page-shell { width: min(100% - 22px, 680px); padding: 22px 0; }
  .app-header, .three-panel-grid { display: block; }
  .theme-switch { margin-top: 18px; }
  .panel + .panel { margin-top: 16px; }
  .preview-panel { min-height: auto; }
  .preview-frame { min-height: 300px; }
  .stat-grid { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; }
}
