:root {
  color-scheme: light dark;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef1f2;
  --text: #17191c;
  --muted: #687078;
  --border: #d8dde1;
  --accent: #0dbd8b;
  --accent-strong: #07966f;
  --danger: #d14343;
  --shadow: 0 10px 30px rgba(20, 28, 34, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151718;
    --surface: #202224;
    --surface-2: #2a2d2f;
    --text: #f4f6f7;
    --muted: #a9b0b5;
    --border: #3a3e41;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
}

.connection {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.search input {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.search button,
.more {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #06251c;
  font-weight: 750;
  padding: 10px 15px;
}

.search button:hover:not(:disabled),
.more:hover:not(:disabled) {
  background: var(--accent-strong);
  color: white;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 13px;
}

.tab.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.notice {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px;
  color: var(--muted);
}

.notice.error {
  border-color: var(--danger);
  color: var(--danger);
}

.grid {
  columns: 3 180px;
  column-gap: 10px;
}

.gif-card {
  width: 100%;
  display: inline-block;
  position: relative;
  overflow: hidden;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  break-inside: avoid;
}

.gif-card img {
  width: 100%;
  min-height: 90px;
  display: block;
  object-fit: cover;
}

.gif-card::after {
  content: "Envoyer";
  position: absolute;
  right: 8px;
  bottom: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: 120ms ease;
}

.gif-card:hover::after,
.gif-card:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.gif-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.gif-card.busy {
  opacity: 0.55;
  pointer-events: none;
}

.more {
  display: block;
  margin: 16px auto 6px;
}

footer {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.75rem;
}

footer strong {
  color: var(--text);
  letter-spacing: 0.08em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: #111;
  color: white;
  padding: 10px 16px;
  box-shadow: var(--shadow);
  transition: 180ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .app {
    padding: 12px;
  }

  .search {
    grid-template-columns: 1fr;
  }

  .grid {
    columns: 2 140px;
  }
}

.more[hidden] {
  display: none !important;
}
