:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #262a33;
  --text: #e8eaee;
  --muted: #8b919c;
  --accent: #e0b062;
  --error: #ef6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; padding-top: var(--safe-top); }

h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.4rem; }
.muted { color: var(--muted); }

/* Connexion */
.login {
  max-width: 360px;
  margin: 0 auto;
  padding: 12vh 24px 40px;
  text-align: center;
}
.login-logo { border-radius: 18px; margin-bottom: 16px; }
.login h1 { margin-bottom: 28px; }
.login form { text-align: left; display: grid; gap: 10px; }
.login label { font-size: 0.85rem; color: var(--muted); }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #15120c;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
button.link {
  padding: 6px 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}
.error { color: var(--error); font-size: 0.9rem; }

/* App */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 20px 8px;
}
.date { color: var(--muted); font-size: 0.85rem; }

.content {
  padding: 12px 20px calc(90px + var(--safe-bottom));
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.card p { color: var(--muted); }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 10px 6px calc(10px + var(--safe-bottom));
  background: rgba(15, 17, 21, 0.95);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.tabs a, .tabs span {
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.45;
}
.tabs a { opacity: 1; }
.tabs .active { color: var(--accent); }

/* ---------- Journal du jour ---------- */
.daynav {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.daytitle { flex: 1; text-align: center; }
.nav-btn {
  width: 40px; height: 40px;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.top { flex-direction: column; gap: 6px; align-items: stretch; }
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
}
.status { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.status.off { color: var(--accent); }

.field, .add {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  resize: none;
  overflow: hidden;
}
.field:focus, .add:focus { border-color: var(--accent); }
textarea.field { min-height: 70px; line-height: 1.5; }
.add { margin-top: 8px; background: transparent; border-style: dashed; }
.mt { margin-top: 16px; }

.scale { display: flex; gap: 8px; }
.scale button {
  flex: 1;
  padding: 10px 0;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
}
.scale button.on { color: #15120c; background: var(--accent); border-color: var(--accent); }

.tasks { list-style: none; padding: 0; display: grid; gap: 2px; }
.tasks li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.tasks li:last-child { border-bottom: 0; }
.tasks .text { flex: 1; word-break: break-word; }
.tasks li.done .text { color: var(--muted); text-decoration: line-through; }
.check {
  flex: 0 0 22px;
  width: 22px; height: 22px;
  padding: 0;
  background: transparent;
  border: 2px solid var(--muted);
  border-radius: 7px;
}
.tasks li.done .check { background: var(--accent); border-color: var(--accent); }
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(224, 176, 98, 0.12);
  padding: 2px 7px;
  border-radius: 999px;
}
.del {
  padding: 0 4px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  opacity: 0.6;
}
.logout { text-align: center; }

/* ---------- Objectifs et habitudes ---------- */
.levels { display: grid; gap: 14px; }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.period { color: var(--muted); font-weight: 500; font-size: 0.85rem; }

.goals { list-style: none; padding: 0; display: grid; }
.goals li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.goals li:last-child { border-bottom: 0; }
.goals > li { display: block; }
#habitList li { display: flex; align-items: center; gap: 10px; }
.goalmain { display: flex; align-items: flex-start; gap: 10px; }
.goalmain .check { margin-top: 2px; }
.goalbody { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.goalbody .text { word-break: break-word; }
.goalbody .parent { font-size: 0.78rem; color: var(--muted); }
.goals li.done .check { background: var(--accent); border-color: var(--accent); }
.goals li.done .goalbody .text { color: var(--muted); text-decoration: line-through; }
.goals li.dropped { opacity: 0.45; }
.stats { font-size: 0.75rem; color: var(--accent); white-space: nowrap; }

.more {
  padding: 0 6px;
  font-size: 1.2rem;
  line-height: 1.2;
  color: var(--muted);
  background: none;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0 32px;
}
.chip {
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.chip.danger { color: var(--error); }

.addrow { display: grid; gap: 8px; margin-top: 8px; }
.addrow .add { margin-top: 0; }

select.parentpick, select.goalpick {
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
select.goalpick {
  max-width: 34%;
  padding: 3px 8px;
  border-radius: 999px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
select.goalpick.on { color: var(--accent); border-color: rgba(224, 176, 98, 0.4); }

.habitform { display: grid; gap: 10px; margin-top: 10px; }
.habitform .add { margin-top: 0; }
.daypick { display: flex; gap: 6px; }
.daypick button {
  flex: 1;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.daypick button.on { color: #15120c; background: var(--accent); border-color: var(--accent); }

/* ---------- Chrono ---------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }

.runbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  margin-top: calc(-1 * var(--safe-top));
  background: #1d2028;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.runbar[hidden] { display: none; }
.runlabel { color: var(--text); text-decoration: none; font-weight: 600; }
.runclock { color: var(--muted); font-variant-numeric: tabular-nums; }
.runwarn { color: var(--accent); font-size: 0.78rem; text-decoration: none; }
.runstop {
  margin-left: auto;
  padding: 6px 14px;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.runhead { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.bigclock {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 12px;
  color: var(--text) !important;
}
#runCard { display: grid; gap: 10px; }
#runCard[hidden] { display: none; }
.stopbtn { width: 100%; }
.longwarn {
  padding: 12px;
  border: 1px solid rgba(224, 176, 98, 0.4);
  border-radius: 12px;
  background: rgba(224, 176, 98, 0.08);
  display: grid;
  gap: 8px;
}
.longwarn p { color: var(--text); font-size: 0.88rem; }

.inline { display: flex; align-items: center; gap: 8px; }
.inline > input[type="text"], .inline > .add { flex: 1; margin-top: 0; }
input[type="time"] {
  flex: 1;
  padding: 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color-scheme: dark;
}
input[type="color"] {
  width: 38px; height: 38px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex: 0 0 38px;
}

.catgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.catbtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.catbtn.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }

.bars { display: grid; gap: 8px; }
.barrow { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: 0.85rem; }
.barname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bartrack { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.barfill { height: 100%; border-radius: 999px; }
.barval { color: var(--muted); font-variant-numeric: tabular-nums; }

.sessions { list-style: none; padding: 0; }
.sessions li { border-bottom: 1px solid var(--line); }
.sessions li:last-child { border-bottom: 0; }
.sessrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; }
.editform { display: grid; gap: 8px; padding: 0 0 12px 20px; }

details summary { cursor: pointer; color: var(--muted); list-style: none; }
details summary::-webkit-details-marker { display: none; }
.manual { margin-top: 10px; }
.manualform { display: grid; gap: 8px; margin-top: 10px; }
.h2like { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.catlist { list-style: none; padding: 0; display: grid; gap: 8px; margin-top: 12px; }
.catlist .add { border-style: solid; background: var(--bg); }
.mt-s { margin-top: 8px; }

/* ---------- Notes ---------- */
.notesbar { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.newnote { padding: 9px 14px; font-size: 0.9rem; }
input[type="search"].field { -webkit-appearance: none; appearance: none; }

.tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.tagbar[hidden] { display: none; }
.tagchip {
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tagchip.on { color: #15120c; background: var(--accent); border-color: var(--accent); }

.notelist { list-style: none; padding: 0; display: grid; gap: 8px; }
.notelist[hidden] { display: none; }
.notelist li {
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}
.notelist li.trash { cursor: default; opacity: 0.8; }
.nhead { display: flex; justify-content: space-between; gap: 10px; }
.ntitle-s { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nwhen { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.nsub { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#trashToggle { display: block; margin: 6px auto 0; }
#trashToggle[hidden] { display: none; }

.notehead {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(15, 17, 21, 0.96);
  border-bottom: 1px solid var(--line);
}
.notehead .link { font-size: 1rem; color: var(--accent); padding: 0; }
.notehead .status { margin-left: 0; }
.noteactions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.iconbtn {
  width: 36px; height: 36px;
  padding: 0;
  font-size: 1.05rem;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.editbtn { padding: 8px 14px; font-size: 0.9rem; }

.notebody { padding-bottom: 120px; }
.reader { font-size: 1.02rem; line-height: 1.6; word-break: break-word; }
.reader .ntitle { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.reader p { margin: 0; }
.reader .nspace { height: 0.8em; }
.reader a { color: var(--accent); }
.reader .tag { color: var(--accent); font-weight: 500; }
.nlist { padding-left: 1.3em; margin: 2px 0; }
.nlist li { margin: 2px 0; }
.nchecks { list-style: none; padding: 0; margin: 2px 0; display: grid; gap: 4px; }
.nchecks li { display: flex; gap: 10px; align-items: flex-start; }
.nchecks li.on span { color: var(--muted); text-decoration: line-through; }
.ncheck {
  flex: 0 0 20px;
  width: 20px; height: 20px;
  margin-top: 4px;
  padding: 0;
  background: transparent;
  border: 2px solid var(--muted);
  border-radius: 6px;
}
.nchecks li.on .ncheck { background: var(--accent); border-color: var(--accent); }
.nimg { display: block; max-width: 100%; max-height: 420px; border-radius: 12px; margin: 8px 0; }
.filelink {
  display: inline-block;
  padding: 8px 12px;
  margin: 4px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
}

.editor {
  width: 100%;
  min-height: 60vh;
  padding: 0;
  font: inherit;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
}

.toolbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: #1d2028;
  border-top: 1px solid var(--line);
}
.toolbar[hidden] { display: none; }
.toolbar button, .tbfile {
  min-width: 42px; height: 38px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.tbmsg { font-size: 0.8rem; color: var(--muted); }
.toolbar .tbdone { margin-left: auto; font-size: 0.9rem; font-weight: 600; color: #15120c; background: var(--accent); border-color: var(--accent); }

/* ---------- Apprendre ---------- */
.alertline {
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--accent);
  background: rgba(224, 176, 98, 0.08);
  border: 1px solid rgba(224, 176, 98, 0.35);
  border-radius: 12px;
}
.alertline[hidden] { display: none; }

.segment { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.segment button {
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.segment button.on { color: #15120c; background: var(--accent); border-color: var(--accent); }
.addform { display: grid; gap: 8px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.checkline input { width: 18px; height: 18px; accent-color: var(--accent); }

.items { list-style: none; padding: 0; display: grid; }
.item { border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.itemhead { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.kicon { flex: 0 0 28px; font-size: 1.2rem; text-align: center; }
.thumb { flex: 0 0 72px; width: 72px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.itemdetail { display: grid; gap: 10px; padding: 0 0 14px 40px; }
.actions.nomargin { margin: 0; }
.chip.accent { color: #15120c; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.warnmsg { font-size: 0.85rem; color: var(--accent); }
.warnmsg:empty { display: none; }

.rating { display: grid; gap: 8px; }
.stars { display: flex; gap: 4px; }
.star { padding: 0 2px; font-size: 1.4rem; color: var(--accent); background: none; }

.cardform { display: grid; gap: 8px; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.cardform .field { background: var(--card); }
.cards { display: grid; gap: 8px; }
.cardview { padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.cardview .nlist { margin: 4px 0; }

.settings { display: grid; gap: 10px; margin-top: 12px; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--muted); }
.settings input {
  width: 64px;
  padding: 8px;
  font: inherit;
  text-align: center;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.reviews { list-style: none; padding: 0; display: grid; gap: 12px; }
.reviews li { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.reviews li:last-child { border-bottom: 0; padding-bottom: 0; }
.rtext { color: var(--text) !important; }

/* ---------- Apprendre v2 : étagères ---------- */
:root { --serif: ui-serif, "New York", Georgia, "Times New Roman", serif; --wood: #6a5133; --brass: #d2ac5c; }
body.noscroll { overflow: hidden; }
.subtabs { display: flex; gap: 2px; overflow-x: auto; width: 100%; margin-top: 6px; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button {
  padding: 8px 12px 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  white-space: nowrap;
}
.subtabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.subtabs .count {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.35em;
  margin-left: 3px;
  font-size: 0.72rem;
  line-height: 1.4em;
  text-align: center;
  color: #15120c;
  background: var(--brass);
  border-radius: 9px;
}
.learn h2.sec { font-family: var(--serif); font-size: 1.25rem; margin: 18px 0 10px; }
.learn h3 { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; margin: 0 0 6px; }
.learn .mt { margin-top: 22px; }
.empty { color: var(--muted); padding: 16px; border: 1px dashed var(--line); border-radius: 12px; font-size: 0.9rem; }
.nudge { border-left: 3px solid var(--brass); background: var(--card); padding: 10px 14px; border-radius: 0 10px 10px 0; font-size: 0.9rem; }

.meter { display: flex; gap: 22px; flex-wrap: wrap; margin: 4px 0 6px; }
.meter .m b { display: block; font-family: var(--serif); font-size: 1.8rem; font-weight: 600; line-height: 1.1; }
.meter .m b small { font-size: 0.95rem; color: var(--muted); font-weight: 400; }
.meter .m span { color: var(--muted); font-size: 0.8rem; }
.goalbar { height: 6px; width: 150px; margin-top: 6px; background: var(--card); border-radius: 3px; overflow: hidden; }
.goalbar i { display: block; height: 100%; background: var(--accent); }

.readgrid { display: grid; gap: 10px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.readcard { display: grid; grid-template-columns: 10px 1fr; gap: 12px; }
.rib { border-radius: 3px; min-height: 40px; }
.linklike { padding: 0; text-align: left; font-family: var(--serif); font-size: 1.05rem; font-weight: 600; color: var(--text); background: none; border: 0; }
.prog { height: 4px; margin: 8px 0 10px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--brass); }
.quicklog { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; margin-top: 6px; }
.quicklog .field { padding: 9px 10px; }

.addbig {
  width: 100%;
  padding: 14px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px dashed rgba(224, 176, 98, 0.5);
  border-radius: 14px;
}
.addcard { display: grid; gap: 8px; }
.addhead { display: flex; justify-content: space-between; align-items: center; }
.addhead h2 { font-family: var(--serif); margin: 0; }
.addhead .link { color: var(--muted); }
.addbtn { width: 100%; margin-top: 4px; }
.results { list-style: none; padding: 0; display: grid; gap: 4px; }
.results li { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.results li.muted { cursor: default; border-style: dashed; }
.results img, .results .nocover { flex: 0 0 34px; width: 34px; height: 50px; object-fit: cover; border-radius: 3px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.picked img { max-height: 120px; border-radius: 6px; }
.picked[hidden] { display: none; }
.shelfpick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.shelfpick .chip.on { color: #15120c; background: var(--accent); border-color: var(--accent); }
.field.small-input { flex: 1 1 150px; width: auto; padding: 7px 10px; font-size: 0.85rem; }
details.more summary { font-size: 0.88rem; padding: 4px 0; }
details.more .addform { margin-top: 8px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin: 18px 0 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 5px; vertical-align: -2px; background: #5a6070; }
.legend .lg-done { box-shadow: inset 0 -4px 0 var(--brass); }
.legend .lg-rib { background: var(--brass); width: 6px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.legend .lg-faded { opacity: 0.45; }

.shelf { margin: 14px 0 22px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.spines {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 3px;
  padding: 0 6px;
  min-height: 60px;
  border-bottom: 8px solid var(--wood);
  box-shadow: 0 8px 0 -2px rgba(0, 0, 0, 0.35);
}
.spine {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  color: #fff;
  border: 0;
  border-radius: 3px 3px 1px 1px;
  overflow: hidden;
  transition: transform 0.15s ease;
}
.spine:active, .spine:hover { transform: translateY(-6px); }
.spine span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 100%;
  padding: 0 2px;
  font-family: var(--serif);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spine::before, .spine::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: rgba(255, 255, 255, 0.28); }
.spine::before { top: 9px; }
.spine::after { bottom: 9px; }
.spine.done, .binder.done { box-shadow: inset 0 -9px 0 var(--brass); }
.spine.paused, .binder.paused { opacity: 0.45; }
.spine .mark, .binder .mark {
  position: absolute;
  top: 0;
  right: 5px;
  width: 7px;
  height: 22px;
  background: var(--brass);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%);
}
.spine-add {
  width: 32px;
  height: 150px;
  padding: 0;
  font-size: 1.3rem;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 3px;
}
.spine-add.wide { width: 50px; height: 196px; }

/* Classeurs */
.binder {
  position: relative;
  height: 196px;
  padding: 0;
  border: 0;
  border-radius: 6px 6px 2px 2px;
  overflow: hidden;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.18), inset 3px 0 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.15s ease;
}
.binder:active, .binder:hover { transform: translateY(-6px); }
.binder .fill { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, 0.16); }
.binder .win {
  position: absolute;
  left: 17%;
  right: 17%;
  top: 11%;
  bottom: 31%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #efe8d8;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.binder .win span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 100%;
  padding: 4px 0;
  font-family: var(--serif);
  font-size: 0.74rem;
  font-weight: 600;
  color: #2a2620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.binder .hole {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.15);
}
.binder .mod { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 0.62rem; color: rgba(255, 255, 255, 0.8); text-align: center; }

/* Cassettes VHS */
.vhsadd { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.vhsgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px 12px;
  padding: 0 4px 10px;
  border-bottom: 8px solid var(--wood);
  box-shadow: 0 8px 0 -2px rgba(0, 0, 0, 0.35);
  margin-bottom: 8px;
}
.vhsgrid.small { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
.vhs {
  position: relative;
  width: 100%;
  aspect-ratio: 188 / 104;
  padding: 0;
  background: linear-gradient(180deg, #1d1e23, #131418);
  border: 0;
  border-radius: 6px;
  box-shadow: inset 0 -7px 0 #0b0c0e, 0 3px 6px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.vhs .label {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 9%;
  height: 50%;
  background: #f3ead7 center / cover no-repeat;
  border-radius: 3px 3px 0 0;
}
.vhs .strip {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 59%;
  height: 17%;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-family: "Marker Felt", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  font-size: 0.72rem;
  color: #22201b;
  background: #f3ead7;
  border-radius: 0 0 3px 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.vhsgrid.small .strip { font-size: 0.62rem; }
.vhs .win {
  position: absolute;
  left: 30%;
  right: 30%;
  bottom: 6%;
  height: 11%;
  border-radius: 3px;
  background:
    radial-gradient(circle at 25% 50%, #4a4c55 0 28%, transparent 30%),
    radial-gradient(circle at 75% 50%, #4a4c55 0 28%, transparent 30%),
    #26272d;
}
.jbadge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: #c0392b;
  border-radius: 999px;
}
.carton {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 18px;
  padding: 18px 18px;
  font-family: "Marker Felt", "Segoe Print", "Comic Sans MS", cursive;
  color: #3a2a14;
  background:
    linear-gradient(180deg, transparent 46%, rgba(0, 0, 0, 0.12) 46% 54%, transparent 54%),
    #b48a55;
  border: 0;
  border-radius: 6px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
}
.carton-title { font-size: 1.05rem; }
.carton-count { font-size: 1.6rem; font-weight: 700; }

/* Révision */
.revcard { max-width: 640px; }
.revcard .src { color: var(--muted) !important; font-size: 0.85rem; margin-bottom: 10px; }
.revcard blockquote { margin: 0 0 16px; font-family: var(--serif); font-size: 1.25rem; line-height: 1.45; }
.revcard blockquote.blur { filter: blur(7px); user-select: none; }
.revcard textarea { margin: 8px 0 10px; }

/* Grille de lecture */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 12px; height: 12px; border-radius: 2px; background: var(--card); }
.heat i.l1 { background: rgba(224, 176, 98, 0.35); }
.heat i.l2 { background: rgba(224, 176, 98, 0.65); }
.heat i.l3 { background: var(--accent); }

/* Feuille (fiche) */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.sheet-wrap[hidden] { display: none; }
.sheet {
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.grab { width: 40px; height: 4px; margin: 8px auto 0; background: var(--line); border-radius: 2px; }
.sheethead {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 18px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.sheethead .rib { width: 12px; height: 52px; }
.sheethead .cover { width: 46px; height: 68px; object-fit: cover; border-radius: 4px; }
.sheethead .cover.wide { width: 92px; height: 52px; }
.stitle { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 2px; }
.x { padding: 2px 6px; font-size: 1.05rem; color: var(--muted); background: none; border: 0; }
.sheetbody { display: grid; gap: 18px; padding: 16px 18px 0; }
.blk { display: grid; gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label.f { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
select.field { -webkit-appearance: none; appearance: none; }
.stars { display: flex; gap: 2px; }
.star { padding: 0 2px; font-size: 1.4rem; color: var(--line); background: none; border: 0; }
.star.on { color: var(--brass); }
.ins { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ins p { flex: 1; margin: 0; font-family: var(--serif); }
.ins .due { font-size: 0.72rem; color: var(--muted); white-space: nowrap; padding-top: 3px; }
.addline { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.act { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.act input { width: 18px; height: 18px; accent-color: var(--accent); }
.act span { flex: 1; }
.act.done span { color: var(--muted); text-decoration: line-through; }
.inline-btn { display: inline-block; margin-top: 8px; text-decoration: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + var(--safe-bottom));
  z-index: 60;
  max-width: 90vw;
  padding: 10px 16px;
  font-size: 0.88rem;
  color: var(--bg);
  background: var(--text);
  border-radius: 10px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.on { opacity: 1; }
.subtabs .count[hidden] { display: none; }
.subtabs button { padding: 8px 10px 10px; }
.vhsadd, .addline, .quicklog { align-items: center; }
.sheet h3 { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; margin: 0; }
.meter { gap: 18px 26px; }

/* ---------- Planning (Google Agenda) ---------- */
.planhead { display: flex; justify-content: space-between; align-items: baseline; }
.planhead .link { text-decoration: none; font-size: 0.8rem; }
.plan { list-style: none; padding: 0; display: grid; gap: 2px; }
.plan li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.plan li:last-child { border-bottom: 0; }
.plan li.past { opacity: 0.45; }
.ptime { flex: 0 0 92px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ptitle { flex: 1; color: var(--text); text-decoration: none; word-break: break-word; }
#blockToggle { margin-top: 6px; padding: 4px 0; color: var(--accent); }
#blockToggle[hidden], .blockform[hidden] { display: none; }
.blockform { display: grid; gap: 8px; margin-top: 10px; }
.plan-btn { font-size: 0.95rem; opacity: 0.7; }
#planEmpty .link { color: var(--accent); font-size: inherit; }
a.link { color: var(--accent); text-decoration: none; }
.planhead a.link { color: var(--muted); }

/* ---------- Rapports ---------- */
.segment.slim { margin: 0; }
.segment.slim button { padding: 5px 12px; }
.bignum b { font-family: var(--serif); font-size: 2rem; margin-right: 6px; }
.bignum { color: var(--text) !important; }
.pvr { display: grid; gap: 6px; }
.pvrrow { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.pvrday { font-size: 0.8rem; color: var(--muted); }
.pvrbars { display: grid; gap: 3px; }
.pvrbars i { display: block; height: 6px; border-radius: 3px; min-width: 2px; }
.pvrbars i.pl { background: #5a6070; }
.pvrbars i.re { background: var(--accent); }
.legend2 { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }
.weekbars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 90px; align-items: end; margin-top: 10px; }
.wb { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.wb i { display: block; width: 60%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.wb span { font-size: 0.7rem; color: var(--muted); }
details.review { padding: 8px 0; border-bottom: 1px solid var(--line); }
details.review:last-child { border-bottom: 0; }
.weekly { border-color: rgba(224, 176, 98, 0.45); }
.weekly .date { margin-bottom: 8px; }
.wsum { padding-left: 1.1em; margin: 0; display: grid; gap: 3px; font-size: 0.9rem; }

/* ---------- Réglages ---------- */
.pushcfg { display: grid; gap: 4px; }
.pushrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pushrow:last-child { border-bottom: 0; }
.pushrow input[type="time"] { flex: 0 0 auto; width: 92px; padding: 7px 8px; }
.pushrow input[type="time"]:disabled { opacity: 0.4; }
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: 0 0 46px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background 0.2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Méditer ---------- */
body[data-page="meditation"] { background: #0b0c0f; }
.medstats { display: flex; gap: 22px; flex-wrap: wrap; }
.medstats .m b { display: block; font-family: var(--serif); font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.medstats .m span { color: var(--muted); font-size: 0.8rem; }
.medcard { display: grid; gap: 8px; }
.medcard .segment { margin-bottom: 4px; }
.medstart { width: 100%; margin-top: 6px; padding: 16px; font-size: 1.05rem; }

.medscreen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(20px + var(--safe-top)) 24px calc(30px + var(--safe-bottom));
  background: #000;
  color: #cfd3da;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.medscreen[hidden] { display: none; }
.orb {
  width: 62vmin;
  height: 62vmin;
  max-width: 340px;
  max-height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(224, 176, 98, 0.32), rgba(224, 176, 98, 0.08) 55%, rgba(224, 176, 98, 0) 70%);
  box-shadow: 0 0 80px rgba(224, 176, 98, 0.12);
  transform: scale(0.6);
  will-change: transform;
}
.medphase { margin-top: 18px; font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: #6b717c; }
.medbig { font-family: var(--serif); font-size: 3rem; font-weight: 500; color: #e2e5ea; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.medsub { font-size: 0.95rem; color: #7d838e; min-height: 1.4em; text-align: center; }
.medctl { position: absolute; bottom: calc(40px + var(--safe-bottom)); display: flex; gap: 10px; }
.medctl[hidden] { display: none; }
.medbtn { padding: 12px 22px; font-weight: 500; color: #cfd3da; background: #15171c; border: 1px solid #262a33; border-radius: 999px; }
.medbtn.main { color: #15120c; background: var(--accent); border-color: var(--accent); }
.remindbox { display: grid; gap: 4px; margin-top: 8px; }
.remindbox input[type="time"] { flex: 0 0 auto; width: 100px; padding: 7px 8px; }
