/* ───────── Tokens ───────── */
:root {
  --bg: #EEF0F3;
  --surface: #FFFFFF;
  --ink: #1A1D26;
  --muted: #5D6372;
  --line: #D6DAE1;
  --focus: #2B5FD9;

  --paper: #F6F3EC;              /* texte sur les planches colorées */
  --paper-soft: rgba(246, 243, 236, .74);
  --paper-faint: rgba(246, 243, 236, .16);

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --sans: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius-plate: 28px;
  --radius-ui: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161922;
    --surface: #1F232E;
    --ink: #ECEEF2;
    --muted: #9AA1B0;
    --line: #2C3140;
    --focus: #8DB0FF;
    color-scheme: dark;
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
svg { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ───────── Shell & navigation ───────── */
.shell { height: 100dvh; display: flex; flex-direction: column; }
.main { flex: 1; min-height: 0; position: relative; }

.nav {
  order: 2;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.brand, .nav-goal { display: none; }
.nav-link {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  font-size: 11.5px; font-weight: 500;
  text-decoration: none;
  color: var(--muted);
}
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-link[aria-current="page"] svg { stroke-width: 2.2; }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .nav {
    order: 0;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: 2px;
    width: 232px; height: 100dvh;
    padding: 28px 16px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none;
    margin: 0 8px 28px;
  }
  .brand-mark {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--ink); color: var(--bg);
    font: 500 21px/1 var(--serif); font-style: italic;
  }
  .brand-name { font: 600 21px/1 var(--serif); letter-spacing: -.01em; }
  .nav-link {
    flex: none; flex-direction: row; justify-content: flex-start;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-ui);
    font-size: 15px;
  }
  .nav-link:hover { background: var(--surface); color: var(--ink); }
  .nav-link[aria-current="page"] { background: var(--surface); }
  .nav-goal { display: block; margin-top: auto; padding: 0 8px; }
}

/* ───────── Fil ───────── */
.view { height: 100%; }
.view-feed { position: relative; }

.feed-top {
  position: absolute; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  pointer-events: none;
}
.feed-top > * { pointer-events: auto; }

.chips {
  display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  flex: 1; min-width: 0;
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  color: var(--paper);
  background: rgba(20, 20, 28, .28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .2s;
}
.chip[aria-selected="true"] { background: var(--paper); color: #1A1D26; }

.today-pill {
  flex: none;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
  background: rgba(20, 20, 28, .28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--paper);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.ring { width: 24px; height: 24px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .ring-track { stroke: currentColor; opacity: .25; }
.ring .ring-value { stroke: currentColor; stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease); }

.feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  outline: none;
}
.feed::-webkit-scrollbar { display: none; }

/* La planche : l'élément signature */
.card {
  --plate: #333;
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
  padding: calc(72px + var(--safe-t)) 16px 28px 24px;
  background: var(--plate);
  color: var(--paper);
  overflow: hidden;
}
.card-body {
  align-self: center;
  max-width: 34rem;
}
.card-cat {
  margin: 0 0 22px;
  font-size: 14px; font-weight: 500;
  color: var(--paper-soft);
}
.card-cat::before {
  content: ''; display: inline-block;
  width: 18px; height: 1px; margin-right: 10px;
  vertical-align: middle;
  background: currentColor;
}
.card-title {
  margin: 0 0 14px;
  font: 600 17px/1.3 var(--sans);
  letter-spacing: -.005em;
  color: var(--paper);
}
.card-text {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.012em;
  text-wrap: pretty;
  hanging-punctuation: first;
}
.card-text[data-size="xl"] { font-size: clamp(38px, 10vw, 56px); line-height: 1.08; }
.card-text[data-size="l"]  { font-size: clamp(27px, 7vw, 38px);  line-height: 1.2; }
.card-text[data-size="m"]  { font-size: clamp(22px, 5.6vw, 29px); line-height: 1.3; }
.card-text.is-quote { font-style: italic; }
.card-text.is-quote::before { content: '« '; }
.card-text.is-quote::after  { content: ' »'; }

.card-source {
  margin: 26px 0 0;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 14.5px;
}
.card-source .author { font-weight: 600; }
.card-source .work { color: var(--paper-soft); }

.deep-btn {
  margin-top: 26px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid rgba(246, 243, 236, .45);
  color: var(--paper);
  font-size: 14.5px; font-weight: 500;
  transition: background .2s, border-color .2s;
}
.deep-btn:hover { background: var(--paper-faint); border-color: var(--paper); }

.card-actions {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 4px;
}
.act {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 52px; padding: 8px 0;
  border-radius: 14px;
  color: var(--paper);
  font-size: 11.5px; font-weight: 500;
}
.act svg { width: 27px; height: 27px; fill: none; transition: transform .25s var(--ease), fill .2s; }
.act[aria-pressed="true"] svg { fill: currentColor; }
.act.pop svg { animation: pop .45s var(--ease); }
@keyframes pop { 40% { transform: scale(1.28); } 100% { transform: scale(1); } }

/* Carte de fin d'objectif */
.card-goal { --plate: var(--ink); color: var(--bg); grid-template-columns: 1fr; }
.card-goal .card-body { text-align: left; }
.card-goal h2 { font: 500 clamp(36px, 9vw, 52px)/1.06 var(--serif); margin: 0 0 18px; letter-spacing: -.02em; }
.card-goal p { margin: 0 0 10px; font-size: 17px; color: color-mix(in srgb, var(--bg) 75%, transparent); max-width: 28rem; }
.card-goal .btn-row { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; }
.card-goal .btn { background: var(--bg); color: var(--ink); }
.card-goal .btn-ghost { border-color: color-mix(in srgb, var(--bg) 45%, transparent); color: var(--bg); }

@media (min-width: 900px) {
  .feed-top { left: 50%; transform: translateX(-50%); width: min(560px, 100%); padding-top: 34px; padding-inline: 22px; }
  .card {
    height: calc(100% - 40px);
    margin: 20px auto;
    max-width: 560px;
    border-radius: var(--radius-plate);
    scroll-margin-top: 20px;
    padding: 90px 18px 32px 40px;
  }
  .card-text[data-size="xl"] { font-size: 52px; }
  .card-text[data-size="l"]  { font-size: 36px; }
  .card-text[data-size="m"]  { font-size: 27px; }
}

/* ───────── Pages ───────── */
.view-page {
  overflow-y: auto;
  padding: calc(28px + var(--safe-t)) 16px 48px;
}
.view-page > * { max-width: 720px; margin-inline: auto; }
.page-head { margin-bottom: 24px; }
.page-head h1 {
  margin: 0 0 6px;
  font: 500 40px/1.1 var(--serif);
  letter-spacing: -.02em;
}
.page-sub { margin: 0; color: var(--muted); }
.section-title { font: 600 15px/1.3 var(--sans); margin: 36px 0 14px; }

.search {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px;
  padding: 0 14px;
  height: 50px;
  border-radius: var(--radius-ui);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}
.search:focus-within { border-color: var(--focus); }
.search input { flex: 1; border: 0; background: none; outline: none; color: var(--ink); font-size: 16px; }

/* Idée du jour */
.daily {
  display: block; width: 100%; text-align: left;
  padding: 26px 24px;
  border-radius: 22px;
  background: var(--plate);
  color: var(--paper);
}
.daily small { display: block; color: var(--paper-soft); font-size: 14px; margin-bottom: 14px; }
.daily .daily-text { font: 400 25px/1.25 var(--serif); letter-spacing: -.01em; margin: 0 0 16px; text-wrap: pretty; }
.daily .daily-src { font-size: 14px; color: var(--paper-soft); }

/* Thèmes : tuiles de tailles différentes selon le nombre d'idées lues */
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .themes { grid-template-columns: repeat(3, 1fr); } }
.theme {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 118px;
  padding: 16px;
  border-radius: 18px;
  background: var(--plate);
  color: var(--paper);
  text-align: left; text-decoration: none;
}
.theme strong { font: 500 22px/1.15 var(--serif); }
.theme span { font-size: 13px; color: var(--paper-soft); }
.theme-bar { height: 3px; border-radius: 2px; background: var(--paper-faint); margin-top: 10px; overflow: hidden; }
.theme-bar i { display: block; height: 100%; background: var(--paper); }

/* Listes d'idées */
.idea-list { list-style: none; padding: 0; margin: 0 auto; }
.idea-row {
  display: grid; grid-template-columns: 4px 1fr; gap: 14px;
  width: 100%; text-align: left;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
}
.idea-row::before { content: ''; border-radius: 2px; background: var(--plate); }
.idea-row:hover .idea-row-title { text-decoration: underline; text-underline-offset: 3px; }
.idea-row-title { display: block; font: 500 19px/1.3 var(--serif); margin-bottom: 4px; }
.idea-row-meta { display: block; color: var(--muted); font-size: 14px; }
.idea-row-note { display: block; margin-top: 6px; font-size: 14px; font-style: italic; color: var(--muted); }

.chips-static { mask-image: none; flex-wrap: wrap; margin-bottom: 8px; }
.chips-static .chip { background: var(--surface); color: var(--ink); border: 1px solid var(--line); backdrop-filter: none; }
.chips-static .chip[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.empty {
  padding: 40px 0; color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font: 500 22px/1.3 var(--serif); margin-bottom: 6px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 46px; padding: 0 20px;
  border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 15px;
  text-decoration: none;
}
.btn-ghost { background: none; color: var(--ink); border: 1px solid var(--line); }

/* Progrès */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  padding: 18px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.stat b { display: block; font: 500 40px/1 var(--serif); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.stat span { font-size: 13.5px; color: var(--muted); }
.stat-main { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; }
.stat-main .ring { width: 76px; height: 76px; color: var(--ink); }
.stat-main .ring circle { stroke-width: 6; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.week i {
  width: 100%; aspect-ratio: 1; max-width: 44px; border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
  font-style: normal; font-size: 12px; font-weight: 600; color: var(--ink);
}
.week i.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.week .today i { border-color: var(--ink); }

.cat-rows { display: grid; gap: 12px; }
.cat-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 12px; font-size: 14.5px; }
.cat-row .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.cat-row .bar i { display: block; height: 100%; background: var(--plate); border-radius: 4px; }
.cat-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.segmented button { padding: 8px 16px; border-radius: 999px; font-size: 14.5px; font-weight: 500; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.hint { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

/* Objectif dans la barre latérale (desktop) */
.goal-mini { display: flex; align-items: center; gap: 10px; padding: 14px 4px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.goal-mini .ring { width: 30px; height: 30px; color: var(--ink); }
.goal-mini b { display: block; color: var(--ink); font-size: 14.5px; }

/* ───────── Feuille de détail ───────── */
.sheet {
  --plate: #333;
  width: 100%; max-width: 640px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(10, 12, 18, .5); }
.sheet[open] { animation: sheet-in .38s var(--ease); }
.sheet[open]::backdrop { animation: fade .3s; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 24px; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
}
.sheet-inner { max-height: 92dvh; overflow-y: auto; padding-bottom: calc(24px + var(--safe-b)); }
.sheet-head {
  position: relative;
  padding: 26px 24px 24px;
  background: var(--plate);
  color: var(--paper);
}
.sheet-head .card-cat { margin-bottom: 14px; }
.sheet-head h2 { margin: 0 0 12px; font: 500 30px/1.15 var(--serif); letter-spacing: -.015em; padding-right: 36px; }
.sheet-head .card-text { font-size: 20px; line-height: 1.4; color: var(--paper-soft); }
.sheet-close {
  position: absolute; top: 16px; right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper-faint); color: var(--paper);
}
.sheet-close svg { width: 18px; height: 18px; }
.sheet-body { padding: 24px; }
.sheet-body > p.deeper {
  margin: 0 0 22px;
  font: 400 19px/1.6 var(--serif);
  max-width: 36em;
}
.sheet-src { font-size: 14.5px; color: var(--muted); margin: 0 0 24px; }
.sheet-src b { color: var(--ink); font-weight: 600; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.sheet-actions .btn svg { width: 19px; height: 19px; fill: none; margin-right: 8px; }
.sheet-actions .btn[aria-pressed="true"] svg { fill: currentColor; }
.note-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.note {
  width: 100%; min-height: 96px; resize: vertical;
  padding: 12px 14px;
  border-radius: var(--radius-ui);
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px; line-height: 1.5;
}
.note:focus { outline: none; border-color: var(--focus); }
.related { margin-top: 28px; }
.related .idea-row { padding: 12px 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 14.5px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .3s var(--ease);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .feed { scroll-behavior: auto; }
}
