:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --border: #143d14;
  --fg: #33cc33;
  --fg-dim: #1a8c1a;
  --muted: #4d9e4d;
  --white: #ffffff;
  --red: #f43f4f;
  --blue-light: #75aadb;
  --blue: #3a75c4;
  --teal: #008789;
  --teal-dark: #006663;
  --cyan: #007272;
  --error: #f43f4f;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "Cascadia Code", "Consolas", "Liberation Mono", "SFMono-Regular", Menlo, monospace;
  padding: clamp(16px, 5vw, 40px) clamp(12px, 4vw, 24px) 60px;
  overflow-x: hidden;
}

.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.topbar {
  color: var(--teal);
  font-weight: 900;
  text-align: center;
  font-size: clamp(0.65rem, 2.6vw, 0.85rem);
  letter-spacing: 0.03em;
  padding: 8px 4px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: clamp(20px, 5vw, 32px);
  word-break: break-word;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  margin-bottom: 20px;
}

.logo-plaque {
  position: relative;
  display: inline-block;
  padding: 9px 14px;
  border-radius: 3px;
  text-decoration: none;
  cursor: crosshair;
  background-image:
    linear-gradient(135deg, #4a4a4a, #1c1c1c),
    radial-gradient(circle at 7px 7px, #999 0%, #555 55%, transparent 70%),
    radial-gradient(circle at calc(100% - 7px) 7px, #999 0%, #555 55%, transparent 70%),
    radial-gradient(circle at 7px calc(100% - 7px), #999 0%, #555 55%, transparent 70%),
    radial-gradient(circle at calc(100% - 7px) calc(100% - 7px), #999 0%, #555 55%, transparent 70%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.7),
    0 2px 6px rgba(0, 0, 0, 0.6);
}

.logo {
  display: block;
  height: 36px;
  width: auto;
  filter: contrast(1.1);
}

h1 {
  margin: 0;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  font-weight: 400;
  color: var(--red);
  line-height: 1.3;
}

h1 strong {
  font-weight: 900;
  color: var(--white);
}

h1 strong em {
  font-style: italic;
  color: var(--white);
}

.manifesto {
  color: var(--fg-dim);
  font-size: clamp(0.82rem, 2.6vw, 0.92rem);
  line-height: 1.6;
  text-align: justify;
  margin-bottom: clamp(20px, 5vw, 32px);
  padding: 0 4px;
}

.manifesto .nuancier {
  color: var(--cyan);
  font-weight: 900;
}

.manifesto .version {
  font-style: italic;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: clamp(16px, 4vw, 24px);
  margin-bottom: 18px;
}

.field {
  margin-bottom: 18px;
}

.suggest-wrap {
  position: relative;
}

.suggest-box {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 5;
  background: #000000;
  border: 1px solid var(--teal);
  border-top: none;
}

.suggest-item {
  padding: 10px 12px;
  font-size: 0.95rem;
  color: var(--fg);
  cursor: crosshair;
  border-top: 1px solid var(--border);
}

.suggest-item:hover {
  background: var(--panel);
  color: var(--white);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 480px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--fg);
}

.hint {
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  font-size: 0.78rem;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: #000000;
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--teal);
}

input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--teal);
}

button {
  width: 100%;
  min-height: 48px;
  padding: 13px;
  border: 1px solid #ff0000;
  background: #ff0000;
  color: var(--white);
  font-family: inherit;
  font-weight: 900;
  font-size: 1rem;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  cursor: crosshair;
  transition: background-color 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) { background: #0000ff; border-color: #0000ff; }
button:disabled { opacity: 0.5; cursor: wait; }

.loading {
  display: none;
  text-align: center;
  margin: 14px 0 0;
}

.loading img {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.fallback-note {
  text-align: center;
  color: var(--teal);
  font-style: italic;
  font-size: 0.82rem;
  margin: 0 0 10px;
}

.error {
  border-color: var(--error);
  color: var(--error);
  text-align: center;
}

.result {
  text-align: center;
  padding: 12px;
}

.result img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid var(--border);
}

.gallery-heading {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  text-align: center;
  text-transform: lowercase;
}

.gallery-empty {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
  margin: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  align-items: start;
}

/* reinitialise le style de bouton generique (rouge pleine largeur) pour ces
   vignettes cliquables */
.gallery-item {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--border);
  background: #000000;
  display: block;
  text-align: left;
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  cursor: crosshair;
  overflow: hidden;
  transition: border-color 0.15s;
}

.gallery-item:hover,
.gallery-item.playing {
  border-color: var(--teal);
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.gallery-caption {
  display: block;
  padding: 5px 6px 6px;
  font-size: 0.68rem;
  line-height: 1.4;
  overflow: hidden;
}

.gallery-pseudo {
  display: block;
  color: var(--fg);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-query {
  display: block;
  color: var(--teal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-date {
  display: block;
  color: var(--muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

footer .about { font-style: italic; }

footer a {
  color: var(--blue-light);
}

footer a:hover { color: var(--red); }

@media (max-width: 380px) {
  .logo { height: 32px; }
}

.archive-nav-back {
  text-align: center;
  font-size: 0.85rem;
  margin: -4px 0 18px;
}

.gallery .archive-nav-back {
  margin: 20px 0 0;
}

.archive-nav-back a,
.archive-pagination a,
.archive-perpage a {
  color: var(--teal);
  text-decoration: none;
}

.archive-nav-back a:hover,
.archive-pagination a:hover,
.archive-perpage a:hover {
  color: var(--red);
}

.archive-info {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 14px;
}

.archive-perpage {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.archive-perpage-active {
  color: var(--white);
  font-weight: 700;
}

.archive-item {
  border: 1px solid var(--border);
  background: #000000;
  overflow: hidden;
}

.archive-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.archive-item .gallery-caption {
  display: block;
  padding: 5px 6px 2px;
  font-size: 0.68rem;
  line-height: 1.4;
  overflow: hidden;
}

.archive-download {
  display: block;
  text-align: center;
  padding: 4px 6px 6px;
  font-size: 0.68rem;
  color: var(--teal);
  text-decoration: none;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.archive-download:hover { color: var(--red); }

.archive-pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  font-size: 0.9rem;
}

.archive-pagination-disabled {
  color: var(--border);
}
