:root {
  --bg: #0b0d10;
  --bg-elevated: #14171c;
  --surface: #1b1f26;
  --surface-2: #21262e;
  --border: #262b33;
  --text: #edeef0;
  --text-muted: #8a8f98;
  --accent: #7c5cfc;
  --accent-soft: rgba(124, 92, 252, 0.16);
  --accent-line: rgba(124, 92, 252, 0.55);
  --success: #34e2c6;
  --success-soft: rgba(52, 226, 198, 0.14);
  --error: #ff5c5c;
  --error-soft: rgba(255, 92, 92, 0.12);
  --radius: 18px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100svh;
  display: flex;
  justify-content: center;
  background-image:
    radial-gradient(circle at 15% 0%, rgba(124, 92, 252, 0.09), transparent 45%),
    radial-gradient(circle at 85% 100%, rgba(52, 226, 198, 0.06), transparent 45%);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.app {
  width: 100%;
  max-width: 560px;
  padding: 32px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
  z-index: 1;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 4px 0;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand .dot {
  color: var(--accent);
}

.tag {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ---------- Card ---------- */

.card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 24px 26px;
  overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}

.perforation {
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  background-image: radial-gradient(circle, var(--bg) 3.5px, transparent 3.6px);
  background-size: 22px 18px;
  background-position: 11px center;
  background-repeat: repeat-x;
}

.perforation--top { top: 0; }
.perforation--bottom { bottom: 0; }

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  pointer-events: none;
}

.scanline.active {
  opacity: 1;
  animation: scan 1.4s ease-in-out infinite;
}

@keyframes scan {
  0%   { top: 18px; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 18px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .scanline.active { animation: none; opacity: 0.6; top: 50%; }
}

/* ---------- Form ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
}

.label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: lowercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.input-row {
  display: flex;
  gap: 8px;
}

input#url {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input#url::placeholder { color: #565c66; }

input#url:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}

.row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.hint {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  padding: 12px 22px;
}

.btn--primary:hover { background: #8c6dff; }
.btn--primary:disabled { opacity: 0.55; cursor: progress; }

.btn--ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 46px;
  flex-shrink: 0;
}

.btn--ghost:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Status ---------- */

.status {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status.info {
  background: var(--accent-soft);
  color: #c3b6ff;
}

.status.error {
  background: var(--error-soft);
  color: #ff9d9d;
}

.hidden { display: none !important; }

/* ---------- Result ---------- */

.result {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.media-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  aspect-ratio: 4 / 5;
}

.media-tile img,
.media-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-tile .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(11, 13, 16, 0.72);
  backdrop-filter: blur(4px);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
}

.media-tile a.dl {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

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

/* ---------- History ---------- */

.history {
  padding: 0 4px;
}

.history-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  text-transform: lowercase;
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.history-list li:hover { border-color: var(--accent); color: var(--text); }

.history-list li span.url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-list .clear {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ---------- Footer ---------- */

.footer {
  text-align: center;
  padding: 4px 10px 0;
}

.footer p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #565c66;
}

@media (max-width: 380px) {
  .card { padding: 30px 16px 22px; }
  .brand { font-size: 24px; }
}
