:root {
  --bg: #0c0f17;
  --bg-elev: #151a27;
  --bg-elev-2: #1c2233;
  --border: #283146;
  --text: #e6eaf2;
  --muted: #8b95ad;
  --accent: #6d8bff;
  --accent-2: #57e0c0;
  --danger: #ff6b6b;
  --success: #4ade80;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: 12px; }

html { color-scheme: dark; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(109, 139, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(87, 224, 192, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  line-height: 1.5;
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.hero { text-align: center; margin-bottom: 32px; }
.hero h1 {
  font-size: 2.2rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.hero .logo { filter: drop-shadow(0 2px 8px rgba(109, 139, 255, 0.5)); }
.hero p { color: var(--muted); margin: 0; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
  padding: 20px 22px;
  margin-bottom: 22px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.field.checkbox { justify-content: flex-end; }
.field.checkbox label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
}
.field input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

select, input[type="number"] {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.2);
}

input[type="range"] { accent-color: var(--accent); width: 100%; }
.muted { color: var(--muted); font-weight: 500; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  padding: 46px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); }
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(109, 139, 255, 0.08);
  transform: scale(1.005);
}
.dropzone-icon { font-size: 2.4rem; margin-bottom: 6px; }
.dropzone-title { font-size: 1.1rem; margin: 0 0 4px; }
.dropzone-sub { color: var(--muted); font-size: 0.85rem; margin: 0; }
.link { color: var(--accent); text-decoration: underline; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0 16px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.summary { font-size: 0.92rem; color: var(--muted); }
.summary strong { color: var(--accent-2); }
.toolbar-actions { display: flex; gap: 10px; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, opacity 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #8a73ff);
  border-color: transparent;
  color: #fff;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 0.82rem; }

.results { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-elev-2);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.card-body { flex: 1; min-width: 0; }
.card-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.card-meta .arrow { color: var(--accent); margin: 0 4px; }
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  margin-left: 8px;
}
.badge.save { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge.grow { background: rgba(255, 107, 107, 0.15); color: var(--danger); }
.badge.info { background: rgba(109, 139, 255, 0.15); color: var(--accent); }

.card-status { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.card.error { border-color: rgba(255, 107, 107, 0.4); }
.card.error .card-meta { color: var(--danger); }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

select:focus-visible, input:focus-visible, .btn:focus-visible, .dropzone:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sample-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 560px) {
  .hero h1 { font-size: 1.7rem; }
  .card { flex-wrap: wrap; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions .btn { flex: 1; }
}
