/* Le Mage du SEA — one design system for every screen.
   Tokens first; every rule below uses them. Nothing else sets a colour, a size, a gap or a radius. */

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

:root {
  /* Colour: neutrals, one accent, three status colours used only for a status (always with words). All text ≥ 4.5:1. */
  --bg: #f5f5f7;
  --surface: #fff;
  --fill: #ececf0;
  --line: #ebebef;
  --edge: #8f8e9a;
  --ink: #17161c;
  --ink-2: #63626d;
  --accent: #4b3cc4;
  --accent-soft: #efedfb;
  --ok: #17703f;
  --late: #b3261e;
  --warn: #8a5300;
  --ok-soft: #e6f4ec;
  --late-soft: #fcebe9;
  --warn-soft: #fbf0dc;
  --veil: rgb(23 22 28 / .4);

  /* Type: one family (optical sizes do the display work), six sizes, three weights. */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --t-xs: 12px;
  --t-sm: 14px;
  --t-md: 16px;
  --t-lg: 20px;
  --t-xl: 32px;
  --t-2xl: 48px;
  --w-regular: 400;
  --w-medium: 500;
  --w-bold: 600;

  /* Space: 4/8 scale. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* Shape and size. */
  --r-sm: 12px;
  --r-lg: 20px;
  --r-full: 999px;
  --tap: 48px;
  --tap-sm: 36px;
  --col: 640px;
  --side: 248px;
  --composer: 148px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); font: var(--w-regular) var(--t-md)/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility }
button, textarea, input { font: inherit; color: inherit }
button { cursor: pointer }
p, h1, h2 { margin: 0 }
[hidden] { display: none !important }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
svg { flex-shrink: 0 }

/* ——— Text roles ——— */
.label, .m, .sub { font-size: var(--t-sm); color: var(--ink-2) }
.label { font-weight: var(--w-medium) }
.figure { font-size: var(--t-2xl); font-weight: var(--w-bold); line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap }
.figure.md { font-size: var(--t-xl) }
.cts { font-size: .5em; font-weight: var(--w-medium); letter-spacing: -.01em; color: var(--ink-2) }
.late { color: var(--late) }
.warn { color: var(--warn) }
.ok { color: var(--ok) }

/* ——— Navigation ——— */
.nav { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2) var(--s3); padding: calc(var(--s2) + env(safe-area-inset-top)) var(--s4) var(--s2); background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px) }
.brand { display: flex; align-items: center; gap: var(--s2); min-width: 0; min-height: var(--tap-sm); font-weight: var(--w-bold); letter-spacing: -.01em; white-space: nowrap }
.brand span { overflow: hidden; text-overflow: ellipsis }
.brand svg { color: var(--accent) }
.demo { display: flex; align-items: center; gap: var(--s2) }
.tabs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); padding: var(--s1); border-radius: var(--r-full); background: var(--fill) }
.tabs button { height: 40px; border: 0; border-radius: var(--r-full); background: none; color: var(--ink-2); font-size: var(--t-sm); font-weight: var(--w-medium) }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(23 22 28 / .08) }

/* ——— Page ——— */
main { max-width: var(--col); margin: 0 auto; padding: var(--s2) var(--s4) var(--s7) }
main.chat { padding-bottom: calc(var(--composer) + env(safe-area-inset-bottom)) }
.hero { padding: var(--s5) var(--s1) var(--s2) }
.hero .figure { margin-top: var(--s1) }
.hero .sub { margin-top: var(--s2) }
.meter { height: 6px; margin-top: var(--s5); border-radius: var(--r-full); background: var(--fill); overflow: hidden }
.meter span { display: block; height: 100%; border-radius: var(--r-full); background: var(--accent) }
.sec { margin-top: var(--s5) }
.sec-h { padding: 0 var(--s1) var(--s2) }
.foot { display: flex; flex-direction: column; align-items: center; gap: var(--s3); margin-top: var(--s6); text-align: center }

/* ——— Card and row: the one list style ——— */
.card { border-radius: var(--r-lg); background: var(--surface); overflow: hidden }
.row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--s4); width: 100%; min-height: 56px; padding: var(--s3) var(--s4); border: 0; background: none; text-align: left }
.row + .row::before, .body > .row:first-child::before { content: ""; position: absolute; top: 0; left: var(--s4); right: var(--s4); height: 1px; background: var(--line) }
button.row:active { background: color-mix(in srgb, var(--fill) 40%, transparent) }
.l { display: flex; flex-direction: column; flex: 1; min-width: 0 }
.r { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; text-align: right }
.t, .a { font-weight: var(--w-medium) }
.t, .l .m { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.a { font-variant-numeric: tabular-nums; white-space: nowrap }
.row.dim .t, .row.dim .a { color: var(--ink-2) }
.grp { gap: var(--s3) }
.grp > svg { color: var(--ink-2); transition: transform .2s }
.grp[aria-expanded="true"] > svg { transform: rotate(180deg) }

/* ——— Tag ——— */
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s2); border-radius: var(--r-full); background: var(--fill); color: var(--ink-2); font-size: var(--t-xs); font-weight: var(--w-medium); white-space: nowrap }
.tag.ok { background: var(--ok-soft); color: var(--ok) }
.tag.late { background: var(--late-soft); color: var(--late) }
.tag.warn { background: var(--warn-soft); color: var(--warn) }

/* ——— Button: one style, two sizes, one emphasis ——— */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s5); border: 0; border-radius: var(--r-full); background: var(--fill); color: var(--ink); font-weight: var(--w-medium); white-space: nowrap; text-decoration: none; transition: filter .15s, transform .1s }
.btn:active { transform: scale(.98) }
.btn.primary { background: var(--accent); color: #fff }
.btn.light { background: var(--surface) }
.btn.sm { min-height: var(--tap-sm); padding: 0 var(--s4); font-size: var(--t-sm) }
.btn.block { width: 100% }
.btn.icon { width: var(--tap); padding: 0; flex-shrink: 0 }
.btn.icon.sm { width: var(--tap-sm) }
.btn:disabled { opacity: .5; cursor: default }

/* ——— Field: the one input style ——— */
.field { width: 100%; min-height: var(--tap); padding: 11px var(--s4); border: 1px solid var(--edge); border-radius: var(--s5); background: var(--surface); line-height: 1.5; outline: 0; resize: none; transition: border-color .15s, box-shadow .15s }
.field::placeholder { color: var(--ink-2) }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft) }

/* ——— Assistant ——— */
.feed { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s2) }
.day { margin-top: var(--s4); text-align: center; font-size: var(--t-sm); color: var(--ink-2) }
.msg.me { align-self: flex-end; max-width: 85%; padding: var(--s3) var(--s4); border-radius: var(--r-lg) var(--r-lg) var(--s1) var(--r-lg); background: var(--accent-soft); overflow-wrap: anywhere }
.msg.assistant { border-radius: var(--r-lg); background: var(--surface); overflow: hidden }
.text { padding: var(--s4); overflow-wrap: anywhere }
.text p + p, .text p + ul, .text ul + p { margin-top: var(--s3) }
.text ul { display: grid; gap: var(--s2); margin: 0; padding: 0; list-style: none }
.text li b { display: block; font-weight: var(--w-medium) }
.text li .m { display: block }
.text li.dot { position: relative; padding-left: var(--s4) }
.text li.dot::before { content: ""; position: absolute; left: 2px; top: 10px; width: 4px; height: 4px; border-radius: 50%; background: var(--ink-2) }
.text b { font-weight: var(--w-bold) }
.block, .block + .text { border-top: 1px solid var(--line) }
.body.text { padding-top: var(--s1) }
.sumup { padding: var(--s4) }
.sumup .figure { margin: var(--s1) 0 }
.stats { display: grid; grid-template-columns: 1fr 1fr }
.stats > div { padding: var(--s4); min-width: 0 }
.stats > div + div { border-left: 1px solid var(--line) }
.stats .v { font-size: var(--t-lg); font-weight: var(--w-bold); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap }
.go { padding: var(--s1) var(--s4) var(--s4) }
.block + .go { padding-top: var(--s4); border-top: 1px solid var(--line) }
.typing { display: flex; gap: 6px; align-self: flex-start; padding: var(--s5) var(--s4) }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); animation: blink 1.2s infinite }
.typing span:nth-child(2) { animation-delay: .2s }
.typing span:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: var(--s2) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px) }
.chips, .bar { max-width: calc(var(--col) - 2 * var(--s4)); margin: 0 auto }
.chips { display: flex; gap: var(--s2); padding: var(--s1) 0 var(--s3); overflow-x: auto; scrollbar-width: none }
.chips::-webkit-scrollbar { display: none }
.bar { display: flex; align-items: flex-end; gap: var(--s2) }
.bar .field { max-height: 132px }

/* ——— Detail sheet ——— */
dialog { width: min(480px, 100%); max-width: 100%; max-height: 90dvh; margin: auto; padding: 0; border: 0; border-radius: var(--s5); background: var(--surface); color: var(--ink) }
dialog::backdrop { background: var(--veil) }
dialog[open] { animation: rise .22s ease-out }
@keyframes rise { from { opacity: 0; transform: translateY(var(--s4)) } }
.sheet { padding: var(--s5) }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3) }
.sheet h2 { margin-top: var(--s4); font-size: var(--t-lg); font-weight: var(--w-bold); line-height: 1.3; letter-spacing: -.01em }
.sheet .figure { margin: var(--s5) 0 var(--s1) }
.lines { margin-top: var(--s5) }
.line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line) }
.line > :first-child { min-width: 0 }
.line .m { display: block }
.totals { padding-top: var(--s2); border-top: 1px solid var(--line) }
.totals .line { padding: var(--s1) 0; border: 0; font-size: var(--t-sm); color: var(--ink-2) }
.note { margin-top: var(--s3); font-size: var(--t-sm); color: var(--ink-2) }
.callout { margin-top: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: var(--t-sm) }
.acts { display: flex; gap: var(--s2); margin-top: var(--s5) }
.acts .btn { flex: 1 }

/* ——— Toast ——— */
.toast { position: fixed; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom)); z-index: 9; max-width: calc(100% - 2 * var(--s4)); padding: var(--s3) var(--s5); border-radius: var(--r-lg); background: var(--ink); color: #fff; font-size: var(--t-sm); transform: translateX(-50%) }

/* ——— Access code ——— */
.login { display: grid; place-items: center; padding: var(--s5) }
.login form { display: grid; gap: var(--s4); width: min(320px, 100%); text-align: center }
.login .brand { justify-content: center; margin-bottom: var(--s4) }
.login h1 { font-size: var(--t-xl); font-weight: var(--w-bold); line-height: 1.2; letter-spacing: -.03em }
.login .field { text-align: center }

/* ——— Phone: the sheet rises from the bottom ——— */
@media (max-width: 599px) {
  :root { --t-2xl: 44px }
  dialog { width: 100%; max-width: 100vw; margin: auto 0 0; border-radius: var(--s5) var(--s5) 0 0 }
  .sheet { padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom)) }
}
@media (max-width: 599px) { .demo .tag { display: none } }

/* ——— Desktop: the navigation becomes a side column ——— */
@media (min-width: 960px) {
  :root { --composer: 164px }
  body { padding-left: var(--side) }
  .nav { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; align-items: stretch; gap: var(--s5); width: var(--side); padding: var(--s5) var(--s4); background: none; -webkit-backdrop-filter: none; backdrop-filter: none; border-right: 1px solid var(--line) }
  .brand { padding: 0 var(--s3) }
  .tabs { order: 1; display: flex; flex-direction: column; gap: var(--s1); padding: 0; border-radius: 0; background: none }
  .tabs button { height: 44px; padding: 0 var(--s3); border-radius: var(--r-sm); font-size: var(--t-md); text-align: left }
  .tabs button.on { box-shadow: none }
  .demo { order: 2; flex-direction: column; align-items: flex-start; gap: var(--s3); margin-top: auto; padding: 0 var(--s3) }
  main { padding-top: var(--s5) }
  .hero { padding-top: var(--s6) }
  .composer { left: var(--side); padding-bottom: var(--s5) }
}

/* Hover only where there is a pointer: on a phone it would stick after a tap. */
@media (hover: hover) {
  button.row:hover { background: color-mix(in srgb, var(--fill) 40%, transparent) }
  .btn:hover { filter: brightness(.97) }
  .btn.primary:hover { filter: brightness(1.08) }
  .tabs button:not(.on):hover { color: var(--ink) }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important } }
