/* ═══════════════════════════════════════════════════
   THEME VARIABLES
═══════════════════════════════════════════════════ */

[data-theme="dark"] {
  --bg:          #080c10;
  --surface:     #0d1117;
  --elevated:    #131a22;
  --border:      #1c2530;
  --border-hi:   #2a3a4a;
  --text:        #e4ecf5;
  --muted:       #556880;
  --accent:      #22c9a0;
  --accent-dim:  rgba(34, 201, 160, 0.10);
  --accent-glow: rgba(34, 201, 160, 0.20);
  --success:     #22c9a0;
  --danger:      #e05757;
  --amber:       #f0a84a;
  --shadow:      0 32px 80px rgba(0, 0, 0, 0.65);
  --shadow-sm:   0 4px 24px rgba(0, 0, 0, 0.45);
  --checker:     conic-gradient(#131a22 0.25turn, #0d1117 0.25turn 0.5turn,
                   #131a22 0.5turn 0.75turn, #0d1117 0.75turn) 0 0 / 18px 18px;
}

[data-theme="light"] {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --elevated:    #f5f8fc;
  --border:      #dce5ee;
  --border-hi:   #a8bdd0;
  --text:        #0e1a26;
  --muted:       #52687c;
  --accent:      #0f9e78;
  --accent-dim:  rgba(15, 158, 120, 0.08);
  --accent-glow: rgba(15, 158, 120, 0.16);
  --success:     #0f9e78;
  --danger:      #cc3c3c;
  --amber:       #b87010;
  --shadow:      0 24px 64px rgba(14, 26, 38, 0.10);
  --shadow-sm:   0 4px 20px rgba(14, 26, 38, 0.06);
  --checker:     conic-gradient(#dce8f0 0.25turn, #edf3f8 0.25turn 0.5turn,
                   #dce8f0 0.5turn 0.75turn, #edf3f8 0.75turn) 0 0 / 18px 18px;
}

/* ═══════════════════════════════════════════════════
   RESET + BASE
═══════════════════════════════════════════════════ */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.25s, color 0.25s;
}

h1, h2, p, fieldset { margin: 0; }
button, input, label, select, output, legend { font: inherit; }
fieldset { padding: 0; border: 0; }

/* ═══════════════════════════════════════════════════
   AMBIENT BACKGROUND
═══════════════════════════════════════════════════ */

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
}

[data-theme="dark"] .blob-a { opacity: 0.07; }
[data-theme="dark"] .blob-b { opacity: 0.05; }
[data-theme="light"] .blob-a { opacity: 0.06; }
[data-theme="light"] .blob-b { opacity: 0.04; }

.blob-a {
  width: 700px; height: 700px;
  top: -200px; left: -150px;
  background: var(--accent);
}

.blob-b {
  width: 500px; height: 500px;
  bottom: -150px; right: -100px;
  background: var(--amber);
}

/* ═══════════════════════════════════════════════════
   SHELL
═══════════════════════════════════════════════════ */

.shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 72px;
  display: grid;
  gap: 20px;
}

/* ═══════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px; height: 38px;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.brand-tagline {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.action-btn:hover {
  border-color: var(--border-hi);
  color: var(--text);
  background: var(--elevated);
}

.action-btn svg { width: 16px; height: 16px; }

[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ═══════════════════════════════════════════════════
   HERO SECTION
═══════════════════════════════════════════════════ */

.hero {
  text-align: center;
  padding: 28px 0 8px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.hero-sub::before,
.hero-sub::after {
  content: '';
  display: inline-block;
  width: 32px;
  height: 1px;
  background: var(--border-hi);
}

/* ═══════════════════════════════════════════════════
   MODE TABS
═══════════════════════════════════════════════════ */

.mode-tabs {
  display: inline-flex;
  gap: 5px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  width: min(100%, 340px);
}

.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-tab svg { width: 16px; height: 16px; flex-shrink: 0; }

.mode-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-tab:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

/* ═══════════════════════════════════════════════════
   WORKSPACE
═══════════════════════════════════════════════════ */

.workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

/* ═══════════════════════════════════════════════════
   DROP ZONE
═══════════════════════════════════════════════════ */

.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 420px;
  padding: 48px 40px;
  background: var(--surface);
  border: 2px dashed var(--border-hi);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.18s, box-shadow 0.2s;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-3px);
  box-shadow: 0 0 0 1px var(--accent), 0 12px 40px var(--accent-glow), var(--shadow-sm);
}

.sr-input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Illustration */
.drop-art svg {
  width: 200px;
  height: auto;
  display: none;
}

.drop-art svg.visible { display: block; }

.art-arrow {
  animation: arrow-nudge 2.4s ease-in-out infinite;
}

@keyframes arrow-nudge {
  0%, 100% { opacity: 0.55; transform: translateX(0); }
  50%       { opacity: 1;    transform: translateX(5px); }
}

.drop-info h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.drop-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 0;
  font-weight: 400;
  line-height: 1.6;
}

/* Primary button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 28px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary svg { width: 15px; height: 15px; }
.btn-primary:hover  { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 8px 32px var(--accent-glow); }
.btn-primary:active { opacity: 1;   transform: translateY(0); }

.drop-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.8;
}

/* ═══════════════════════════════════════════════════
   SETTINGS PANEL
═══════════════════════════════════════════════════ */

.settings {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.settings > fieldset {
  background: var(--surface);
  padding: 16px;
}

.settings > fieldset:first-child { border-radius: 17px 17px 0 0; }
.settings > fieldset:last-child  { border-radius: 0 0 17px 17px; }

legend {
  float: left;
  width: 100%;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
}

legend + * { clear: both; }

/* Format chips */
.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Mode cards */
.mode-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 7px;
  align-items: start;
}

.mode-card:last-of-type { margin-bottom: 0; }

.mode-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.mode-card input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.mode-card:has(input:disabled) { opacity: 0.4; cursor: not-allowed; }

.mode-card-body strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 3px;
}

.mode-card-body small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.38;
}

/* Sub panels */
.sub-panel {
  background: var(--elevated) !important;
}

.subsection {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

/* Checkboxes */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.42;
  cursor: pointer;
  color: var(--text);
}

.check-row input {
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Sliders */
.range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

input[type="range"] {
  width: 100%;
  margin: 5px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

output {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Color controls */
.color-ctrl {
  display: flex;
  align-items: center;
  gap: 7px;
}

input[type="color"] {
  width: 38px; height: 28px;
  padding: 2px 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--elevated);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-mini {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.btn-mini:hover { border-color: var(--border-hi); color: var(--text); }
.btn-mini:disabled { opacity: 0.35; cursor: not-allowed; }

.hint-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.48;
  margin-bottom: 10px;
}

/* Select */
.select-wrap {
  position: relative;
}

.select-wrap select {
  width: 100%;
  appearance: none;
  min-height: 42px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--elevated);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s;
}

.select-wrap select:focus { outline: none; border-color: var(--accent); }

.select-wrap svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  color: var(--muted);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════
   STATUS BAR
═══════════════════════════════════════════════════ */

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: border-color 0.2s;
}

.status-pip {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.2s;
}

.status-bar.is-error  { border-color: rgba(224, 87, 87, 0.3); }
.status-bar.is-error  .status-pip  { background: var(--danger); }
.status-bar.is-error  .status-text { color: var(--danger); font-weight: 600; }

.status-bar.is-active .status-text { color: var(--text); }
.status-bar.is-active .status-pip  {
  background: var(--accent);
  animation: pip-blink 1.3s ease-in-out infinite;
}

.status-bar.is-done .status-pip  { background: var(--success); }
.status-bar.is-done .status-text { color: var(--success); font-weight: 600; }
.status-bar.is-done { border-color: rgba(34, 201, 160, 0.2); }

@keyframes pip-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ═══════════════════════════════════════════════════
   RESULTS
═══════════════════════════════════════════════════ */

.results { display: grid; gap: 14px; }

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.results-header h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }
.btn-ghost:disabled { opacity: 0.35; cursor: not-allowed; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

/* Result cards */
.result-card {
  display: grid;
  grid-template-rows: 150px auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: card-enter 0.22s ease-out both;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.result-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.result-card.is-error { border-color: rgba(224, 87, 87, 0.25); }

.card-preview {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--checker);
}

.card-preview img {
  max-width: 100%;
  max-height: 138px;
  object-fit: contain;
}

.card-preview-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.card-preview.is-media { background: var(--elevated); color: var(--accent); }
.card-preview.is-error { background: var(--elevated); color: var(--danger); }

.card-body {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.card-name {
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.card-meta {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.card-meta.is-error { color: var(--danger); }

.card-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  justify-self: start;
  transition: background 0.15s, border-color 0.15s;
}

.card-download:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.card-download svg { width: 11px; height: 11px; }

/* ═══════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE — TABLET ≤ 900px
═══════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .shell { width: min(100% - 24px, 680px); padding: 18px 0 48px; }
  .hero-title { font-size: clamp(22px, 6vw, 34px); }
  .hero { padding: 16px 0 4px; }
  .workspace { grid-template-columns: 1fr; }
  .drop-zone { min-height: 320px; padding: 36px 28px; gap: 14px; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — MOBILE ≤ 580px
═══════════════════════════════════════════════════ */

@media (max-width: 580px) {
  .shell { width: min(100% - 16px, 480px); padding: 12px 0 40px; gap: 14px; }
  .brand-tagline { display: none; }
  .brand-icon { width: 32px; height: 32px; }
  .brand-name { font-size: 16px; }
  .hero { padding: 8px 0 0; }
  .hero-title { font-size: 22px; }
  .hero-sub { font-size: 13px; }
  .mode-tabs { width: 100%; }
  .drop-zone { min-height: 260px; padding: 24px 16px; gap: 12px; }
  .drop-art svg { width: 160px; }
  .drop-info h2 { font-size: 19px; }
  .settings > fieldset { padding: 13px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .results-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .btn-mini { font-size: 10px; padding: 0 6px; }
}

@media (max-width: 360px) {
  .result-grid { grid-template-columns: 1fr; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr 300px; }
}

/* ═══════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════ */

.site-footer {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
