:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-top: #eef4fb;
  --bg-bottom: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --ink: #172033;
  --text: #172033;
  --muted: #68758a;
  --accent: #315f9f;
  --accent-dark: #264f87;
  --accent-soft: #e8f0fb;
  --border: #d9e1ec;
  --success: #146c43;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 39, 75, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-top: #111827;
  --bg-bottom: #0b1220;
  --panel: #111c2f;
  --panel-soft: #0f1a2b;
  --ink: #e5eefc;
  --text: #e5eefc;
  --muted: #a5b4cf;
  --accent: #5b8cff;
  --accent-dark: #7ca2ff;
  --accent-soft: #182846;
  --border: #24324a;
  --success: #86efac;
  --danger: #f87171;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(108, 160, 255, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(84, 210, 255, 0.14), transparent 24%),
    linear-gradient(155deg, var(--bg-top) 0%, var(--bg) 52%, var(--bg-bottom) 100%);
  color: var(--ink);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.32;
  z-index: 0;
}

body::before {
  top: 4rem;
  right: -6rem;
  background: rgba(84, 210, 255, 0.22);
}

body::after {
  bottom: -6rem;
  left: -5rem;
  background: rgba(108, 160, 255, 0.18);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: none;
  margin-bottom: 12px;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
  font-weight: 800;
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.15rem;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 0 0 2rem;
}

.panel {
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.preview-panel {
  grid-column: 1 / -1;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.drop-zone {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: var(--panel-soft);
  cursor: pointer;
}

.drop-zone span {
  font-weight: 800;
}

.drop-zone small,
.hint,
.status,
footer {
  color: var(--muted);
}

input,
select,
button {
  width: 100%;
  border-radius: 0.75rem;
  font: inherit;
}

input,
select {
  margin-top: 0.4rem;
  min-height: 58px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 700;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(49, 95, 159, 0.14);
}

input[type="file"] {
  margin-top: 0.75rem;
}

label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

button {
  margin-top: 0.75rem;
  min-height: 58px;
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.theme-toggle {
  width: auto;
  min-width: 96px;
  min-height: 42px;
  margin-top: 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.88rem;
}

.theme-toggle:hover:not(:disabled) {
  background: var(--panel-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.status {
  margin: 0.85rem 0 0;
}

.status.ok {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

#previewFrame {
  width: 100%;
  height: min(72vh, 820px);
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-soft);
}

footer {
  padding: 0 1rem 2rem;
  text-align: center;
}

@media (max-width: 820px) {
  .hero,
  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
  }

  .page-shell {
    width: min(100% - 20px, 1440px);
    padding: 24px 0;
  }

  .layout,
  .grid {
    grid-template-columns: 1fr;
  }
}
