/* Quantum Portal — application. Même direction artistique que le programme : carnet papier, encre, crayon rouge, or. */
:root {
  --paper: #F4EDE0; --paper-2: #EDE3D1; --card: #FFFCF5; --ink: #2A2430; --ink-2: #5B5260; --muted: #8C8580;
  --red: #C4122C; --red-soft: #F6E1DE; --gold: #B88434; --gold-soft: #F3E6CA; --kraft: #D9C29A; --line: #E6DCCB; --ok: #3E7B54;
  --display: "Fraunces", Georgia, serif; --body: "Source Serif 4", Georgia, serif; --hand: "Caveat", "Bradley Hand", cursive;
  --shadow: 0 1px 0 rgba(42,36,48,.05), 0 10px 22px -14px rgba(42,36,48,.4);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  min-height: 100dvh; color: var(--ink); font: 17px/1.55 var(--body); background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.12; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 34px; font-weight: 800; } h2 { font-size: 26px; font-weight: 700; } h3 { font-size: 21px; font-weight: 600; }
p { margin: 0 0 12px; }
a { color: var(--red); }
.hand { font-family: var(--hand); font-weight: 500; font-size: 1.3em; color: var(--gold); line-height: 1.15; }
.muted { color: var(--muted); font-size: 15px; }
.st { filter: drop-shadow(0 5px 7px rgba(60,40,20,.22)); pointer-events: none; }

/* ---------- squelette */
.screen { max-width: 560px; margin: 0 auto; padding: 18px 18px calc(110px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 18px; min-height: 40px; }
.topbar .back { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid #CDBFA6; background: var(--card); font-size: 20px; cursor: pointer; display: grid; place-items: center; }
.topbar .ttl { font: 600 15px var(--body); color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; flex: 1; }
.saved { font: 600 13px var(--body); color: var(--ok); opacity: 0; transition: opacity .3s; }
.saved.on { opacity: 1; } .saved.err { color: var(--gold); }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; gap: 2px;
  padding: 8px 10px calc(8px + var(--safe-b)); background: rgba(250,246,238,.96); backdrop-filter: blur(8px); border-top: 1px solid #DCCFB8; }
nav.tabs a { flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--ink-2); font: 600 12px var(--body); padding: 4px 0; border-radius: 12px; position: relative; }
nav.tabs a img { width: 30px; height: 30px; }
nav.tabs a.on { color: var(--red); background: #FFF4EE; }
nav.tabs a.lock { opacity: .45; }
nav.tabs a.lock::after { content: "🔒"; position: absolute; top: 0; right: 18%; font-size: 11px; }

/* ---------- boutons, champs */
.btn { display: block; width: 100%; text-align: center; font: 600 17px var(--body); padding: 14px 18px; border-radius: 12px; border: 2px solid var(--ink);
  background: var(--red); color: #fff; text-decoration: none; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); margin: 10px 0; }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.ghost { background: var(--card); color: var(--ink); }
.btn.gold { background: var(--gold); }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 15px; margin: 4px 6px 4px 0; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
label.lb { display: block; font: 600 14px var(--body); color: var(--ink-2); margin: 14px 0 4px; }
.in, textarea.in, select.in { width: 100%; border: none; border-bottom: 2px solid #CDBFA6; background: rgba(255,255,255,.65); padding: 10px 12px;
  font: 500 24px/1.3 var(--hand); color: #1F3B73; border-radius: 6px 6px 0 0; resize: none; overflow: hidden; }
input.in.plain, select.in { font: 17px var(--body); color: var(--ink); }
.in:focus { outline: none; border-bottom-color: var(--red); background: #fff; }
.in::placeholder { color: #B9AE9C; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip { border: 1.5px solid #CDBFA6; background: var(--card); border-radius: 999px; padding: 8px 14px; font: 600 15px var(--body); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { border-color: var(--red); color: var(--red); background: #FFF4EE; }
.chip img { width: 26px; height: 26px; }
.err-msg { color: var(--red); font-size: 15px; min-height: 20px; }

/* ---------- cartes */
.card { position: relative; background: var(--card); border-radius: 6px; box-shadow: var(--shadow); padding: 20px 18px; margin: 16px 0; }
.card.ruled { background-image: repeating-linear-gradient(transparent 0 31px, #DCE6EE 31px 32px); background-position: 0 58px; }
.card.ruled::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 1.5px; background: rgba(196,18,44,.3); }
.tape { position: absolute; width: 96px; height: 26px; background: rgba(217,194,154,.75); top: -11px; left: 26px; transform: rotate(-4deg);
  clip-path: polygon(3% 0, 97% 4%, 100% 50%, 96% 100%, 2% 96%, 0 50%); }
.card .corner { position: absolute; right: -8px; top: -18px; width: 74px; transform: rotate(8deg); }
.stamp { display: inline-block; font: 700 12px var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--red); border: 2px solid var(--red); border-radius: 4px; padding: 2px 8px; transform: rotate(-2deg); }
.kraft { background: var(--kraft); color: #3A2E20; padding: 16px 18px; border-radius: 3px; margin: 16px 0; transform: rotate(.4deg); }
.kraft b { font: 700 22px var(--hand); display: block; }
.postit { background: #FBEFC8; padding: 16px 18px; margin: 16px 0; transform: rotate(-.6deg); box-shadow: 0 10px 16px -12px rgba(60,40,10,.5); font: 500 22px/1.3 var(--hand); color: #2B2A44; }
.postit h4 { font: 700 24px var(--hand); color: var(--red); margin-bottom: 4px; }
.note { background: var(--red-soft); border-left: 4px solid var(--red); padding: 10px 14px; border-radius: 4px; font-size: 15px; margin: 12px 0; }
.note.gold { background: var(--gold-soft); border-left-color: var(--gold); }

/* ---------- accueil */
.hello { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.hello img { width: 58px; }
.hello h1 { font-size: 28px; }
.daycard { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); }
.daycard img { width: 74px; flex: none; }
.daycard .k { font: 700 12px var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--red); }
.daycard h3 { font-size: 24px; }
.target { background: var(--card); border-radius: 4px; box-shadow: var(--shadow); padding: 22px 18px 16px 30px; margin: 16px 0; position: relative;
  background-image: repeating-linear-gradient(transparent 0 33px, #DCE6EE 33px 34px); background-position: 0 50px; font: 500 25px/1.35 var(--hand); color: #1F3B73; }
.target::before { content: ""; position: absolute; left: 18px; top: 0; bottom: 0; width: 1.5px; background: rgba(196,18,44,.35); }
.target .lbl { font: 700 11px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--red); display: block; margin-top: 4px; }
.sos { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--paper); border-radius: 14px; padding: 14px 16px; text-decoration: none; margin: 16px 0; }
.sos img { width: 46px; } .sos b { font: 700 17px var(--body); display: block; } .sos span { font-size: 14px; color: #D9CFBF; }

/* ---------- jours, protocoles */
.dayhead { text-align: center; padding: 6px 0 4px; }
.dayhead img { width: 120px; transform: rotate(5deg); }
.daystamp { display: inline-block; font: 800 18px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--red); border: 3px solid var(--red); border-radius: 6px; padding: 2px 12px; transform: rotate(-3deg); margin: 8px 0; }
.list a, .list .it { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 10px; padding: 12px 14px; margin: 10px 0; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.list img { width: 46px; flex: none; }
.list .t { flex: 1; } .list .t b { display: block; font: 600 17px var(--body); } .list .t span { font-size: 14px; color: var(--muted); }
.badge { font: 700 12px var(--body); padding: 4px 9px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: #E3F0E6; color: var(--ok); } .badge.go { background: var(--red); color: #fff; }
.progress { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; margin: 10px 0 2px; }
.progress i { display: block; height: 100%; background: var(--red); transition: width .4s; }
.steps-dots { display: flex; gap: 6px; justify-content: center; margin: 4px 0 14px; }
.steps-dots i { width: 8px; height: 8px; border-radius: 50%; background: #D8CBB3; } .steps-dots i.on { background: var(--red); width: 22px; border-radius: 99px; }
.flow h2 { margin: 6px 0 10px; }
.flow .why { font: 600 19px/1.4 var(--display); margin: 8px 0 12px; }
.rung { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.rung .n { font: 700 26px var(--hand); color: var(--red); width: 26px; text-align: center; }
.rung .tx { flex: 1; background: var(--card); border-radius: 8px; padding: 8px 12px; font: 500 22px var(--hand); color: #1F3B73; box-shadow: var(--shadow); }
.arrow-down { text-align: center; color: var(--gold); font: 700 22px var(--hand); margin: -2px 0; }

/* compteur */
.counter { text-align: center; margin: 16px 0; }
.counter .num { font: 800 72px var(--display); line-height: 1; }
.counter .lab { font: 500 24px var(--hand); color: var(--gold); }
.tapbig { width: 190px; height: 190px; border-radius: 50%; border: 3px solid var(--ink); background: var(--red); color: #fff; font: 700 20px var(--body); box-shadow: 4px 4px 0 var(--ink); cursor: pointer; margin: 14px auto; display: grid; place-items: center; }
.tapbig:active { transform: translate(3px,3px) scale(.98); box-shadow: 1px 1px 0 var(--ink); }

/* minuteurs */
.timer { text-align: center; margin: 16px 0; }
.orb { width: 210px; height: 210px; margin: 10px auto; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #F7C9C5, var(--red)); display: grid; place-items: center;
  transform: scale(.6); transition: transform 5s ease-in-out; box-shadow: 0 0 0 14px rgba(196,18,44,.08); }
.orb.in { transform: scale(1); }
.orb span { font: 700 30px var(--hand); color: #fff; }
.tbig { font: 800 56px var(--display); font-variant-numeric: tabular-nums; }
.hg { width: 120px; margin: 6px auto; } .hg.run { animation: flip 2s ease-in-out infinite; }
@keyframes flip { 0%,80% { transform: rotate(0); } 100% { transform: rotate(180deg); } }

/* argue test */
.argue { background: var(--card); border-radius: 10px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow); }
.argue .s { font: 500 22px/1.25 var(--hand); color: #1F3B73; margin-bottom: 8px; }
.argue .chips { margin: 0; } .argue .chip { padding: 6px 10px; font-size: 14px; }

/* tracker */
.trk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0; }
.trk i { aspect-ratio: 1; border: 1.5px solid var(--ink-2); border-radius: 4px; background: #fff; position: relative; font-style: normal; font: 600 11px var(--body); color: var(--muted); display: grid; place-items: center; }
.trk i.x::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font: 700 26px var(--hand); }
.trk i.today { border-color: var(--red); border-width: 2.5px; }

/* anneau de la routine */
.ring { display: flex; align-items: center; gap: 16px; }
.ring svg { width: 130px; height: 130px; flex: none; }
.blocks .blk { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 10px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow); cursor: pointer; border-left: 6px solid var(--c, var(--gold)); }
.blocks .blk.done { opacity: .62; }
.blocks .blk .t { flex: 1; } .blocks .blk b { display: block; } .blocks .blk span { font-size: 14px; color: var(--muted); }
.blocks .blk .ck { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink-2); display: grid; place-items: center; font-weight: 700; color: #fff; }
.blocks .blk.done .ck { background: var(--ok); border-color: var(--ok); }

/* graphique */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding: 6px 0; border-bottom: 1.5px solid var(--ink-2); }
.chart i { flex: 1; background: var(--red); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.chart i.g { background: var(--gold); }
.chart-l { display: flex; gap: 5px; font-size: 10px; color: var(--muted); } .chart-l span { flex: 1; text-align: center; }

/* exemples */
.ex { background: var(--card); border-radius: 6px; padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); border-top: 4px solid var(--gold); }
.ex:nth-child(3n+2) { border-top-color: var(--red); } .ex:nth-child(3n) { border-top-color: var(--ink); }
.ex h4 { font: 700 23px var(--hand); margin-bottom: 4px; }
.ex dt { font: 700 11px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--red); margin-top: 6px; } .ex dd { margin: 0; font-size: 16px; }

/* installation */
.choice { display: flex; align-items: center; gap: 14px; width: 100%; background: var(--card); border: 2px solid #DCCFB8; border-radius: 14px; padding: 14px; margin: 10px 0; cursor: pointer; font: 600 18px var(--body); color: var(--ink); text-align: left; }
.choice.on { border-color: var(--red); background: #FFF6F2; }
.choice .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 26px; background: var(--paper-2); flex: none; }
.istep { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; }
.istep .n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font: 700 16px var(--body); }
.istep .tx { flex: 1; padding-top: 4px; }
.kbd { display: inline-flex; align-items: center; gap: 4px; border: 1.5px solid var(--ink-2); border-radius: 8px; padding: 1px 8px; background: #fff; font: 600 15px var(--body); white-space: nowrap; }
.kbd svg { width: 16px; height: 16px; }
.mock { background: #fff; border: 2px solid var(--ink); border-radius: 22px; padding: 12px; margin: 10px auto; max-width: 260px; box-shadow: var(--shadow); font-size: 14px; }

/* modale, toast */
#modal:empty { display: none; }
.mback { position: fixed; inset: 0; z-index: 50; background: rgba(30,24,30,.45); display: flex; align-items: flex-end; justify-content: center; }
.msheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--paper); border-radius: 20px 20px 0 0; padding: 18px 18px calc(24px + var(--safe-b)); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font: 600 15px var(--body); opacity: 0; transition: .3s; z-index: 60; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; transform: translateX(-50%); }
.celebrate { text-align: center; padding: 20px 0; }
.celebrate img { width: 170px; animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* connexion */
.authbox { max-width: 420px; margin: 0 auto; padding: 40px 22px; text-align: center; }
.authbox img.logo { width: 130px; animation: spin 40s linear infinite; }
.authbox form { text-align: left; }
.linkish { background: none; border: none; color: var(--red); font: 600 15px var(--body); cursor: pointer; text-decoration: underline; padding: 6px; }
.demo { font-size: 13px; color: var(--gold); margin-top: 10px; }
