:root {
  /* Couleurs Yima (reprises du logo) */
  --brand-cyan: #22c8ff;
  --brand-blue: #2f6bff;
  --brand-violet: #a42cf5;
  --gradient: linear-gradient(135deg, var(--brand-cyan), var(--brand-blue) 45%, var(--brand-violet));

  /* Thème sombre (par défaut) */
  color-scheme: dark;
  --bg: #0a0c1a;
  --panel: #12152a;
  --hover: #1c2142;
  --border: #272d52;
  --text: #e9ecf8;
  --muted: #8a91b4;
  --link: #22c8ff;
  --header-bg: rgba(10, 12, 26, .85);
  --accent: #4a63ff;
  --danger: #ff5c7a;
  --ok: #2ed39a;
  --warn: #ffb547;
  --stars: #ffc93c;
  --radius: 14px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Thème clair : suit le système (mode « Auto »), ou forcé par le bouton (data-theme sur <html>) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f7fc;
    --panel: #ffffff;
    --hover: #eef1fa;
    --border: #dde2f0;
    --text: #141833;
    --muted: #5d6485;
    --link: #0b78c2;
    --header-bg: rgba(245, 247, 252, .85);
    --danger: #d4284d;
    --ok: #0f9a6c;
    --warn: #b86e00;
    --stars: #e0a100;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fc;
  --panel: #ffffff;
  --hover: #eef1fa;
  --border: #dde2f0;
  --text: #141833;
  --muted: #5d6485;
  --link: #0b78c2;
  --header-bg: rgba(245, 247, 252, .85);
  --danger: #d4284d;
  --ok: #0f9a6c;
  --warn: #b86e00;
  --stars: #e0a100;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); line-height: 1.55; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
p { margin: 0 0 1em; }
img { max-width: 100%; }
code, pre, textarea.code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.gradient-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- En-tête et pied de page ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--header-bg); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.site-header .container { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.site-nav { margin-left: auto; display: flex; gap: 18px; flex-wrap: wrap; }
.site-nav a { color: var(--muted); }
.site-nav a:hover, .site-nav a.active { color: var(--text); text-decoration: none; }
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 28px 0; color: var(--muted); font-size: .9rem; }
.site-footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- Boutons, badges, cartes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--gradient); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: .85rem; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--hover); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.new { background: color-mix(in srgb, var(--link) 15%, transparent); color: var(--link); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.stars { color: var(--stars); letter-spacing: 2px; }
.flash { padding: 12px 16px; border-radius: 10px; margin: 16px 0; border: 1px solid var(--border); }
.flash.success { background: rgba(46, 211, 154, .12); border-color: rgba(46, 211, 154, .4); }
.flash.error { background: rgba(255, 92, 122, .12); border-color: rgba(255, 92, 122, .4); }

/* ---------- Accueil ---------- */
.hero { padding: 72px 0 40px; text-align: center; }
.hero p { color: var(--muted); font-size: 1.15rem; max-width: 640px; margin-inline: auto; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.app-card { display: flex; flex-direction: column; gap: 12px; color: var(--text); transition: transform .15s, border-color .15s; }
.app-card:hover { transform: translateY(-3px); border-color: var(--brand-blue); text-decoration: none; }
.app-card h3 { margin: 0; }
.app-card p { color: var(--muted); margin: 0; flex: 1; }
.app-icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 30px; background: var(--hover); overflow: hidden; flex-shrink: 0; }
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-icon.large { width: 96px; height: 96px; font-size: 52px; border-radius: 22px; }

/* ---------- Page application ---------- */
.app-header { display: flex; gap: 24px; align-items: center; padding: 48px 0 24px; flex-wrap: wrap; }
.app-header .tagline { color: var(--muted); font-size: 1.1rem; margin: 0; }
.app-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.description { white-space: pre-line; }
.download-box h2 { font-size: 1.1rem; }
.download-box .btn { width: 100%; margin-bottom: 10px; }
.release { border-top: 1px solid var(--border); padding: 14px 0; }
.release:first-of-type { border-top: 0; }
.release-notes { white-space: pre-line; color: var(--muted); margin: 6px 0 0; }
.feedback { border-top: 1px solid var(--border); padding: 16px 0; }
.feedback header { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.feedback p { white-space: pre-line; margin: 6px 0 0; }
section.block { margin-top: 32px; }

/* ---------- Formulaires ---------- */
form > div, .field { margin-bottom: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-blue); outline-offset: 0; border-color: transparent; }
textarea.code { min-height: 460px; font-size: .88rem; line-height: 1.5; tab-size: 2; }
.form-help, .help-text { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.form-error, ul li.form-error, form ul { color: var(--danger); font-size: .9rem; }
form ul { padding-left: 18px; margin: 6px 0 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-blue); }
.rating-choice > div, #feedback_rating { display: flex; gap: 14px; flex-wrap: wrap; }
#feedback_rating label { display: inline; font-weight: 500; margin: 0 0 0 4px; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Administration ---------- */
.admin { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-side { background: var(--panel); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.admin-side .brand { margin: 0 8px 18px; }
.admin-side a.nav { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--muted); }
.admin-side a.nav:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.admin-side a.nav.active { background: var(--hover); color: var(--text); box-shadow: inset 3px 0 0 var(--brand-blue); }
.admin-side .spacer { flex: 1; }
.admin-main { padding: 28px 32px; min-width: 0; }
.admin-main > header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-main > header h1 { font-size: 1.7rem; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat .value { font-size: 2rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
td form { display: inline; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filters > div { margin: 0; min-width: 160px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; word-break: break-all; }
.login-box { max-width: 400px; margin: 10vh auto; }
details summary { cursor: pointer; color: var(--link); }
.grid-2 { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }

@media (max-width: 860px) {
  .app-layout, .grid-2 { grid-template-columns: 1fr; }
  .admin { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .admin-side .spacer { display: none; }
  .admin-main { padding: 20px 16px; }
}

/* ---------- Bouton de thème ---------- */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; line-height: 1; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.theme-toggle:hover { color: var(--text); background: var(--hover); }
.admin-side .theme-toggle { margin: 6px 8px; justify-content: center; }
.theme-toggle svg, .password-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.theme-toggle svg { display: none; }
.theme-toggle[data-mode="auto"] [data-icon="auto"],
.theme-toggle[data-mode="light"] [data-icon="light"],
.theme-toggle[data-mode="dark"] [data-icon="dark"] { display: block; }

/* ---------- Afficher / masquer le mot de passe ---------- */
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-field input::-ms-reveal, .password-field input::-ms-clear { display: none; }
.password-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.password-toggle:hover { color: var(--text); background: var(--hover); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle [data-icon="hide"], .password-toggle[aria-pressed="true"] [data-icon="show"] { display: none; }
.password-toggle[aria-pressed="true"] [data-icon="hide"] { display: block; }
