/* Catpiccino — ambiance café : crème, caramel, expresso. */
:root {
  --bg: #f7f1e8;
  --surface: #fffaf3;
  --ink: #3b2a20;
  --muted: #8a7466;
  --line: #e6d8c6;
  --accent: #9c5b2e;
  --accent-ink: #fff;
  --ok-bg: #e5f2e3;
  --ok-ink: #2f5d2a;
  --err-bg: #f8e1dc;
  --err-ink: #8a2d1b;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1714;
    --surface: #2a211c;
    --ink: #f1e6da;
    --muted: #b09d8f;
    --line: #43362e;
    --accent: #d18a52;
    --accent-ink: #1d1714;
    --ok-bg: #1f3320;
    --ok-ink: #b5dcae;
    --err-bg: #3d211b;
    --err-ink: #f2b5a6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
.muted { color: var(--muted); font-weight: normal; }
.hint { display: block; color: var(--muted); font-size: .85rem; font-weight: normal; }
.optional { color: var(--muted); font-weight: normal; font-size: .85rem; }
.mono { font-family: ui-monospace, monospace; font-size: .85rem; }

/* En-tête */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1.5rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: .25rem 0; border-bottom: 2px solid transparent; }
.topbar nav a.active, .topbar nav a:hover { color: var(--ink); border-color: var(--accent); }
.me { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.me img { border-radius: 50%; }
.me form { margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.breadcrumb { margin: 0 0 .5rem; font-size: .9rem; }

/* Messages */
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin: 0 0 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.err { background: var(--err-bg); color: var(--err-ink); }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* Boutons et champs */
button, .button {
  display: inline-block;
  font: inherit;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--err-ink); border-color: var(--err-ink); color: #fff; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

label { display: block; font-weight: 600; margin-bottom: 1rem; }
:where(input:not([type=hidden]):not([type=file]), select, textarea) {
  display: block;
  width: 100%;
  margin-top: .25rem;
  padding: .5rem .6rem;
  font: inherit;
  font-weight: normal;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input[type=file] { display: block; margin-top: .4rem; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .7; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.danger-zone { border-color: var(--err-bg); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.filters input, .filters select { width: auto; flex: 1 1 160px; margin: 0; }
form.inline { display: flex; gap: .5rem; align-items: center; margin: 0; }
form.inline select { width: auto; margin: 0; }

/* Badges et statuts */
.badge { display: inline-block; font-size: .8rem; padding: .1rem .5rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.badge.staff { border-color: var(--accent); color: var(--accent); }
.status { font-size: .85rem; font-weight: 600; padding: .2rem .7rem; border-radius: 99px; }
.status.pending { background: #f6e3b4; color: #6b4b00; }
.status.accepted { background: var(--ok-bg); color: var(--ok-ink); }
.status.refused { background: var(--err-bg); color: var(--err-ink); }

/* Onglets */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--accent); }

/* File de modération */
.queue { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.queue a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.queue a:hover { border-color: var(--accent); }
.queue img, .series-icon { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; }
.series-icon { display: grid; place-items: center; font-size: 2rem; background: var(--bg); }
.queue-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.queue-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; font-size: .85rem; text-align: right; }
@media (max-width: 600px) {
  .queue a { flex-wrap: wrap; }
  .queue-meta { align-items: flex-start; text-align: left; width: 100%; }
}

/* Recadrage */
.crop-tool { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 1rem; margin-bottom: 1.25rem; }
.crop-area { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; max-height: 70vh; }
.crop-area img { display: block; max-width: 100%; }
.crop-side .label { font-weight: 600; margin: 0 0 .5rem; }
.crop-preview { width: 200px; height: 200px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line); }
@media (max-width: 700px) {
  .crop-tool { grid-template-columns: 1fr; }
}
img.original { max-width: min(100%, 480px); border-radius: var(--radius); margin-bottom: 1rem; }

/* Catalogue */
.card-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.card-grid a {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: .5rem;
  background: var(--surface);
  border: 2px solid var(--rarity, var(--line));
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.card-grid img { width: 100%; height: auto; aspect-ratio: 1; border-radius: 6px; margin-bottom: .4rem; }
.card-grid strong { line-height: 1.25; }
.card-grid .muted { font-size: .85rem; }
.card-number { position: absolute; top: .9rem; left: .9rem; font-size: .75rem; background: rgb(0 0 0 / .6); color: #fff; padding: 0 .4rem; border-radius: 4px; }
.card-foot { display: flex; justify-content: space-between; margin-top: auto; padding-top: .4rem; font-size: .8rem; }
.card-grid .retired { opacity: .55; }
.card-grid .badge { position: absolute; top: .9rem; right: .9rem; }
.pager { display: flex; justify-content: center; gap: 1.5rem; margin-top: 1.5rem; }

.card-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .card-layout { grid-template-columns: 1fr; } }
.card-preview { margin: 0 0 1rem; border: 3px solid var(--rarity); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.card-preview img { display: block; width: 100%; height: auto; }
.card-preview figcaption { padding: .4rem .7rem; font-weight: 600; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 0 0 1rem; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.details { max-width: 360px; word-break: break-word; font-size: .8rem; color: var(--muted); }

/* Accueil */
.welcome { max-width: 480px; margin: 4rem auto; text-align: center; }
.welcome h1 { font-size: 2.2rem; }
.welcome .button { margin: 1rem 0; }
