:root {
  --bg: #f4f1eb;
  --panel: rgba(255, 252, 246, .86);
  --panel-solid: #fffaf1;
  --text: #211a14;
  --muted: #75685d;
  --line: rgba(65, 48, 33, .13);
  --accent: #7c3f27;
  --accent-2: #b46a3c;
  --good: #2c7a4b;
  --bad: #a43d34;
  --shadow: 0 20px 70px rgba(58, 39, 21, .13);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(188, 115, 71, .22), transparent 24rem),
    radial-gradient(circle at 78% 8%, rgba(92, 66, 42, .16), transparent 28rem),
    linear-gradient(135deg, #f8f3eb 0%, #f0e8dc 100%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
code { background: rgba(80, 54, 33, .10); padding: .12rem .35rem; border-radius: 8px; }

.app-shell {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(36, 26, 19, .92);
  color: #fff8ed;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--accent-2), #f0c38c);
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
  font-size: 24px;
}
.brand h1 { margin: 0; font-size: 1.4rem; letter-spacing: -.03em; }
.brand p { margin: 2px 0 0; color: rgba(255,248,237,.64); font-size: .86rem; }

.nav { display: grid; gap: 8px; }
.nav-item {
  border: 0;
  width: 100%;
  color: rgba(255,248,237,.78);
  background: transparent;
  border-radius: 17px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(2px); }
.nav-item.active { background: rgba(255, 248, 237, .14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.nav-item span { width: 20px; text-align: center; opacity: .9; }

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.10);
  color: rgba(255,248,237,.82);
}
.sidebar-card p { margin: 8px 0 0; line-height: 1.45; font-size: .9rem; }

.main { min-width: 0; padding: 28px clamp(18px, 3vw, 44px) 56px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-bottom: 26px;
}
.eyebrow { color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; }
.topbar h2 { margin: 3px 0 0; font-size: clamp(2rem, 4vw, 3.8rem); letter-spacing: -.065em; line-height: 1; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.ghost, .primary, .danger {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 10px 14px;
  background: rgba(255,255,255,.55);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(58, 39, 21, .06);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.ghost:hover, .primary:hover, .danger:hover { transform: translateY(-1px); box-shadow: 0 14px 35px rgba(58, 39, 21, .10); }
.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff8ed; border: 0; }
.danger { color: var(--bad); }

.view { animation: enter .24s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.sidebar-layout { grid-template-columns: minmax(290px, 390px) minmax(0,1fr); align-items: start; }
.card, .hero, .item-card, .reader, .quiz-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.card { padding: 20px; }
.hero { padding: clamp(22px, 4vw, 34px); overflow: hidden; position: relative; }
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px;
  border-radius: 999px; background: rgba(180,106,60,.18);
  pointer-events: none;
  z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.hero h3 { margin: 0 0 10px; font-size: clamp(1.6rem, 3vw, 2.4rem); letter-spacing: -.045em; }
.hero p { margin: 0; color: var(--muted); max-width: 70ch; line-height: 1.55; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin: 18px 0; }
.stat { padding: 16px; border-radius: 20px; background: rgba(255,255,255,.58); border: 1px solid var(--line); }
.stat strong { display: block; font-size: 1.7rem; letter-spacing: -.05em; }
.stat span { color: var(--muted); font-size: .86rem; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; align-items: center; }
.search, .select {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.75);
  color: var(--text);
  border-radius: 16px;
  padding: 11px 13px;
  outline: none;
}
.search { min-width: min(100%, 320px); flex: 1; }
.select { min-width: 160px; }

.item-list { display: grid; gap: 12px; }
.item-card {
  padding: 16px;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  cursor: pointer;
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 22px 72px rgba(58, 39, 21, .17); background: rgba(255,255,255,.90); }
.item-title { display: flex; gap: 12px; align-items: start; justify-content: space-between; }
.item-title h4 { margin: 0; font-size: 1rem; letter-spacing: -.02em; }
.item-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.45; font-size: .92rem; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(124,63,39,.08);
  color: var(--accent);
  font-size: .78rem;
  font-weight: 700;
}
.pill.light { background: rgba(33,26,20,.07); color: var(--muted); }
.pill.good { background: rgba(44,122,75,.12); color: var(--good); }
.pill.bad { background: rgba(164,61,52,.12); color: var(--bad); }

.reader, .quiz-panel { padding: clamp(18px, 3vw, 28px); min-height: 420px; }
.reader h3, .quiz-panel h3 { margin: 0 0 12px; font-size: clamp(1.4rem, 2.4vw, 2rem); letter-spacing: -.04em; }
.reader .content { line-height: 1.68; color: #2d241d; }
.reader .content h2 { margin-top: 1.4em; letter-spacing: -.03em; }
.reader .content ul { padding-left: 1.2rem; }
.reader .content blockquote { border-left: 4px solid var(--accent-2); padding-left: 1rem; color: var(--muted); margin-left: 0; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.news-card { min-height: 190px; display: flex; flex-direction: column; }
.news-card .source { color: var(--accent); font-weight: 800; font-size: .82rem; }
.news-card h4 { margin: 8px 0; line-height: 1.25; }
.news-card p { flex: 1; }
.news-card a { margin-top: 10px; color: var(--accent); font-weight: 800; text-decoration: none; }

.resource-table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 20px; }
.resource-table th, .resource-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.resource-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.resource-table tr:hover td { background: rgba(255,255,255,.42); }
.resource-table a { color: var(--accent); font-weight: 800; text-decoration: none; }

.question { padding: 16px; border-radius: 20px; background: rgba(255,255,255,.58); border: 1px solid var(--line); margin: 12px 0; }
.question h4 { margin: 0 0 12px; }
.option { display: flex; gap: 10px; padding: 10px; border-radius: 14px; margin: 6px 0; border: 1px solid transparent; }
.option:hover { background: rgba(124,63,39,.06); }
.option.correct { border-color: rgba(44,122,75,.35); background: rgba(44,122,75,.10); }
.option.wrong { border-color: rgba(164,61,52,.35); background: rgba(164,61,52,.10); }
.explanation { margin-top: 10px; color: var(--muted); font-size: .92rem; }
.score-box { padding: 18px; border-radius: 22px; background: rgba(255,255,255,.65); border: 1px solid var(--line); margin: 14px 0; }
.score-box strong { font-size: 2rem; letter-spacing: -.05em; }

.loader-card { display: flex; gap: 12px; align-items: center; padding: 24px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(124,63,39,.16); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-title { display:none; }
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; padding: 16px; border-right: 0; }
  .nav { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .nav-item { justify-content: center; font-size: .88rem; }
  .sidebar-card { display: none; }
  .main { padding: 18px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .grid.cols-2, .grid.cols-3, .grid.sidebar-layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 540px) {
  .nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stats { grid-template-columns: 1fr; }
  .top-actions { justify-content: stretch; }
  .top-actions button { flex: 1; }
}

.muted { color: var(--muted); }
.single-line { grid-template-columns: 1fr; margin-top: -4px; }
.stat.wide strong { font-size: 1.05rem; letter-spacing: -.02em; }

.done-badge, .inline-done {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  margin-right: 8px;
  border-radius: 999px;
  background: rgba(44,122,75,.14);
  color: var(--good);
  border: 1px solid rgba(44,122,75,.25);
  font-size: .78rem;
  font-weight: 900;
  vertical-align: middle;
}
.inline-done:empty {
  display: none;
}
.done-badge {
  margin-right: 0;
}

.video-card {
  display: grid;
  grid-template-columns: 120px minmax(0,1fr);
  gap: 12px;
  align-items: start;
}
.video-card .item-title,
.video-card p,
.video-card .meta { grid-column: 2; }
.video-thumb {
  grid-row: 1 / span 3;
  width: 120px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 25px rgba(58, 39, 21, .10);
  background: rgba(255,255,255,.55);
}
.video-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  margin: 18px 0;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(58, 39, 21, .14);
  background: #211a14;
}
.video-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.link-pill { text-decoration: none; }

.calendar-card { margin: 18px 0; overflow-x: auto; }
.calendar-toolbar { justify-content: space-between; }
.calendar-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 780px;
}
.calendar-weekdays {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  gap: 4px;
  padding-top: 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 13px;
  width: 34px;
}
.calendar-weekdays span:nth-child(1) { grid-row: 1; }
.calendar-weekdays span:nth-child(2) { grid-row: 3; }
.calendar-weekdays span:nth-child(3) { grid-row: 5; }
.calendar-weekdays span:nth-child(4) { grid-row: 7; }
.activity-calendar {
  display: grid;
  grid-template-columns: repeat(53, 13px);
  grid-template-rows: repeat(7, 13px);
  grid-auto-flow: column;
  gap: 4px;
  min-width: calc(53 * 13px + 52 * 4px);
}
.activity-day {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1px solid rgba(65,48,33,.08);
  background: rgba(33,26,20,.08);
}
.activity-day.level-1 { background: #79aee0; }
.activity-day.level-2 { background: #6cb9bd; }
.activity-day.level-3 { background: #6fbd7b; }
.activity-day.level-4 { background: #2c7a4b; }
.calendar-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .78rem;
  margin-top: 14px;
  min-width: 780px;
}
.calendar-legend .activity-day { position: static; display: inline-block; }

@media (max-width: 540px) {
  .video-card { grid-template-columns: 1fr; }
  .video-thumb,
  .video-card .item-title,
  .video-card p,
  .video-card .meta { grid-column: auto; grid-row: auto; width: 100%; }
}

.multi-hint {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(124,63,39,.10);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  vertical-align: middle;
}
.answer-recap { color: var(--text); }
.concours-summary { margin: 18px 0; }
.summary-card h4 { margin: 0 0 10px; font-size: 1.08rem; letter-spacing: -.03em; }
.summary-card p { margin: 8px 0; color: var(--muted); line-height: 1.55; }
.clean-list { margin: 8px 0 0; padding-left: 1.1rem; color: var(--muted); line-height: 1.55; }
.clean-list li { margin: 6px 0; }

:root[data-theme="dark"] {
  --bg: #11100e;
  --panel: rgba(31, 29, 26, .88);
  --panel-solid: #1f1d1a;
  --text: #f7efe4;
  --muted: #b9ab9d;
  --line: rgba(255, 248, 237, .13);
  --accent: #e1a06e;
  --accent-2: #f1bd86;
  --good: #85d69d;
  --bad: #f19a91;
  --shadow: 0 20px 70px rgba(0, 0, 0, .32);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 10% 10%, rgba(188, 115, 71, .16), transparent 24rem),
    radial-gradient(circle at 80% 8%, rgba(93, 120, 143, .12), transparent 28rem),
    linear-gradient(135deg, #100f0d 0%, #1c1815 100%);
}

:root[data-theme="dark"] .sidebar {
  background: rgba(12, 11, 10, .94);
  color: #fff8ed;
}

:root[data-theme="dark"] .hero::after { background: rgba(225,160,110,.12); }
:root[data-theme="dark"] .stat,
:root[data-theme="dark"] .question,
:root[data-theme="dark"] .score-box,
:root[data-theme="dark"] .search,
:root[data-theme="dark"] .select,
:root[data-theme="dark"] .ghost,
:root[data-theme="dark"] .danger {
  background: rgba(255, 248, 237, .06);
  color: var(--text);
}
:root[data-theme="dark"] .item-card:hover,
:root[data-theme="dark"] .resource-table tr:hover td {
  background: rgba(255, 248, 237, .08);
}
:root[data-theme="dark"] .reader .content { color: var(--text); }
:root[data-theme="dark"] .pill { background: rgba(225,160,110,.12); }
:root[data-theme="dark"] .pill.light { background: rgba(255,248,237,.08); color: var(--muted); }
:root[data-theme="dark"] .video-player { background: #000; }
:root[data-theme="dark"] code { background: rgba(255,248,237,.10); }

@media (max-width: 760px) {
  .resource-table { min-width: 680px; }
  .table-wrap { overflow-x: auto; }
  .concours-summary { grid-template-columns: 1fr; }
  .summary-card .grid.cols-3 { grid-template-columns: 1fr; }
}

.hero-actions {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}
.big-action {
  padding: 14px 18px;
  font-weight: 900;
  white-space: nowrap;
}
.revision-card { margin: 18px 0; }
.revision-head {
  justify-content: space-between;
  align-items: flex-start;
}
.revision-head p { margin: 5px 0 0; }
.mini-task {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.54);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
}
.mini-task h4 { margin: 0; letter-spacing: -.025em; line-height: 1.25; }
.mini-task p { margin: 0; color: var(--muted); line-height: 1.45; flex: 1; }
.empty-mini { justify-content: center; color: var(--muted); }
.open-question {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(124,63,39,.07);
  border: 1px solid var(--line);
}
.open-question p { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }

.action-meta { align-items: center; }
.review-toggle {
  border: 1px solid rgba(124,63,39,.22);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(124,63,39,.08);
  color: var(--accent);
  font-size: .78rem;
  font-weight: 900;
}
.review-toggle.active {
  background: rgba(44,122,75,.13);
  border-color: rgba(44,122,75,.30);
  color: var(--good);
}
.inline-review, .review-badge {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  margin-right: 8px;
  border-radius: 999px;
  background: rgba(124,63,39,.10);
  color: var(--accent);
  border: 1px solid rgba(124,63,39,.22);
  font-size: .78rem;
  font-weight: 900;
  vertical-align: middle;
}
.inline-review:empty { display: none; }
.review-badge { margin-right: 0; }
.qcm-bilan-card { margin: 18px 0; }

:root[data-theme="dark"] .mini-task,
:root[data-theme="dark"] .open-question,
:root[data-theme="dark"] .review-toggle {
  background: rgba(255,248,237,.06);
}
:root[data-theme="dark"] .review-toggle.active {
  background: rgba(133,214,157,.12);
}

@media (max-width: 760px) {
  .hero-actions { flex-direction: column; align-items: stretch; }
  .big-action { width: 100%; }
}
