:root {
  --bg: #0b0c0f;
  --panel: #12141a;
  --panel-2: #171a22;
  --line: #232733;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #10b981;
  --accent-2: #34d399;
  --danger: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(16, 185, 129, 0.10), transparent 70%),
    var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 18px 40px;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 18px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 15px;
  color: var(--text);
}

.brand svg { width: 18px; height: 18px; color: var(--accent); }

.ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ghost:hover { border-color: #3a4152; background: rgba(255,255,255,.03); }

/* ---------- hero ---------- */

.hero { padding: 34px 0 22px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 8vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 700;
}
.hero h1 span {
  background: linear-gradient(92deg, var(--accent-2), #7dd3fc 60%, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

/* ---------- input ---------- */

.input-card {
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-top: 8px;
  transition: border-color .15s;
}
.input-card:focus-within { border-color: rgba(16,185,129,.55); }

#url {
  width: 100%;
  appearance: none;
  border: 1px solid transparent;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 14px 13px;
  border-radius: 11px;
  outline: none;
  text-overflow: ellipsis;
}
#url::placeholder { color: #5c6478; }
#url:focus { border-color: rgba(16,185,129,.4); }

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

.paste, .go {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 14.5px;
  font-weight: 650;
  border-radius: 11px;
  cursor: pointer;
  padding: 13px 18px;
  white-space: nowrap;
  transition: transform .1s, filter .15s, background .15s;
}
.paste { background: var(--panel-2); color: var(--muted); }
.paste:hover { color: var(--text); }
.go { flex: 1; background: var(--accent); color: #04120c; }
.go:hover { filter: brightness(1.08); }
.paste:active, .go:active { transform: scale(.98); }
.go[disabled] { opacity: .55; cursor: default; }

/* ---------- status ---------- */

.status {
  min-height: 20px;
  margin: 12px 2px 0;
  font-size: 13.5px;
  color: var(--muted);
}
.status.error { color: var(--danger); }
.status.busy { color: var(--accent-2); }

.status.busy::after {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-left: 8px;
  border-radius: 50%;
  border: 2px solid rgba(52,211,153,.3);
  border-top-color: var(--accent-2);
  animation: spin .7s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- result ---------- */

.result {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 16px;
  animation: rise .22s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.thumb {
  width: 92px; height: 122px;
  border-radius: 11px;
  overflow: hidden;
  background: var(--panel-2);
  position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.meta { min-width: 0; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.25);
  padding: 3px 8px;
  border-radius: 999px;
}

.meta h2 {
  margin: 8px 0 4px;
  font-size: 15.5px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#byline { margin: 0; font-size: 13px; color: var(--accent-2); }
.facts { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.primary, .secondary {
  appearance: none;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .1s, filter .15s, background .15s;
}
.primary svg { width: 17px; height: 17px; }

.primary {
  flex: 1 1 180px;
  padding: 14px 18px;
  font-size: 15px;
  background: var(--accent);
  color: #04120c;
}
.primary:hover { filter: brightness(1.08); }

.secondary {
  flex: 0 1 auto;
  padding: 14px 16px;
  font-size: 13.5px;
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--line);
}
.secondary:hover { background: #1d212b; }
.primary:active, .secondary:active { transform: scale(.98); }

/* ---------- how ---------- */

.how {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18,20,26,.5);
  padding: 0 16px;
}
.how summary {
  cursor: pointer;
  padding: 14px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.how summary::-webkit-details-marker { display: none; }
.how summary::before { content: "+ "; color: var(--accent); }
.how[open] summary::before { content: "− "; }
.how ol { margin: 0 0 10px; padding-left: 20px; font-size: 13.5px; line-height: 1.7; color: #c3c8d4; }
.how .tiny { margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.55; }

/* ---------- recent ---------- */

.recent { margin-top: 28px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.recent h3 { margin: 0; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.tiny-btn { padding: 5px 11px; font-size: 11.5px; }

#recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
#recent::-webkit-scrollbar { display: none; }

#recent li { flex: 0 0 auto; width: 76px; }
#recent button {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  color: inherit;
}
#recent img {
  width: 76px; height: 100px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: border-color .15s;
}
#recent button:hover img { border-color: rgba(16,185,129,.5); }
#recent span {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- footer ---------- */

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: #5c6478;
}
.net { display: inline-flex; align-items: center; gap: 6px; }
.foot-right { display: inline-flex; align-items: center; gap: 14px; }
footer a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted #3a4152; }
footer a:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }
.net::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(16,185,129,.8);
}
.net.off::before { background: var(--danger); box-shadow: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: #1b1f29;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 40px);
  text-align: center;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (min-width: 560px) {
  .result { grid-template-columns: 132px 1fr; }
  .thumb { width: 132px; height: 176px; }
}
