/* ==========================================================================
   École — style inspiré d'Apple (sombre par défaut), même famille que Courses et Budget
   ========================================================================== */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #f0f0f3;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #5856d6;
  --accent-soft: rgba(88, 86, 214, 0.12);
  --green: #1f9d45;
  --green-soft: rgba(52, 199, 89, 0.14);
  --red: #d70015;
  --red-soft: rgba(255, 59, 48, 0.12);
  --orange: #b25000;
  --orange-soft: rgba(255, 149, 0, 0.16);
  --teal: #0b7a8a;
  --teal-soft: rgba(48, 176, 199, 0.14);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 22px;
  --blur-bg: rgba(245, 245, 247, 0.78);
}
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --text: #f5f5f7;
  --muted: #98989d;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #7d7aff;
  --accent-soft: rgba(94, 92, 230, 0.22);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --teal: #64d2ff;
  --teal-soft: rgba(100, 210, 255, 0.14);
  --shadow: none;
  --blur-bg: rgba(0, 0, 0, 0.72);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 12px;
  background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.hello { font-size: 13px; color: var(--muted); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn, .theme-toggle {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: none; background: var(--card-2); cursor: pointer;
  display: grid; place-items: center;
  transition: transform .15s ease, background .2s;
}
.icon-btn:active, .theme-toggle:active { transform: scale(.92); }
.icon-btn svg, .theme-toggle svg { width: 20px; height: 20px; }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle.floating { position: fixed; top: calc(16px + env(safe-area-inset-top)); right: 16px; }

/* ---------- Contenu ---------- */
.container { max-width: 560px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.view { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.card-head h2 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.label { font-size: 13px; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.link-btn { border: none; background: none; color: var(--accent); font-weight: 600; font-size: 15px; cursor: pointer; padding: 4px 0; white-space: nowrap; }
.link-btn.small { font-size: 13px; padding: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.hint:last-child { margin-bottom: 0; }
.empty { text-align: center; color: var(--muted); margin: 8px 0; font-size: 15px; }
.alert { background: var(--red-soft); color: var(--red); padding: 12px 14px; border-radius: 12px; font-size: 14px; }

/* ---------- Séances ---------- */
.session { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.card-head + .session, .day-head + .session { border-top: none; }
.session-time {
  flex: none; width: 52px; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums;
  font-size: 15px; display: flex; flex-direction: column;
}
.session-time span { font-weight: 500; color: var(--muted); font-size: 13px; }
.session-body { min-width: 0; flex: 1; border-left: 3px solid var(--accent); padding-left: 12px; }
.session-body strong { display: block; font-weight: 600; }
.session.ent .session-body { border-left-color: var(--teal); }
.session.now .session-body { background: var(--accent-soft); border-radius: 0 12px 12px 0; padding: 6px 10px 6px 12px; }
.session.past { opacity: .45; }
.tag {
  display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
}
.tag.bad { background: var(--red-soft); color: var(--red); }
.tag.warn { background: var(--orange-soft); color: var(--orange); }

/* ---------- Notes ---------- */
.note { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .note, #lastNotes > .note:first-child { border-top: none; }
.note-badge {
  flex: none; width: 64px; height: 50px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums;
  background: var(--card-2);
}
.note-badge small { font-size: 11px; font-weight: 600; opacity: .7; margin-left: 1px; }
.note-badge.good { background: var(--green-soft); color: var(--green); }
.note-badge.ok { background: var(--accent-soft); color: var(--accent); }
.note-badge.bad { background: var(--red-soft); color: var(--red); }
.note-badge.none { font-size: 12px; color: var(--muted); }
.note-body { min-width: 0; }
.note-body strong { font-weight: 600; }

.hero { text-align: center; padding: 24px 20px 20px; }
.big { font-size: 48px; font-weight: 700; letter-spacing: -0.03em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.big small { font-size: 20px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.big.good { color: var(--green); }
.big.bad { color: var(--red); }
.sub { font-size: 14px; color: var(--muted); }
.avg { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.avg.good { color: var(--green); }
.avg.ok { color: var(--accent); }
.avg.bad { color: var(--red); }
.subject + .subject { margin-top: 14px; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: none; cursor: pointer; padding: 8px 16px; border-radius: 999px;
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
}
.chip.active { background: var(--accent); color: #fff; }

/* ---------- Planning ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; }
.week-label { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.day { padding: 16px 20px; }
.day + .day { margin-top: 14px; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.day-head h2 { margin: 0; font-size: 17px; }
.day-head .tag { margin-top: 0; }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.none { margin: 4px 0 0; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; max-width: 140px; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0;
}
.tabbar button svg { width: 25px; height: 25px; }
.tabbar button.active { color: var(--accent); }

/* ---------- Réglages ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 560px; margin: 0 auto; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--card-2); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; text-align: center; }
.settings-list { background: var(--card-2); border-radius: 16px; margin-bottom: 16px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-top: 1px solid var(--line); width: 100%; text-align: left;
}
.settings-row:first-child { border-top: none; }
.settings-row .theme-toggle { background: var(--card); }
.settings-row.as-btn { border-left: none; border-right: none; border-bottom: none; background: none; cursor: pointer; color: var(--accent); }
.btn-small {
  flex: none; border: none; border-radius: 999px; padding: 8px 16px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
}
.btn-small:disabled { opacity: .4; }

/* ---------- Formulaires et boutons ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; padding-left: 4px; }
.field input {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: var(--card-2); border: 2px solid transparent; border-radius: 14px;
  padding: 14px 16px; outline: none; transition: border-color .2s; min-width: 0;
}
.field input:focus { border-color: var(--accent); }
.btn-primary, .btn-ghost {
  width: 100%; border: none; border-radius: 14px; padding: 15px;
  font-size: 17px; font-weight: 600; cursor: pointer; transition: transform .12s, opacity .2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--card-2); color: var(--red); }
.btn-primary:active, .btn-ghost:active { transform: scale(.98); }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 40; animation: fade .2s ease; white-space: nowrap;
}

/* ---------- Connexion ---------- */
.login-page { padding-bottom: 0; }
.login-wrap {
  min-height: 100vh; min-height: 100dvh; max-width: 400px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; text-align: center;
}
.login-logo { border-radius: 20px; margin-bottom: 14px; }
.login-wrap h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
.login-wrap .muted { margin: 6px 0 26px; }
.login-card { width: 100%; display: flex; flex-direction: column; gap: 14px; text-align: left; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

@media (max-width: 360px) {
  .topbar h1 { font-size: 28px; }
  .big { font-size: 40px; }
  .note-badge { width: 58px; }
}
