:root {
  --paper: #f5eee2;
  --paper-2: #ece2d1;
  --card: #fffaf2;
  --ink: #14322f;
  --ink-2: #4b615d;
  --ink-3: #8a968f;
  --saffron: #e5762a;
  --saffron-d: #c45d15;
  --jade: #1f7a63;
  --chili: #c2412d;
  --line: #e2d6c2;
  --radius: 18px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; }
body { min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: var(--ink); }
.hidden { display: none !important; }

/* Écrans d'accueil */
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.locked-card { text-align: center; max-width: 340px; }
.locked-card h1 { font-family: var(--display); font-size: 34px; margin: 18px 0 8px; letter-spacing: -0.02em; }
.locked-card p { color: var(--ink-2); line-height: 1.5; margin: 0 0 28px; }
.logo-big { width: 84px; height: 84px; margin: 0 auto; border-radius: 26px; background: var(--saffron); color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 50px; transform: rotate(-6deg); box-shadow: 0 10px 30px -10px rgba(197, 93, 21, .6); }
.who-buttons { display: grid; gap: 12px; }
.who-buttons button { padding: 18px; border-radius: 16px; background: var(--ink); color: var(--paper); font-family: var(--display); font-weight: 700; font-size: 22px; }
.who-buttons button:active { transform: scale(.98); }

/* App */
#app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 0; }
.top { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--saffron-d); }
.title { font-family: var(--display); font-size: 38px; line-height: 1; margin: 4px 0 0; letter-spacing: -0.03em; font-weight: 800; }
.me-chip { padding: 8px 14px; border-radius: 999px; background: var(--paper-2); font-weight: 600; font-size: 14px; }
.me-chip::before { content: "● "; color: var(--jade); }

.balance { background: var(--ink); color: var(--paper); border-radius: 24px; padding: 22px 20px 18px; position: relative; overflow: hidden; }
.balance-line { font-family: var(--display); font-weight: 700; font-size: 25px; line-height: 1.2; letter-spacing: -0.01em; }
.balance-line b { color: #ffb57e; font-weight: 800; }
.balance-eur { color: #b9cbc6; margin-top: 4px; font-size: 15px; }
.balance-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: #9db3ad; }
.stat .v { font-family: var(--display); font-weight: 700; font-size: 17px; margin-top: 2px; }
.stat .s { font-size: 12px; color: #9db3ad; }
.settle { margin-top: 16px; width: 100%; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.1); color: var(--paper); font-weight: 600; font-size: 15px; position: relative; z-index: 1; }

.feed-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 6px; }
.feed-head h2 { font-family: var(--display); font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.feed-head span { color: var(--ink-3); font-size: 13px; }
.day { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 18px 4px 8px; display: flex; justify-content: space-between; }
.items { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item:active { background: var(--paper-2); }
.ico { width: 40px; height: 40px; border-radius: 12px; background: var(--paper-2); display: grid; place-items: center; font-size: 20px; flex: none; }
.item.transfer .ico { background: #dcefe7; }
.item.note .ico { background: #fde4cf; }
.meta { flex: 1; min-width: 0; }
.meta .d { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .w { font-size: 13px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { text-align: right; flex: none; }
.amt .a { font-family: var(--display); font-weight: 700; font-size: 17px; }
.amt .e { font-size: 12px; color: var(--ink-3); }
.mini-play { width: 30px; height: 30px; border-radius: 50%; background: var(--saffron); color: #fff; font-size: 11px; display: grid; place-items: center; flex: none; }
.mini-play.on { background: var(--ink); }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); line-height: 1.6; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { font-family: var(--display); font-size: 20px; color: var(--ink); display: block; margin-bottom: 6px; }
.feed-pad { height: calc(130px + var(--safe-b)); }

/* Dock */
.dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 20px calc(14px + var(--safe-b)); display: flex; align-items: center; justify-content: center; background: linear-gradient(to top, var(--paper) 55%, rgba(245,238,226,0)); }
.mic { width: 76px; height: 76px; border-radius: 50%; background: var(--saffron); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 28px -8px rgba(197,93,21,.7), inset 0 -3px 0 rgba(0,0,0,.12); transition: transform .12s; }
.mic:active { transform: scale(.94); }
.mic .stop-ico { display: none; }
.mic.rec { background: var(--chili); animation: pulse 1.4s infinite; }
.mic.rec .mic-ico { display: none; }
.mic.rec .stop-ico { display: block; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194,65,45,.55); } 70% { box-shadow: 0 0 0 22px rgba(194,65,45,0); } 100% { box-shadow: 0 0 0 0 rgba(194,65,45,0); } }
.dock-add { position: absolute; left: max(20px, calc(50% - 260px)); display: flex; align-items: center; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.dock-hint { position: absolute; right: max(20px, calc(50% - 260px)); font-size: 13px; color: var(--ink-2); font-weight: 500; max-width: 110px; text-align: right; }

/* Enregistrement */
.rec-overlay { position: fixed; inset: 0; background: rgba(20,50,47,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px calc(120px + var(--safe-b)); z-index: 5; }
.rec-box { background: var(--card); border-radius: 24px; padding: 22px; width: 100%; max-width: 420px; text-align: center; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--chili); margin: 0 auto; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-family: var(--display); font-weight: 800; font-size: 44px; margin: 6px 0; font-variant-numeric: tabular-nums; }
.rec-tip { color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.rec-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 18px; }
.dock.recording { z-index: 6; }

.busy { position: fixed; inset: 0; background: rgba(245,238,226,.88); display: grid; place-content: center; justify-items: center; gap: 14px; z-index: 20; font-weight: 600; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--paper-2); border-top-color: var(--saffron); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Feuille */
.sheet-wrap { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20,50,47,.45); }
.sheet { position: relative; background: var(--card); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { font-family: var(--display); font-size: 24px; margin: 0; letter-spacing: -0.02em; }
.x { font-size: 28px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; background: var(--paper-2); }
.field { margin-top: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); margin-bottom: 6px; }
.field input[type=text], .field input[type=date] { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; min-height: 50px; }
.field input:focus { border-color: var(--saffron); }
.amount-row { display: flex; gap: 8px; }
.amount-row input { flex: 1; font-family: var(--display); font-weight: 700; font-size: 28px !important; }
.hint { font-size: 13px; color: var(--ink-3); margin-top: 5px; min-height: 1em; }
.seg { display: flex; background: var(--paper-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 10px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg.small { flex: none; width: 104px; }
.seg.small button { font-size: 20px; padding: 6px; }
#kindSeg { margin-top: 4px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats button { padding: 8px 11px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: 14px; font-weight: 500; }
.cats button.on { border-color: var(--saffron); background: #fde9da; }
.voice-box { background: #fdf1e6; border: 1px solid #f3d3b6; border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.voice-row { display: flex; gap: 10px; align-items: flex-start; }
.play { width: 36px; height: 36px; border-radius: 50%; background: var(--saffron); color: #fff; flex: none; font-size: 13px; }
.play.on { background: var(--ink); }
.voice-transcript { font-size: 14px; line-height: 1.45; color: var(--ink); font-style: italic; padding-top: 2px; }
.voice-note { font-size: 13px; color: var(--saffron-d); margin-top: 8px; font-weight: 500; }
.form-error { margin-top: 12px; background: #fbe1dc; color: var(--chili); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary { flex: 1; padding: 15px; border-radius: 14px; background: var(--saffron); color: #fff; font-weight: 700; font-size: 16px; }
.btn-primary:disabled { opacity: .6; }
.btn-ghost { padding: 15px 16px; border-radius: 14px; background: var(--paper-2); font-weight: 600; }
.btn-danger { padding: 15px 16px; border-radius: 14px; background: #fbe1dc; color: var(--chili); font-weight: 600; }
.sheet.k-note .money-only, .sheet.k-note .expense-only, .sheet.k-transfer .expense-only, .sheet.k-transfer .only-expense { display: none; }

.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 14px); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }
.toast.err { background: var(--chili); }
