:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #ecebe7;
  --text: #1d2125;
  --muted: #6b7178;
  --line: #dedcd6;
  --accent: #3e5566;
  --accent-ink: #ffffff;
  --steel: linear-gradient(135deg, #c9d0d6 0%, #8d99a3 45%, #dfe4e8 60%, #7b8892 100%);
  --good: #2f7a4d;
  --warn: #9a5b12;
  --danger: #b03a2e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 25, .06), 0 4px 14px rgba(20, 22, 25, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141618;
    --surface: #1c1f22;
    --surface-2: #25292d;
    --text: #e8eaec;
    --muted: #949ba2;
    --line: #2f3439;
    --accent: #9fb4c4;
    --accent-ink: #12161a;
    --good: #6fc492;
    --warn: #e0a85a;
    --danger: #e3786c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }

/* En-tête */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; font-size: 17px; }
.brand svg { width: 26px; height: 26px; fill: var(--accent); }
.brand svg .in { fill: var(--bg); opacity: .75; }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 14px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tabs button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 550; padding: 6px 14px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.count { font-size: 12px; background: var(--line); color: var(--text); border-radius: 99px; padding: 0 7px; min-width: 20px; text-align: center; }

/* Vues */
main { padding-top: 28px; padding-bottom: 40px; min-height: 70vh; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 4px; font-weight: 680; }
.view-head p { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 260px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 11px; outline: none; min-height: 38px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.result-count { margin: 0 0 14px; font-size: 13px; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; min-height: 38px;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { color: var(--danger); }

/* Grille de cartes */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(20, 22, 25, .1); }
.cover { position: relative; aspect-ratio: 4 / 5; background: var(--steel); overflow: hidden; display: block; }
.cover img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; background: var(--surface-2); }
.badges { z-index: 2; }
.cover .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: #2a3138; font-weight: 650; font-size: 15px; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 6px; background: rgba(15, 18, 21, .72); color: #fff; backdrop-filter: blur(4px); }
.badge.new { background: #b03a2e; }
.badge.owned { background: var(--good); }
.badge.wish { background: #8a6d1f; }

.body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.title { font-weight: 640; font-size: 15px; line-height: 1.3; margin: 0; letter-spacing: -.005em; }
.title a { text-decoration: none; }
.title a:hover { text-decoration: underline; }
.date { font-size: 13px; font-weight: 600; color: var(--accent); }
.date.past { color: var(--muted); font-weight: 500; }
.meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.meta span:not(:last-child)::after { content: "·"; margin-left: 8px; }
.update { font-size: 12px; color: var(--warn); line-height: 1.35; }
.notes { font-size: 12.5px; color: var(--muted); white-space: pre-line; }
.card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.card-actions button {
  flex: 1; font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 4px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text);
}
.card-actions button:hover { background: var(--surface-2); }
.card-actions button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.src { font-size: 11px; color: var(--muted); text-transform: lowercase; }

.more { display: flex; justify-content: center; margin-top: 24px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* Stats */
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 6px; }
.stat b { font-size: 20px; display: block; letter-spacing: -.02em; }
.stat span { font-size: 12.5px; color: var(--muted); }

/* Menu */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; min-width: 190px; z-index: 5; display: flex; flex-direction: column; }
.menu-pop button, .menu-pop .as-btn { font: inherit; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.menu-pop button:hover, .menu-pop .as-btn:hover { background: var(--surface-2); }

/* Compte */
.top-inner .tabs { margin-left: auto; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.account .menu-pop { min-width: 230px; }
.menu-info { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; word-break: break-all; }
.sync { font-size: 12px; color: var(--muted); }
.sync.ok { color: var(--good); }
.sync.err { color: var(--danger); }
.btn.signed::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 7px; vertical-align: 1px; }
.small-text { font-size: 13.5px; margin: -8px 0 14px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-msg { font-size: 13.5px; margin: 12px 0 0; min-height: 1em; }
.form-msg.err { color: var(--danger); }
.form-msg.ok { color: var(--good); }
.link { background: none; border: 0; padding: 0; font: inherit; font-size: 13.5px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Dialogue */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 18, 21, .45); backdrop-filter: blur(2px); }
dialog form { padding: 22px; }
dialog h2 { margin: 0 0 16px; font-size: 19px; letter-spacing: -.01em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid label > * { font-weight: 400; color: var(--text); }
.span2 { grid-column: span 2; }
.dlg-actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.spacer { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 550; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.foot { padding-top: 20px; padding-bottom: 40px; font-size: 13px; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .wrap { padding: 0 14px; }
  .top-inner { height: auto; padding: 10px 14px; flex-direction: column; align-items: stretch; gap: 8px; }
  .brand em { display: none; }
  .tabs button { flex: 1; justify-content: center; padding: 6px 8px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .toolbar select { flex: 1 1 45%; }
  .card-actions { flex-direction: column; }
  .card-actions button { padding: 7px 4px; }
  h1 { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
