:root {
  --navy: #1F3864; --bg: #e9ecf2; --card: #ffffff; --ink: #14213d; --mute: #6b7a99; --line: #d3dae8; --warn: #e8590c;
  --body1: #c4c7cc; --body2: #9a9ea5; --dark: #3b4048; --dark2: #2a2e35; --light: #eceef0; --orange: #e8801f;
  --yel: #f2c200; --red: #d4202a; --lcdbg: #c8d1bd; --lcdink: #1d2619;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--ink); display: flex; flex-direction: column; overflow-x: hidden; }
main { flex: 1; overflow: auto; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); }
.pane { max-width: 430px; margin: 0 auto; min-width: 0; width: 100%; }
.pane[hidden] { display: none; }

/* ---------- Châssis calculatrice ---------- */
.casio { container-type: inline-size; background: linear-gradient(160deg, var(--body1), var(--body2)); border-radius: 22px 22px 38px 38px; padding: 8px 12px 16px; border: 2px solid var(--casio-border, #7d8189); box-shadow: 0 10px 24px rgba(20,33,61,.35), inset 0 2px 0 rgba(255,255,255,.55); }
.brandbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.logo { background: var(--logo-bg, var(--navy)); color: var(--logo-ink, #fff); font-weight: bold; font-size: 13px; letter-spacing: 1.5px; padding: 3px 10px; border-radius: 4px; }
.tagline { white-space: nowrap; font-size: 9.5px; font-size: clamp(7px, 2.4cqw, 9.5px); letter-spacing: .6px; color: var(--tag-ink, #1b6a3a); font-weight: bold; font-style: italic; }
.model { font-size: 12px; color: var(--model-ink, #2b2f36); margin: 3px 2px 6px; }
.model i { color: var(--model-ink, #555); opacity: .7; }

.lcd { background: var(--lcdbg); border: 5px solid #23262b; border-radius: 8px; padding: 3px 8px 4px; box-shadow: inset 0 3px 8px rgba(0,0,0,.35); color: var(--lcdink); }
.ind { display: flex; gap: 9px; font-size: 9.5px; font-weight: bold; min-height: 12px; }
.ind span { visibility: hidden; }
.ind span.on, .ind .math { visibility: visible; }
.ind .math { margin-left: auto; opacity: .75; }
math-field#expr { display: block; width: 100%; min-height: 58px; font-size: 24px; font-size: max(24px, 6.4cqw); color: var(--lcdink); background: transparent; border: 0; outline: none; padding: 2px 0; --caret-color: #111; --selection-background-color: rgba(31,56,100,.25); --text-font-family: Arial, sans-serif; }
math-field#expr::part(container) { padding: 2px 0; }
math-field#expr::part(virtual-keyboard-toggle), math-field#expr::part(menu-toggle) { display: none; }
math-field#expr:focus-within { outline: none; }
.result { text-align: right; font-size: 28px; font-size: max(28px, 7.4cqw); font-weight: bold; min-height: 32px; overflow-x: auto; white-space: nowrap; font-family: "Courier New", monospace; }
.result .frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin-left: 2px; }
.result .frac .num { border-bottom: 2px solid var(--lcdink); padding: 0 6px 1px; }
.result .frac .den { padding: 1px 6px 0; }
.result .sgn { vertical-align: middle; margin-right: 2px; }
.result sup { font-size: .6em; }
.msg { color: #8a1c0e; font-size: 11px; min-height: 13px; }

.chips { display: flex; gap: 5px; overflow-x: auto; padding: 8px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: #d9dce1; border: 1px solid #7d8189; border-radius: 999px; padding: 3px 9px; font-size: 12px; color: var(--dark2); }
.chip i { font-style: normal; color: #5b6270; margin-left: 4px; }

.g5, .g6 { display: grid; gap: 6px 8px; margin-top: 4px; }
.g5 { grid-template-columns: repeat(5, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); gap: 6px 6px; }
#pad-top { grid-template-rows: auto auto; grid-template-columns: 1fr 1fr 1.6fr 1fr 1fr; column-gap: 8px; }
.kw { position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding-top: 13px; padding-top: max(13px, 3.4cqw); min-width: 0; }
.sl, .al { position: absolute; top: 0; font-size: 10px; font-size: max(10px, 2.7cqw); font-weight: bold; line-height: 12px; white-space: nowrap; }
.sl { left: 2px; color: var(--sl-ink, #a67800); }
.al { right: 2px; color: var(--al-ink, var(--red)); }
.k { height: 40px; height: max(40px, 10.2cqw); touch-action: manipulation; border: 0; border-radius: 20px / 14px; font-size: 13px; font-size: max(13px, 3.4cqw); background: linear-gradient(#4a5058, var(--dark2)); color: #fff; box-shadow: 0 2px 0 #14161a, inset 0 1px 0 rgba(255,255,255,.25); padding: 0; }
.g6 .k { font-size: 12.5px; font-size: max(12.5px, 3.2cqw); }
#pad-low .k { height: 44px; height: max(44px, 11.6cqw); font-size: 19px; font-size: max(19px, 5cqw); border-radius: 12px; }
.k:active { transform: translateY(1px); box-shadow: 0 1px 0 #14161a; }
.k.num { background: linear-gradient(#fbfbfc, #d5d7db); color: #14161a; font-weight: bold; box-shadow: 0 2px 0 #7c8087; }
.k.del { background: linear-gradient(#f39a3b, var(--orange)); color: #fff; font-weight: bold; box-shadow: 0 2px 0 #9a5410; font-size: 16px; }
.k.yel { background: linear-gradient(#f7d64a, var(--yel)); color: #1b1b1b; font-weight: bold; box-shadow: 0 2px 0 #8a6f00; }
.k.red { background: linear-gradient(#ea5560, var(--red)); color: #fff; font-weight: bold; box-shadow: 0 2px 0 #7a0e15; }
.k.on-active { outline: 2px solid #fff; }
.k.eq { background: linear-gradient(#4a5058, var(--dark2)); font-size: 20px; font-weight: bold; }

.kw.padcell { grid-column: 3; grid-row: 1 / span 2; padding-top: 0; align-items: center; justify-content: center; }
.replay { position: relative; width: 100%; max-width: 104px; aspect-ratio: 1; height: auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5a616b, #23262c); box-shadow: 0 3px 0 #0e1013, inset 0 2px 0 rgba(255,255,255,.2); margin: 0 auto; }
.replay b { position: absolute; width: 34%; height: 34%; color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; touch-action: manipulation; }
.replay b.u { top: 2%; left: 33%; } .replay b.d { bottom: 2%; left: 33%; }
.replay b.l { left: 2%; top: 33%; } .replay b.r { right: 2%; top: 33%; }
.replay span { position: absolute; inset: 29%; border-radius: 50%; background: linear-gradient(#6c737d, #3a3f47); color: #cfd3d9; font-size: 7px; letter-spacing: .5px; display: flex; align-items: center; justify-content: center; }

/* ---------- Pages Formules / Mémoires ---------- */
.hist { margin-top: 12px; }
.hist summary { color: var(--mute); font-size: 13px; }
.hrow { display: flex; justify-content: space-between; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-family: "Courier New", monospace; font-size: 14px; }
.hrow b { color: var(--navy); }
.tabs { display: flex; background: var(--navy); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; padding: 13px 4px; border: 0; background: transparent; font-size: 14px; color: #aab8d6; border-top: 3px solid transparent; }
.tabs button.on { color: #fff; font-weight: bold; border-top-color: var(--yel); }

.search { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; margin-bottom: 10px; }
.cols { display: flex; gap: 8px; margin-bottom: 10px; }
.cols button { flex: 1; padding: 9px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font-size: 15px; font-weight: 600; }
.cols button small { display: block; font-weight: 400; font-size: 12px; color: var(--mute); }
.cols button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.cols button.on small { color: #dbe4f0; }
.group h3 { margin: 16px 0 6px; color: var(--navy); font-size: 14px; text-transform: uppercase; letter-spacing: .5px; }
.fitem { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 6px; font-size: 15px; color: var(--ink); }
.fitem small { display: block; color: var(--mute); margin-top: 2px; }
.back { background: none; border: 0; color: var(--navy); font-size: 15px; padding: 4px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.card h2 { margin: 0 0 4px; font-size: 17px; color: var(--navy); }
.ref { color: var(--mute); font-size: 12px; margin-bottom: 8px; }
.field { display: grid; grid-template-columns: 1fr 110px 54px; gap: 8px; align-items: center; padding: 5px 0; font-size: 14px; }
.field input { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; text-align: right; }
.unit { color: var(--mute); font-size: 12px; }
.out { display: grid; grid-template-columns: 1fr auto 54px; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; align-items: center; }
.out b { color: var(--navy); font-size: 16px; cursor: pointer; text-align: right; }
.out.bad b { color: var(--warn); }
.note { font-size: 12px; color: var(--mute); margin-top: 8px; line-height: 1.4; }
.btn { background: var(--navy); color: #fff; border: 0; border-radius: 10px; padding: 11px 14px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
.row-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.row-actions .btn { flex: 1; }
.hint { color: var(--mute); font-size: 13px; }
.hint code { background: #fff; padding: 1px 5px; border-radius: 4px; }
.vrow { display: grid; grid-template-columns: 90px 1fr 36px; gap: 8px; padding: 6px 0; align-items: center; }
.vrow input { padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.vrow button { border: 0; background: transparent; color: var(--warn); font-size: 20px; }
.solve { margin-top: 10px; }
.solve summary { color: var(--navy); font-size: 14px; }
.solve .field { grid-template-columns: 1fr 1fr; }
.solve select, .solve input { padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; width: 100%; }

/* ---------- Une calculatrice, rien d'autre à l'écran ---------- */
main { display: flex; justify-content: center; align-items: flex-start; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.calcpane { margin: 0 auto; }
body.ov-open .calcpane { visibility: hidden; }
.ov { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow: auto; padding: 0 14px 24px; max-width: none; }
.ov > *:not(.ov-bar) { max-width: 560px; margin-left: auto; margin-right: auto; }
.ov-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; margin: 0 -14px 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); max-width: none !important; }
.ov-close { background: var(--yel); color: #1b1b1b; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: bold; font-size: 14px; }

.casio { transform-origin: top center; }

/* ---------- Premium ---------- */
.premium-bar { display: block; width: 100%; margin: 0 0 10px; padding: 12px; border: 0; border-radius: 10px; background: var(--yel); color: #1b1b1b; font-weight: bold; font-size: 15px; }
.premium-bar.on { background: #1f7a45; color: #fff; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tool { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; font-size: 14px; font-weight: 600; color: var(--navy); }
.tool small { display: block; font-weight: 400; font-size: 11px; color: var(--mute); margin-top: 2px; }
.fitem.locked { opacity: .55; background: #f1f3f7; }
.notice { background: #fff4d6; border: 1px solid #f2c200; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.notice.ok { background: #e3f6ea; border-color: #1f7a45; }
.notice.err { background: #fde6e3; border-color: var(--warn); }
.plist { margin: 6px 0 10px; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.price { font-weight: bold; color: var(--navy); font-size: 16px; margin: 6px 0 0; }
.devid { font-family: "Courier New", monospace; font-size: 22px; letter-spacing: 2px; background: #f1f3f7; border-radius: 8px; padding: 10px; text-align: center; margin-bottom: 10px; user-select: all; }
a.btn { display: block; text-align: center; text-decoration: none; }
a.btn.wa { background: #1f9d55; }
.codebox { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-family: "Courier New", monospace; font-size: 14px; margin-bottom: 8px; }
.card.actif { border-color: var(--navy); border-width: 2px; }
.xbtn { border: 0; background: transparent; color: var(--warn); font-size: 22px; }
.field.one { grid-template-columns: 1fr; }
.field.two { grid-template-columns: 1fr 1fr; }
.field select, .field input[type=text] { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; text-align: left; }
.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 5px 7px; text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; font-weight: bold; }
.scrollx { overflow-x: auto; }
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 8px; font-size: 14px; color: var(--ink); }
.theme i { display: block; height: 54px; border-radius: 8px; margin-bottom: 6px; border: 2px solid rgba(0,0,0,.25); }
.theme.on { border-color: var(--navy); font-weight: bold; }
.pbody { padding-bottom: 20px; }
#print-report { display: none; }
@media print {
  html, body { height: auto !important; overflow: visible !important; display: block !important; background: #fff !important; }
  body > *:not(#print-report) { display: none !important; }
  #print-report { display: block; color: #000; font: 11pt Arial, sans-serif; }
  .pr-head { display: flex; justify-content: space-between; border-bottom: 3px solid #1F3864; padding-bottom: 6px; color: #1F3864; }
  #print-report h1 { font-size: 16pt; margin: 12px 0 2px; }
  .pr-blk { margin: 12px 0; break-inside: avoid; }
  .pr-ref { font-size: 9pt; color: #555; }
  .pr-t { width: 100%; border-collapse: collapse; }
  .pr-t th { text-align: left; background: #e9ecf2; padding: 4px 6px; }
  .pr-t td { border-bottom: 1px solid #ddd; padding: 3px 6px; }
  .pr-t td.n { text-align: right; font-family: "Courier New", monospace; }
  .pr-t tr.res td { font-weight: bold; }
  .pr-foot { margin-top: 18px; font-size: 9pt; color: #555; }
}

.pbody > .btn { margin-bottom: 12px; }

.out:not(.bad) b::after { content: ' ↗'; font-size: 12px; color: var(--mute); }

.frow { display: flex; gap: 6px; align-items: stretch; margin-bottom: 6px; }
.frow .fitem { margin-bottom: 0; flex: 1; min-width: 0; }
.star { width: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 22px; color: #c9a100; }
.btn.install { width: 100%; margin: 0 0 12px; }

.histbtn { margin-left: 8px; padding: 0 7px; height: 16px; line-height: 14px; border: 1px solid var(--lcdink); border-radius: 4px; background: transparent; color: var(--lcdink); font-size: 9.5px; font-weight: bold; cursor: pointer; }
.casio.off .lcd > * { visibility: hidden; }
.cols button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.hitem { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.hitem .he { font-family: "Courier New", monospace; font-size: 15px; word-break: break-all; }
.hitem .hr { font-family: "Courier New", monospace; font-size: 20px; font-weight: bold; color: var(--navy); text-align: right; margin: 4px 0 8px; }
.hitem .row-actions { margin: 0; }
