:root {
  --bg: #0a0a0f;
  --surface: #15151f;
  --surface-2: #1e1e2b;
  --text: #f4f4f8;
  --muted: #9a9ab0;
  --accent: #d6336c;
  --accent-2: #f06595;
  --danger: #ff6b6b;
  --ok: #51cf66;
  --border: #2a2a3a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 20px 40px;
}

.head { text-align: center; margin-bottom: 28px; }

.brand {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

.form { display: flex; gap: 10px; flex-wrap: wrap; }

.input {
  flex: 1 1 100%;
  padding: 15px 16px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: #5a5a72; }

.btn {
  flex: 1 1 100%;
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: progress; }

.btn-ghost {
  flex: 0 0 auto;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.opts { margin-top: 12px; }
.opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.select {
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.select:focus { border-color: var(--accent); }

.status {
  margin: 18px 2px 0;
  font-size: 14px;
  min-height: 20px;
}
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }
.status.loading { color: var(--muted); }

.result { margin-top: 26px; }
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.meta { color: var(--muted); font-size: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 440px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

.cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cell img, .cell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cell .dl {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: rgba(10, 10, 15, 0.78);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  backdrop-filter: blur(4px);
}
.badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  background: rgba(10, 10, 15, 0.78);
  color: var(--accent-2);
}

.history { margin-top: 34px; }
.history-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 12px;
}
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.history-item:active { border-color: var(--accent); }
.hi-label { font-size: 14px; font-weight: 600; color: var(--text); }
.hi-meta { font-size: 12px; color: var(--muted); }
