:root {
  --bg: #f5f5f7; --card: #ffffff; --ink: #1d1d1f; --grey: #86868b;
  --sep: #d2d2d7; --fill: #f2f2f7; --fill-2: #e8e8ed;
  --blue: #0071e3; --blue-hover: #0058b9; --blue-soft: #e8f1fd;
  --green: #34c759; --green-hover: #28a746;
  --red: #ff3b30; --orange: #ff9500;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);
}
[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --ink: #f5f5f7; --grey: #98989d;
  --sep: #38383a; --fill: #2c2c2e; --fill-2: #3a3a3c;
  --blue: #0a84ff; --blue-hover: #409cff; --blue-soft: #0a2540;
  --green: #30d158; --green-hover: #4ade7b;
  --red: #ff453a; --orange: #ff9f0a;
  --shadow: none;
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

.theme-btn {
  position: fixed; top: 18px; right: 18px; z-index: 60;
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--fill); color: var(--grey); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.theme-btn:hover { color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }

.btn {
  border: none; border-radius: 999px; font-family: inherit;
  font-size: 15px; font-weight: 600; padding: 12px 22px;
  cursor: pointer; letter-spacing: -.01em;
  transition: background .18s ease;
  color: var(--ink); background: var(--fill);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: var(--green-hover); }
.btn-soft:hover { background: var(--fill-2); }
.btn-ghost { background: none; color: var(--grey); font-weight: 500; }
.btn-ghost:hover { color: var(--red); }

.fld { margin-bottom: 15px; }
.fld label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--grey); margin-bottom: 7px; letter-spacing: -.01em;
}
.fld input, .fld select {
  width: 100%; padding: 14px 15px; border: none; border-radius: 12px;
  background: var(--fill); color: var(--ink); font-family: inherit; font-size: 16px;
  outline: 2px solid transparent; outline-offset: -2px;
  transition: outline-color .15s ease, background .25s ease;
}
.fld input:focus, .fld select:focus { outline-color: var(--blue); }
.fld input::placeholder { color: var(--grey); opacity: .6; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(140%);
  background: var(--ink); color: var(--bg);
  padding: 13px 22px; border-radius: 999px; font-size: 15px; font-weight: 500;
  z-index: 90; transition: transform .3s cubic-bezier(.3,1.3,.5,1); pointer-events: none;
  max-width: 90vw;
}
.toast.on { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); color: #fff; }

/* Fenêtres modales — remplacent alert()/confirm()/prompt() natifs */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .16s ease;
}
.modal-overlay.on { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--card); border-radius: 20px; padding: 26px;
  max-width: 420px; width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,0.35);
  transform: translateY(10px) scale(.97);
  transition: transform .18s cubic-bezier(.2,.9,.3,1.1);
}
.modal-overlay.on .modal-box { transform: translateY(0) scale(1); }
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 10px; color: var(--ink); }
.modal-message { font-size: 14.5px; color: var(--grey); line-height: 1.55; margin: 0 0 20px; white-space: pre-line; }
.modal-input {
  width: 100%; padding: 13px 15px; border: none; border-radius: 12px;
  background: var(--fill); color: var(--ink); font-family: inherit; font-size: 15px;
  outline: 2px solid transparent; outline-offset: -2px; margin-bottom: 16px;
}
.modal-input:focus { outline-color: var(--blue); }
.modal-error { color: var(--red); font-size: 13px; margin: -10px 0 14px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding: 13px; font-size: 14.5px; }
.modal-danger-btn { background: var(--red) !important; color: #fff !important; }
