:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e5ea;
  --text: #16181d;
  --muted: #6b7180;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eef0ff;
  --danger: #c2272d;
  --ok: #157f3b;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --border: #2c3039;
    --text: #e8eaee;
    --muted: #979dab;
    --accent: #8b85ff;
    --accent-text: #0f1020;
    --accent-soft: #23243d;
    --danger: #ff6b6f;
    --ok: #4ccf7c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 18px; letter-spacing: -0.01em; }
.brand img { display: block; }

.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; background: none;
}
.btn:focus-visible, .drop:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); border-color: var(--border); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--surface); border-color: var(--border); }
.btn:disabled { opacity: .5; cursor: default; }

/* Connexion */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.login-card .brand { margin-bottom: 22px; }
.login-card form { display: grid; gap: 10px; }
.login-card label { font-weight: 550; font-size: 14px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.login-card input.pin { font-size: 24px; letter-spacing: .5em; text-align: center; padding-left: calc(12px + .5em); }
.login-card .btn { justify-content: center; padding: 10px; margin-top: 6px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }

/* Page principale */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 720px; margin: 0 auto; padding: 16px;
}
.topbar form { margin: 0; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 48px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 220px; padding: 24px; text-align: center; cursor: pointer;
  background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); transition: border-color .15s, background .15s;
}
.drop svg { color: var(--accent); margin-bottom: 4px; }
.drop strong { color: var(--text); font-size: 18px; font-weight: 600; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .hint { font-size: 13px; }
kbd {
  font: 12px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; background: var(--bg);
}

.uploads, .files { list-style: none; margin: 0; padding: 0; }
.uploads { margin-top: 12px; display: grid; gap: 8px; }
.uploads:empty { display: none; }
.up {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  display: grid; gap: 6px; font-size: 14px;
}
.up-head { display: flex; justify-content: space-between; gap: 12px; }
.up-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-head span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up.done .bar i { background: var(--ok); }
.up.fail { border-color: var(--danger); }
.up.fail .up-head span:last-child { color: var(--danger); }

.text-box { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.text-box summary { padding: 12px 16px; cursor: pointer; font-weight: 550; color: var(--muted); }
.text-box[open] summary { color: var(--text); }
.text-box textarea {
  display: block; width: calc(100% - 32px); margin: 0 16px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.text-box .btn { margin: 10px 16px 16px; }

h2 { font-size: 15px; font-weight: 600; margin: 32px 0 10px; display: flex; align-items: center; gap: 8px; }
.count {
  font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 1px 8px;
}
.count:empty { display: none; }

.files { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.files:empty { display: none; }
.file { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); }
.file:first-child { border-top: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted); font-size: 13px; }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.file.taken { opacity: .45; }
.file-text { flex-basis: 100%; }
.file.has-text { flex-wrap: wrap; }
.file-text textarea {
  width: 100%; min-height: 90px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); font: 13px/1.5 ui-monospace, monospace; resize: vertical;
}

.empty { color: var(--muted); margin: 0; padding: 14px; text-align: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.note { color: var(--muted); font-size: 13px; margin-top: 16px; }

.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent); backdrop-filter: blur(2px);
  pointer-events: none;
}
.overlay div {
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 18px;
  padding: 14px 24px; border-radius: 999px;
}
.overlay[hidden], .toast[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  font-size: 14px; max-width: calc(100% - 32px);
}

@media (max-width: 520px) {
  .drop { min-height: 170px; }
  .file { flex-wrap: wrap; }
  .file-actions { width: 100%; justify-content: flex-end; }
}
