/* Mes papiers — styles. Pensé pour le téléphone d'abord. */

/* Polices embarquées (licence SIL OFL, voir fonts/) : rien n'est chargé
   depuis Internet. Fraunces pour les titres, Figtree pour le texte. */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* Thème « Papeterie » : papier crème, encre bleu nuit. Toujours clair,
   même quand le téléphone est en mode sombre (choix de l'utilisateur). */
:root {
  color-scheme: light;

  --paper: #f3eee4;        /* fond de page, ton papier */
  --surface: #fffcf6;      /* cartes et feuilles */
  --ink: #1f2433;          /* texte, bleu nuit presque noir */
  --ink-soft: #6a675f;     /* texte secondaire */
  --line: #e4dccb;         /* filets */
  --accent: #23395d;       /* bleu nuit */
  --on-accent: #fffaf0;
  --accent-soft: #e5e9f1;
  --field-border: #b8ad97; /* contour des champs de saisie */
  --danger: #b23a2b;
  --on-danger: #ffffff;
  --warn: #9a5a0c;         /* échéance dans la semaine */
  --shadow: 60 45 20;

  /* Couleurs des catégories. */
  /* Six teintes bien séparées sur le cercle des couleurs. */
  --c-impots: #2c5fd4;   /* bleu */
  --c-sante: #1f9a5c;    /* vert */
  --c-logement: #e2701c; /* orange */
  --c-banque: #c42d74;   /* framboise */
  --c-energie: #e9b400;  /* jaune */
  --c-autre: #7c7a74;    /* gris */

  /* Cases du résumé. */
  --tile-late: #f8ddd6;
  --tile-late-ink: #8f2a1d;
  --tile-week: #f6e7c8;
  --tile-week-ink: #7a4b06;
  --tile-todo: #dfe6f1;
  --tile-todo-ink: #23395d;

  --radius: 14px;
  --gutter: 16px;
  --font-ui: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: "Fraunces", ui-serif, Georgia, serif;
}

/* Thème sombre, au choix de l'utilisateur (« ⋮ », Apparence). Le thème
   clair reste celui par défaut, même si le téléphone est en mode sombre. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: #161a22;
  --surface: #1f2430;
  --ink: #efe9dd;
  --ink-soft: #a7a397;
  --line: #2f3543;
  --accent: #a9bde6;
  --on-accent: #131b2e;
  --accent-soft: #283149;
  --field-border: #5a6070;
  --danger: #ff9d8e;
  --on-danger: #3b0d08;
  --warn: #f2bb5f;
  --shadow: 0 0 0;

  --c-impots: #6f9cf2;
  --c-sante: #4cc58a;
  --c-logement: #f29a52;
  --c-banque: #ec6fa8;
  --c-energie: #f2c94c;
  --c-autre: #a4a19a;

  --tile-late: #43221f;
  --tile-late-ink: #ffb5a8;
  --tile-week: #3d301a;
  --tile-week-ink: #f5cd85;
  --tile-todo: #26304a;
  --tile-todo-ink: #c3d2f2;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* La page ne défile pas derrière une feuille ouverte par-dessus. */
html:has(dialog:modal) {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- En-tête ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: calc(16px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--paper);
}

.app-header-inner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 40rem;
  margin: 0 auto;
}

.heading {
  min-width: 0;
  margin-right: auto;
}

.app-header h1 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 600;
  font-variation-settings: "SOFT" 100, "opsz" 72;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* Sur téléphone, le titre est le nom de l'application ; sur ordinateur,
   la catégorie affichée (le nom est dans la barre latérale). */
.view-title {
  display: none;
}

.today {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* Le résumé dit déjà combien de papiers sont à traiter. */
.count {
  display: none;
}

/* Boutons de l'en-tête (rappels, sauvegarde). Un point rouge signale qu'il
   y a quelque chose à faire. */
.app-header .bell {
  position: relative;
  margin: -2px 0 0;
  color: var(--ink);
}

.app-header .bell:last-child {
  margin-right: -10px;
}

@media (max-width: 380px) {
  .app-header h1 {
    font-size: 1.75rem;
  }
}

.bell-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border: 2px solid var(--paper);
  border-radius: 50%;
}

/* ---------- Résumé en trois cases ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 12px 11px;
  border-radius: 14px;
}

.tile-n {
  font-family: var(--font-title);
  font-size: 1.875rem;
  font-weight: 600;
  font-variant-numeric: lining-nums;
  line-height: 1;
}

.tile-l {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}

.tile-late { background: var(--tile-late); color: var(--tile-late-ink); }
.tile-week { background: var(--tile-week); color: var(--tile-week-ink); }
.tile-todo { background: var(--tile-todo); color: var(--tile-todo-ink); }

/* ---------- Contenu ---------- */

.app-main {
  max-width: calc(40rem + 2 * var(--gutter));
  margin: 0 auto;
  /* On laisse la place du bouton fixe en bas de l'écran. */
  padding: 8px var(--gutter) calc(112px + env(safe-area-inset-bottom));
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8vh 12px 24px;
  text-align: center;
}

.empty h2 {
  margin-top: 12px;
  font-family: var(--font-title);
  font-size: 1.375rem;
  line-height: 1.25;
  text-wrap: balance;
}

.empty p {
  max-width: 22rem;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.empty-art .art-back {
  fill: var(--accent-soft);
  stroke: var(--line);
  stroke-width: 1.5;
}

.empty-art .art-front {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.empty-art .art-fold,
.empty-art .art-lines {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-art .art-lines {
  opacity: 0.45;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 12px;
  color: var(--danger);
  font-size: 0.9375rem;
}

.notice-info {
  border-color: var(--warn);
  color: var(--warn);
}

.hint {
  color: var(--ink-soft);
  font-size: 0.875rem;
  text-wrap: pretty;
}

/* ---------- Recherche et filtre ---------- */

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 4px;
}

.search {
  position: relative;
}

.search input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 46px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.05);
  color: var(--ink);
  font: inherit; /* 16 px au moins : sinon l'iPhone zoome à la saisie */
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}

/* On a notre propre croix pour effacer. */
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

/* Une rangée de catégories qui défile sur le côté si elle ne tient pas. */
.filters {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 4px var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  white-space: nowrap;
  cursor: pointer;
}

.filter[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.no-result {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 40px 12px;
  color: var(--ink-soft);
  text-align: center;
}

.no-result .btn {
  color: var(--ink);
}

/* Intertitres « À traiter », « Traités » : en italique, comme sur un carnet. */
.group-title {
  margin: 22px 4px 10px;
  font-family: var(--font-title);
  font-size: 1.1875rem;
  font-style: italic;
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* Titre de groupe qui replie sa liste : tout le titre se touche. */
.group-title .fold {
  display: flex;
  align-items: baseline;
  gap: 0;
  width: 100%;
  min-height: 40px;
  margin: -8px 0;
  padding: 8px 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.group-title .fold:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Petite flèche à droite : vers le bas déplié, vers la droite replié. */
.fold-icon {
  align-self: center;
  width: 9px;
  height: 9px;
  margin-left: auto;
  margin-right: 8px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.15s;
}

.fold[aria-expanded="false"] .fold-icon {
  transform: rotate(-45deg);
}

/* Rubriques de la page des objets. */
.things-groups .group-title {
  margin-top: 18px;
}

.things-groups .group:first-child .group-title {
  margin-top: 6px;
}

.group-count {
  margin-left: 6px;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-style: normal;
  font-weight: 500;
}

.toolbar + .group,
.no-result + .group {
  margin-top: 12px;
}

/* ---------- Liste des papiers ---------- */

.paper-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Chaque papier est une fiche avec, sur le bord gauche, une tranche de la
   couleur de sa catégorie, comme l'onglet d'un classeur. */
.paper {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.04);
}

.paper::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 5px;
  background: var(--category);
}

/* Zone principale : toucher ouvre le papier. */
.paper-open {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 12px 4px 12px 17px;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.paper-open:active {
  background: var(--accent-soft);
}

/* Petit calendrier : le mois en haut, le jour en grand. */
.cal {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}

.cal-m {
  align-self: stretch;
  padding: 2px 0 1px;
  background: var(--category);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.4;
  text-transform: uppercase;
}

.cal-d {
  padding: 1px 0 3px;
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: lining-nums;
  line-height: 1.15;
}

.cal-y {
  margin: -3px 0 3px;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 600;
}

/* Sans date limite : « Sans date » dans la bande, l'icône de la catégorie
   à la place du jour. */
.cal-none .cal-m {
  font-size: 0.5rem;
  letter-spacing: 0.04em;
}

.cal-icon {
  display: grid;
  place-items: center;
  height: 2rem;
  color: var(--category);
}

/* Sur le jaune, le blanc se lit mal : texte foncé. */
.cal[data-category="energie"]:not(.cal-late) .cal-m {
  color: #3d2f00;
}

.cal-late {
  border-color: var(--danger);
}

.cal-late .cal-m {
  background: var(--danger);
}

/* Rond à cocher : marque le papier comme traité. */
.paper-done {
  display: grid;
  place-items: center;
  width: 60px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.check {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--field-border);
  border-radius: 50%;
  color: transparent;
  transition: background-color 0.15s, border-color 0.15s;
}

.paper-done[aria-pressed="true"] .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.paper-done:active .check {
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (hover: hover) {
  .paper-done:hover .check {
    border-color: var(--accent);
  }

  .paper:hover {
    border-color: color-mix(in srgb, var(--line) 50%, var(--field-border));
  }
}

/* Un papier traité s'efface un peu. */
.paper.is-done {
  background: color-mix(in srgb, var(--surface) 55%, var(--paper));
  box-shadow: none;
}

.paper.is-done .paper-title {
  color: var(--ink-soft);
  font-weight: 500;
}

.paper.is-done::before,
.paper.is-done .cal {
  opacity: 0.5;
}

/* Le papier ouvert dans le volet de droite, sur ordinateur. */
.paper.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 16px -10px rgb(var(--shadow) / 0.5);
}

/* Le papier qu'on vient d'ajouter ou de modifier est signalé un instant. */
.paper.is-fresh {
  animation: fresh 1.8s ease-out;
}

@keyframes fresh {
  from {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
}

.paper-title {
  display: -webkit-box;
  overflow: hidden;
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

/* Pastille de couleur + nom de la catégorie. */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--category, var(--c-autre));
}

[data-category="impots"] { --category: var(--c-impots); }
[data-category="sante"] { --category: var(--c-sante); }
[data-category="logement"] { --category: var(--c-logement); }
[data-category="banque"] { --category: var(--c-banque); }
[data-category="energie"] { --category: var(--c-energie); }
[data-category="autre"] { --category: var(--c-autre); }

.paper-due {
  white-space: nowrap;
}

/* Une date sans urgence est déjà sur le petit calendrier : on ne la répète
   pas. Le texte reste pour les lecteurs d'écran. */
.paper-due:not([data-level]) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.paper-due[data-level="soon"] {
  color: var(--warn);
  font-weight: 650;
}

.paper-due[data-level="late"] {
  color: var(--danger);
  font-weight: 650;
}

/* Montant et rythme d'une échéance qui revient. */
.paper-amount {
  color: var(--ink);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.paper-repeat {
  white-space: nowrap;
}

.paper-repeat::before {
  content: "↻ ";
}

/* L'objet d'un papier (voiture, logement, appareil), dans la liste. */
.paper-thing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.paper-thing svg,
.thing-icon svg {
  display: block;
  flex: none;
}

.thing-icon {
  display: inline-flex;
  color: var(--ink-soft);
}

.filter[aria-pressed="true"] .thing-icon {
  color: inherit;
}

/* Deux pages sur téléphone : « Papiers » et « Objets ». */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 14px;
}

.tab {
  min-height: 42px;
  padding: 0 12px;
  background: none;
  border: 0;
  border-radius: 11px;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(var(--shadow) / 0.12);
  color: var(--ink);
}

.tab:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* Page « Objets » : une carte par objet. */
.things-grid {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thing-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 14px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.04);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.thing-tile:active {
  background: var(--accent-soft);
}

.thing-tile:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.thing-tile > .thing-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--accent-soft);
  border-radius: 12px;
  color: var(--accent);
}

.thing-tile > .thing-icon svg {
  width: 22px;
  height: 22px;
}

.thing-tile-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.thing-tile-name {
  overflow: hidden;
  font-family: var(--font-title);
  font-size: 1.1875rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thing-tile-stats,
.thing-tile-next {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thing-tile-next[data-level="soon"] {
  color: var(--warn);
  font-weight: 650;
}

.thing-tile-next[data-level="late"] {
  color: var(--danger);
  font-weight: 650;
}

.thing-tile-arrow {
  color: var(--ink-soft);
  font-size: 1.75rem;
  line-height: 1;
}

.things-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--ink-soft);
  text-align: center;
}

.things-empty h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 1.25rem;
}

.things-empty p {
  max-width: 26rem;
  margin: 0;
}

.things-empty-icon {
  color: var(--accent);
}

/* Page d'un objet : son en-tête, au-dessus de ses papiers. */
.thing-card {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.thing-back {
  justify-self: start;
  margin: 0 -8px;
}

.thing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 8px;
}

.thing-actions .btn {
  min-height: 44px;
  padding: 0 16px;
}

.thing-empty {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* « Catégorie » et « + Nouvelle » sur une même ligne. */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -8px 0 -2px 0;
}

.field-head-label {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* Liste « Objet concerné » et nom d'un nouvel objet. */
.field select + input[type="text"] {
  margin-top: 2px;
}

/* Couleurs d'une nouvelle catégorie. */
.color-choice {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.color-swatch {
  display: grid;
  place-items: center;
  height: 48px;
  cursor: pointer;
}

.swatch {
  width: 38px;
  height: 38px;
  background: var(--swatch);
  border: 3px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.color-swatch:has(input:checked) .swatch {
  box-shadow: 0 0 0 3px var(--ink);
}

.color-swatch:has(input:focus-visible) .swatch {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.color-custom {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.color-custom input {
  width: 44px;
  height: 36px;
  padding: 0;
  background: none;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  cursor: pointer;
}

.category-preview-row {
  margin: 0;
  font-size: 1rem;
}

/* Catégories personnelles, dans « ⋮ ». */
.category-manage {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.category-manage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.category-manage-item .side-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-manage-item .side-count {
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

/* « Nouvel objet », en tête de la page des objets. */
.thing-new {
  width: 100%;
  border-style: dashed;
}

/* « Nouvel objet » et « Nouvelle catégorie », côte à côte. */
.things-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.things-actions .btn {
  min-height: 48px;
  padding: 0 6px;
  font-size: 0.9375rem;
}

/* Une catégorie d'objets encore vide. */
.things-empty-kind {
  display: grid;
  gap: 10px;
  padding: 4px 4px 0;
}

/* Dans « ⋮ » : intertitre des catégories d'objets. */
.kind-manage-title {
  margin: 14px 0 6px;
  font-weight: 600;
}

/* Rattacher un papier existant. */
.attach-search {
  margin-bottom: 8px;
}

.attach-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--category);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.attach-item:active {
  background: var(--accent-soft);
}

.attach-text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.attach-title {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

.attach-plus {
  flex: none;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 650;
}

.thing-name {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.thing-stats {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.thing-rename {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.thing-rename input {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
}

.thing-rename input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* Un prélèvement automatique n'a pas de rond « traité ». */
.paper > .paper-open:only-child {
  grid-column: 1 / -1;
}

/* Sous les trois cases : le total des dépenses régulières, par mois. */
.tile-regular {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--accent);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tile-regular[hidden] {
  display: none;
}

.regular-label {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.regular-unit {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
}

.regular-label::before {
  content: "↻ ";
}

.regular-total {
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

.tile-regular[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.tile-regular:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-secondary {
  border-color: var(--line);
  background: var(--surface);
}

.btn-danger {
  background: var(--danger);
  color: var(--on-danger);
}

.btn-danger-quiet {
  width: 100%;
  color: var(--danger);
}

.icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -10px -8px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.icon-button:active {
  background: var(--accent-soft);
}

.link-button {
  min-height: 44px;
  margin: -12px -8px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Bouton d'ajout, fixe en bas ---------- */

.add-bar {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  padding: 28px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 60%, transparent);
  pointer-events: none;
}

.add-bar .btn {
  width: 100%;
  max-width: 26rem;
  min-height: 56px;
  font-size: 1.0625rem;
  white-space: nowrap;
  box-shadow: 0 10px 24px -8px rgb(var(--shadow) / 0.45);
  pointer-events: auto;
}

/* ---------- Message bref ---------- */

.toast {
  position: fixed;
  right: var(--gutter);
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 26rem;
  min-height: 52px;
  margin: 0 auto;
  padding: 4px 6px 4px 18px;
  background: var(--ink);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgb(var(--shadow) / 0.3);
  color: var(--paper);
  font-size: 0.9375rem;
}

.toast p {
  min-width: 0;
  padding: 8px 0;
  overflow-wrap: anywhere;
}

.toast-action {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.toast-action:focus-visible {
  outline-color: var(--paper);
}

/* ---------- Feuille d'ajout ---------- */

.sheet {
  width: 100%;
  max-width: 34rem;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  overflow: auto;
  background: var(--surface);
  border: 0;
  border-radius: 22px 22px 0 0;
  color: var(--ink);
}

.sheet::backdrop,
.viewer::backdrop {
  background: rgb(14 16 20 / 0.5);
}

.sheet-inner {
  display: grid;
  gap: 16px;
  padding: 22px var(--gutter) calc(18px + env(safe-area-inset-bottom));
}

.sheet h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.choices,
.paper-form {
  display: grid;
  gap: 10px;
}

.paper-form {
  gap: 16px;
}

.choice {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice svg {
  color: var(--accent);
}

.choice:active {
  background: var(--accent-soft);
}

/* Anneau visible au clavier seulement, pas au toucher. */
.choice:has(input:focus-visible),
.chip:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.choice-title,
.choice-hint {
  display: block;
}

.choice-title {
  font-weight: 600;
}

.choice-hint {
  color: var(--ink-soft);
  font-size: 0.875rem;
}

/* ---------- Aperçu du fichier en tête de feuille ---------- */

.preview {
  display: grid;
  gap: 8px;
}

/* Bandeau : le haut du courrier, là où se trouve l'en-tête. */
.preview-banner {
  position: relative;
  display: block;
  width: 100%;
  height: 150px;
  padding: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: zoom-in;
}

.preview-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.preview-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgb(14 16 20 / 0.72);
  color: #ffffff;
  font: 600 0.8125rem/1.2 var(--font-ui);
}

.preview-banner:disabled .preview-zoom {
  visibility: hidden;
}

.preview-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  padding: 12px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 20px;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.preview-meta p {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.done-status {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
}

/* ---------- Champs ---------- */

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field label,
.field legend {
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* Une légende ne participe pas à la grille : on recrée l'espacement. */
.field legend {
  margin-bottom: 8px;
}

.optional {
  margin-left: 4px;
  color: var(--ink-soft);
  font-weight: 400;
}

.field textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  color: var(--ink);
  font: inherit; /* 16 px au moins : sinon l'iPhone zoome à la saisie */
  line-height: 1.4;
  resize: vertical;
}

.field textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.field textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}


/* Bouton « Écrire ou dicter une note » : même allure que les deux autres choix. */
button.choice {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}

/* Première ligne de la note, sous la catégorie, dans la liste. */
.paper-note {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field input[type="text"],
.field input[type="date"] {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  color: var(--ink);
  font: inherit; /* 16 px au moins : sinon l'iPhone zoome à la saisie */
  -webkit-appearance: none;
  appearance: none;
}

/* Sur iPhone, la date est centrée par défaut. */
.field input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

/* Pas de flèche de liste déroulante : les suggestions viennent à la frappe. */
.field input[list]::-webkit-calendar-picker-indicator {
  display: none !important;
}

.field input::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}

.field input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* « À traiter » ou « À conserver » : deux boutons côte à côte. */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 14px;
}

.segmented label {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 11px;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented label:has(input:checked) {
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(var(--shadow) / 0.12);
  color: var(--ink);
}

.segmented label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* « + Note » et « + Montant ou abonnement », sur une ligne. */
.more-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  margin: -10px -8px;
}

.more-row[hidden],
.more-row .link-button[hidden] {
  display: none;
}

.money-block {
  display: grid;
  gap: 18px;
}

.money-block[hidden] {
  display: none;
}

/* Montant et « Revient » côte à côte, pour que la fiche ne s'allonge pas trop. */
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 12px;
}

.amount-input {
  position: relative;
}

.field .amount-input input[type="text"] {
  padding-right: 34px;
  font-variant-numeric: tabular-nums;
}

.amount-unit {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

.field select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 36px 0 14px;
  background: var(--surface) url("icons/chevron.svg") no-repeat right 12px center / 16px 16px;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.field select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* Les deux messages d'erreur de la rangée passent dessous, sur toute la largeur. */
.amount-error {
  margin-top: -10px;
}

/* Case « Prélevé automatiquement ». */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: -6px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.check-row[hidden] {
  display: none;
}

.check-row input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.check-row .hint {
  display: block;
  font-weight: 400;
}

.repeat-history {
  margin-top: -10px;
}

/* Trois colonnes, ou deux quand l'écran est trop étroit pour les libellés. */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 6px;
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  font-size: 0.9375rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.chip:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  font-weight: 600;
}

/* ---------- Rappels ---------- */

.status-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-card .hint:empty {
  display: none;
}

.sheet section {
  display: grid;
  gap: 10px;
}

/* Bouton qui ouvre le choix d'un fichier. */
.file-button:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.file-button.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.sheet .group-title {
  margin: 4px 0 0;
}

.upcoming {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upcoming li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
}

.upcoming-date {
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.upcoming-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-stage,
.upcoming .upcoming-more {
  color: var(--ink-soft);
  font-size: 0.875rem;
  white-space: nowrap;
}

.upcoming .upcoming-more {
  display: block;
}

/* Pages suivantes, sous l'aperçu du papier. */
.pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.pages-list {
  display: contents;
}

.page {
  position: relative;
}

.page-open {
  display: grid;
  place-items: center;
  width: 64px;
  height: 82px;
  padding: 0;
  overflow: hidden;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.page-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-number {
  position: absolute;
  bottom: 4px;
  left: 4px;
  padding: 0 5px;
  background: rgb(14 16 20 / 0.7);
  border-radius: 6px;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  pointer-events: none;
}

.page-remove {
  position: absolute;
  top: -10px;
  right: -10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
}

.page-add {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px dashed var(--field-border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.page-add:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Rappel de sauvegarde, en haut de la liste. */
.backup-reminder {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--warn);
  border-left-width: 5px;
  border-radius: var(--radius);
}

.backup-reminder-title {
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 600;
}

.backup-reminder .actions {
  margin-top: 6px;
}

.backup-reminder .btn {
  min-height: 46px;
}

/* Choix clair / sombre, dans « Sauvegarde et installation ». */
.theme-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ---------- Suppression ---------- */

.delete-zone {
  margin-top: -6px;
}

.delete-confirm {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.error {
  color: var(--danger);
  font-size: 0.9375rem;
  text-align: center;
}

/* ---------- Visionneuse ---------- */

.viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  background: #0e1014;
  border: 0;
  color: #f2f0ea;
}

.viewer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 8px;
}

.viewer-title {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-viewer {
  min-height: 44px;
  padding: 0 18px;
  border-color: rgb(255 255 255 / 0.28);
  color: inherit;
}

.btn-viewer:focus-visible {
  outline-color: #ffffff;
}

.viewer-body {
  position: relative;
  min-height: 0;
  margin-bottom: env(safe-area-inset-bottom);
}

/* La photo occupe toute la zone, sans être rognée ni déformée. */
.viewer-body img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- Écrans moyens : la feuille devient une fenêtre centrée ---------- */

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-radius: 22px;
  }
}

/* ---------- Ordinateur : trois volets ---------- */

/* Hors des grands écrans, la barre latérale et l'emplacement du volet de
   droite n'existent pas. */
.sidebar,
.panel-placeholder {
  display: none;
}

@media (min-width: 1000px) {
  :root {
    --side: 232px;   /* barre latérale */
    --panel: 360px;  /* fiche du papier */
  }

  body {
    padding-right: var(--panel);
    padding-left: var(--side);
  }

  /* À gauche : le nom, les catégories, les actions. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: var(--side);
    padding: 26px 16px 20px;
    border-right: 1px solid var(--line);
  }

  .sidebar-brand {
    padding: 0 10px 20px;
    font-family: var(--font-title);
    font-size: 1.625rem;
    font-weight: 600;
    font-variation-settings: "SOFT" 100, "opsz" 72;
    letter-spacing: -0.02em;
  }

  .side-nav {
    display: grid;
    gap: 2px;
  }

  .side-item,
  .side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    background: none;
    border: 0;
    border-radius: 10px;
    color: var(--ink);
    font: inherit;
    font-size: 0.9375rem;
    text-align: left;
    cursor: pointer;
  }

  .side-things-all {
    margin-top: 14px;
  }

  .side-things-all .thing-icon {
    width: 9px;
    justify-content: center;
    color: var(--ink);
  }

  .side-things-all .thing-icon svg {
    width: 16px;
    height: 16px;
  }

  .side-things .side-item {
    min-height: 36px;
    padding-left: 33px;
    font-size: 0.875rem;
  }

  .tabs {
    display: none;
  }

  .things-grid {
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  }

  .side-item[data-filter="all"] .dot {
    background: var(--ink);
  }

  .side-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .side-count {
    color: var(--ink-soft);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
  }

  .side-item:hover,
  .side-link:hover {
    background: color-mix(in srgb, var(--surface) 60%, transparent);
  }

  .side-item[aria-pressed="true"] {
    background: var(--surface);
    box-shadow: 0 1px 2px rgb(var(--shadow) / 0.08);
    font-weight: 650;
  }

  .side-add {
    margin-top: 18px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    white-space: nowrap;
  }

  .side-bottom {
    display: grid;
    gap: 2px;
    margin-top: auto;
  }

  .side-link svg {
    flex: none;
    color: var(--ink-soft);
  }

  .side-dot {
    width: 8px;
    height: 8px;
    margin-left: auto;
    background: var(--danger);
    border-radius: 50%;
  }

  /* Au milieu : la liste. */
  .app-header {
    position: static;
    padding: 30px 32px 8px;
  }

  .app-header-inner,
  .app-main {
    max-width: 46rem;
  }

  .app-main {
    padding: 8px 32px 48px;
  }

  .brand,
  .app-header .bell,
  .filters,
  .add-bar {
    display: none !important;
  }

  .view-title {
    display: inline;
  }

  .toast {
    right: calc(var(--panel) + 24px);
    bottom: 24px;
    left: calc(var(--side) + 24px);
  }

  /* À droite : la fiche du papier choisi, ou une invitation à en choisir un. */
  .panel-placeholder {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: var(--panel);
    padding: 32px;
    border-left: 1px solid var(--line);
    color: var(--ink-soft);
    text-align: center;
  }

  .panel-placeholder .art-back { fill: var(--accent-soft); stroke: var(--line); stroke-width: 1.5; }
  .panel-placeholder .art-front { fill: var(--surface); stroke: var(--field-border); stroke-width: 2.5; stroke-linejoin: round; }
  .panel-placeholder .art-fold,
  .panel-placeholder .art-lines { fill: none; stroke: var(--field-border); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

  .sheet.as-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 3;
    width: var(--panel);
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    box-shadow: -10px 0 30px -24px rgb(var(--shadow) / 0.6);
    animation: none;
  }

  .sheet.as-panel .sheet-inner {
    padding: 24px 28px 28px;
  }

  .sheet.as-panel .preview-banner {
    height: 230px;
  }
}

/* ---------- Animations ---------- */

@media (prefers-reduced-motion: no-preference) {
  .sheet[open] {
    animation: sheet-in 0.22s ease-out;
  }

  .viewer[open] {
    animation: fade-in 0.16s ease-out;
  }

  .toast {
    animation: sheet-in 0.2s ease-out;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(28px);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* Grands écrans : volets plus larges. Placé en dernier pour l'emporter. */
@media (min-width: 1280px) {
  :root {
    --side: 248px;
    --panel: 400px;
  }
}
