@font-face { font-family: "Bricolage"; src: url(fonts/bricolage.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url(fonts/schibsted.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }

/* Couleurs tirées de la maquette : graphite olive, ocre des bandes, rouge du nez. */
:root {
  --ground: #191d18;
  --ground-2: #283026;
  --surface: #20251f;
  --surface-2: #272d26;
  --raised: #2f362d;
  --line: #353d33;
  --line-2: #4a5447;
  --paper: #ecebe2;
  --muted: #a3a99b;
  --faint: #737b6e;
  --olive: #5d6b54;
  --ochre: #eaa02b;
  --ochre-ink: #231703;
  --red: #c4442f;
  --ok: #9cc183;
  --danger: #e77d67;
  --display: "Bricolage", "Schibsted", system-ui, sans-serif;
  --font: "Schibsted", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 7px;
  --r: 12px;
  --r-lg: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--ground); color: var(--paper); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.muted { color: var(--muted); margin: 0; }
.small-text { font-size: 13px; }
::selection { background: rgba(234, 160, 43, .35); }

input:not([type="range"]):not([type="color"]):not([type="file"]), textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--ground); border: 1px solid var(--line); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--olive); box-shadow: 0 0 0 3px rgba(93, 107, 84, .35); }
::placeholder { color: var(--faint); }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.logo { flex: none; width: 28px; height: 28px; stroke: none; fill: none; color: var(--paper); }
.brand strong, .hero-top strong { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; white-space: nowrap;
  padding: 10px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: none; color: var(--paper); font-weight: 600;
  transition: border-color .15s, background .15s, filter .15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ochre); border-color: var(--ochre); color: var(--ochre-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: rgba(231, 125, 103, .4); }
.btn.danger:hover { background: rgba(231, 125, 103, .1); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.big { padding: 13px 18px; font-size: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.link { border: 0; background: none; padding: 0; color: var(--ochre); font-size: 14px; font-weight: 600; }
.link:hover { text-decoration: underline; }
.danger-link { color: var(--danger); }
.ghost { border: 1px solid transparent; background: none; padding: 6px 10px; border-radius: 999px; color: var(--muted); font-size: 13px; }
.ghost:hover { color: var(--paper); border-color: var(--line-2); }
.ghost[aria-pressed="true"] { color: var(--ochre); border-color: var(--ochre); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { border-color: var(--line-2); color: var(--paper); }
.icon-btn[aria-pressed="true"] { color: var(--faint); }

.seg { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--ground); }
.seg button { flex: 1; border: 0; background: none; padding: 6px 12px; border-radius: 999px; white-space: nowrap; color: var(--muted); font-size: 14px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--paper); }
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ground); font-weight: 600; }

/* ============ accueil ============ */
.welcome { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 30vw); height: 100dvh; }
.hero { position: relative; overflow: hidden; background: radial-gradient(90% 75% at 50% 35%, var(--ground-2) 0%, var(--ground) 72%); }
#hero-view { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1s; }
#hero-view.ready { opacity: 1; }
.hero-top { position: absolute; top: 28px; left: clamp(20px, 4vw, 56px); }
.hero-top { display: flex; align-items: center; gap: 10px; font-family: var(--display); }
.hero-top .logo { width: 34px; height: 34px; }
.hero-top strong { font-size: 24px; }
.hero-copy { position: absolute; left: clamp(20px, 4vw, 56px); right: clamp(20px, 4vw, 56px); bottom: clamp(24px, 5vh, 56px); pointer-events: none; }
.hero h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(46px, 7.4vw, 118px); line-height: .9; letter-spacing: -.045em;
  font-variation-settings: "opsz" 96;
  text-shadow: 0 2px 30px rgba(25, 29, 24, .6);
}
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); gap: 28px; margin: clamp(22px, 4vh, 40px) 0 0; padding: 0; list-style: none; counter-reset: step; }
.how li { counter-increment: step; display: grid; gap: 3px; padding-top: 12px; border-top: 2px solid var(--line-2); font-size: 14px; color: var(--muted); }
.how li:first-child { border-color: var(--ochre); }
.how b { color: var(--paper); font-weight: 600; font-size: 15px; }
.how b::before { content: counter(step) "  "; color: var(--ochre); font-family: var(--display); font-weight: 800; }

.signin { display: flex; flex-direction: column; justify-content: center; gap: 24px; padding: 40px clamp(24px, 3.4vw, 52px); background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; }
.signin-form { display: grid; gap: 16px; }
.signin h2 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.signin .lede { margin: -8px 0 6px; color: var(--muted); }
.signin label { display: grid; gap: 7px; font-size: 14px; font-weight: 600; }
.signin input { padding: 12px 13px !important; font-size: 16px; }
.signin .btn { margin-top: 6px; }
.signin-foot { margin: 0; font-size: 13px; color: var(--faint); }
.form-error { margin: 0; padding: 9px 12px; border-radius: var(--r-sm); background: rgba(231, 125, 103, .1); color: var(--danger); font-size: 14px; }

/* ============ application ============ */
#app { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100dvh; }
#stage { position: relative; min-width: 0; background: radial-gradient(110% 85% at 50% 40%, var(--ground-2) 0%, var(--ground) 75%); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#view.hovering { cursor: pointer; }

.topbar { position: absolute; inset: 0 0 auto 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; pointer-events: none; z-index: 3; }
.topbar > * { pointer-events: auto; }
.top-actions { display: flex; gap: 8px; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 300px; height: 38px; padding: 0 14px; border-radius: 999px; background: rgba(25, 29, 24, .78); border: 1px solid var(--line); backdrop-filter: blur(10px); font-weight: 600; font-size: 14px; transition: border-color .15s; }
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill:hover { border-color: var(--line-2); }
.pill svg { color: var(--muted); flex: none; }
.pill.account { padding: 0 14px 0 4px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--olive); color: var(--paper); font-family: var(--display); font-weight: 800; font-size: 14px; }
.menu { position: absolute; top: 62px; right: 18px; width: min(340px, calc(100% - 32px)); max-height: 62dvh; overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }
.menu ul { list-style: none; margin: 4px 0 0; padding: 4px 0 0; border-top: 1px solid var(--line); }
.menu ul:empty { display: none; }
.menu-new { width: 100%; text-align: left; padding: 10px 11px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ochre); font-weight: 600; }
.menu-new:hover, .menu li button.open:hover { background: var(--surface-2); }
.menu li { display: flex; align-items: center; gap: 4px; }
.menu li button.open { flex: 1; min-width: 0; display: grid; text-align: left; padding: 8px 11px; border: 0; border-radius: var(--r-sm); background: none; }
.menu li button.open[aria-current="true"] { background: rgba(234, 160, 43, .1); box-shadow: inset 2px 0 0 var(--ochre); }
.menu li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu li .d { color: var(--muted); font-size: 13px; }
.menu li .icon-btn { opacity: 0; }
.menu li:hover .icon-btn, .menu li .icon-btn:focus-visible { opacity: 1; }

.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 90px 24px; }
.empty-drop {
  display: grid; justify-items: center; gap: 8px; width: min(440px, 100%); padding: 44px 28px; text-align: center;
  border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); color: var(--muted); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.empty-drop:hover { border-color: var(--ochre); background: rgba(234, 160, 43, .04); }
.empty-drop svg { width: 30px; height: 30px; color: var(--ochre); margin-bottom: 6px; }
.empty-drop strong { color: var(--paper); font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -.015em; }
.empty-drop span { max-width: 320px; }

.dropzone { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(25, 29, 24, .85); outline: 2px dashed var(--ochre); outline-offset: -14px; pointer-events: none; }
.dropzone span { padding: 14px 22px; border-radius: 999px; background: var(--ochre); color: var(--ochre-ink); font-weight: 700; font-size: 16px; }

.dock, .gizmo-bar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 8px 14px; background: rgba(25, 29, 24, .82); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(10px); font-size: 13px; color: var(--muted); z-index: 2; }
.gizmo-bar { padding: 4px 6px 4px 4px; }
.gizmo-bar .seg { border: 0; padding: 0; background: none; }
.dock input[type="range"] { width: clamp(110px, 24vw, 280px); accent-color: var(--ochre); }
.dock-sep { width: 1px; height: 18px; background: var(--line); }

.tooltip { position: absolute; z-index: 5; pointer-events: none; padding: 5px 10px; border-radius: var(--r-sm); background: rgba(16, 19, 15, .92); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; transform: translate(14px, 14px); }
.loader { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); font-size: 13px; pointer-events: none; transition: opacity .3s; }
.loader.done { opacity: 0; }
.loader.error { color: var(--danger); }
.loader-bar { width: 180px; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: var(--ochre); transition: width .15s; }

/* --- panneau --- */
#panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; margin: 14px 16px 0; padding: 3px; flex: none; border-radius: 999px; background: var(--ground); border: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; transition: background .15s, color .15s; }
.tabs button:hover { color: var(--paper); }
.tabs button[aria-selected="true"] { background: var(--raised); color: var(--paper); }
.count { margin-left: 4px; font-size: 12px; color: var(--faint); font-weight: 500; }
#panel section { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.banner { display: grid; gap: 2px; margin: 14px 16px 0; padding: 12px 14px; border-radius: var(--r); background: rgba(234, 160, 43, .08); border: 1px solid rgba(234, 160, 43, .3); font-size: 14px; }
.banner span { color: var(--muted); }
.banner .link { justify-self: start; margin-top: 6px; }

.messages { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 18px 16px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.msg { max-width: 90%; display: grid; gap: 6px; }
.msg.user { align-self: flex-end; justify-items: end; }
.msg .bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--olive); border-bottom-right-radius: 5px; }
.msg.astra { max-width: 100%; }
.msg.astra .bubble { padding: 0 2px; border-radius: 0; }
.msg.astra.error .bubble { padding: 10px 14px; border-radius: var(--r); background: rgba(231, 125, 103, .08); color: #f1b4a5; }
.msg.edit { align-self: center; padding: 4px 12px; border-radius: 999px; background: rgba(156, 193, 131, .1); font-size: 13px; color: var(--ok); }
.msg .imgs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg .imgs img { width: 110px; height: 110px; object-fit: cover; border-radius: var(--r); }
.msg .who { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.msg .who small { font-weight: 500; color: var(--faint); }
.msg .bubble b { font-weight: 700; color: var(--paper); }
.msg .bubble code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); font-size: .92em; }
.astra-mark { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--ochre) 0 34%, transparent 36%), var(--olive); }
.steps { font-size: 13px; color: var(--muted); }
.steps summary { cursor: pointer; color: var(--faint); width: fit-content; }
.steps summary:hover { color: var(--muted); }
.steps ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.steps li.ko { color: #d69a8d; }
.live { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.live strong { color: var(--paper); font-size: 14px; display: flex; align-items: center; gap: 9px; }
.live strong small { margin-left: auto; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.live ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.live li:last-child { color: var(--paper); }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ochre); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome-msg { color: var(--muted); font-size: 14px; padding: 2px; }
.welcome-msg b { color: var(--paper); }
.welcome-msg h3 { margin: 0 0 6px; font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: -.015em; color: var(--paper); }
.welcome-msg ol { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.welcome-msg li::marker { color: var(--ochre); font-weight: 700; }

.composer { flex: none; margin: 0 16px 16px; display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--ground); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--olive); box-shadow: 0 0 0 3px rgba(93, 107, 84, .3); }
.composer textarea { resize: none; max-height: 180px; min-height: 46px; padding: 6px 8px !important; line-height: 1.45; border: 0 !important; box-shadow: none !important; background: none !important; }
.composer-row { display: flex; align-items: center; gap: 8px; }
.hint { flex: 1; font-size: 12px; color: var(--faint); }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 4px 0; }
.attachments figure { position: relative; margin: 0; }
.attachments img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--r-sm); display: block; }
.attachments button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); }
.attachments button svg { width: 10px; height: 10px; }
.composer .btn.primary { border-radius: 999px; padding: 7px 16px; }

.parts-panel { padding: 16px; gap: 12px; overflow-y: auto; }
.parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.part { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 7px 6px 7px 11px; border-radius: var(--r-sm); transition: background .15s; }
.part.is-hover, .part:hover { background: var(--surface-2); }
.part.is-selected { background: rgba(234, 160, 43, .1); box-shadow: inset 2px 0 0 var(--ochre); }
.part.is-hidden .name { color: var(--faint); }
.part .swatch { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.part .main { all: unset; cursor: pointer; display: contents; }
.part .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part .meta { display: block; font-weight: 400; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.inspector { display: grid; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.inspector-head input { font-weight: 600; }
.inspector-row { display: flex; align-items: center; gap: 10px; }
.inspector-row label { color: var(--muted); font-size: 14px; }
.inspector-row .btn { margin-left: auto; }
input[type="color"] { width: 46px; height: 32px; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--ground); cursor: pointer; }
.pending { display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r); border: 1px solid rgba(234, 160, 43, .35); background: #2c2b1d; font-size: 14px; position: sticky; bottom: 0; }
.pending-actions { display: flex; gap: 8px; justify-content: flex-end; }
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 10px; }
.downloads .btn { font-size: 14px; padding: 9px 10px; }

/* --- export --- */
.export-panel { padding: 16px; gap: 22px; overflow-y: auto; }
.export-panel > .banner { margin: 0; }
.export-block { display: grid; gap: 10px; }
.export-block + .export-block { padding-top: 20px; border-top: 1px solid var(--line); }
.export-block h3 { margin: 0; font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.field-label { font-size: 14px; color: var(--muted); }
.size-row { display: flex; align-items: center; gap: 8px; }
.size-row .seg { flex: 1; min-width: 0; }
.size-row .seg button { padding: 6px 4px; font-variant-numeric: tabular-nums; }
.mm { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.mm input { width: 76px !important; padding: 7px 9px !important; text-align: right; font-variant-numeric: tabular-nums; }
.export-block > .btn.primary { justify-self: stretch; }
.formats { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.formats li { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 4px 7px 8px; border-radius: var(--r-sm); }
.formats li:hover { background: var(--surface-2); }
.fmt { font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: .01em; color: var(--ochre); }
.fmt-use { font-size: 14px; color: var(--muted); }
.note { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.note:empty { display: none; }
.note.error { color: var(--danger); }

/* --- paramètres --- */
.dialog { width: min(540px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0 20px 20px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); color: var(--paper); overflow-y: auto; }
.dialog::backdrop { background: rgba(10, 12, 10, .7); backdrop-filter: blur(3px); }
.dialog > .btn { width: 100%; margin-top: 14px; }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 18px 0 8px; background: var(--surface); }
.dialog-head h2 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.card { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.dialog-head + .card { border-top: 0; }
.card h3 { margin: 0; font-size: 16px; }
.card .muted { font-size: 14px; }
.card .banner { margin: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-width: 0; }
.stack-form { display: grid; gap: 8px; }
.stack-form .btn { justify-self: start; }
.key-status { margin: 0; font-size: 14px; font-weight: 600; }
.key-status.ok { color: var(--ok); }
.key-status.none { color: var(--ochre); }
.form-msg { margin: 0; font-size: 14px; color: var(--ok); }
.form-msg.error { color: var(--danger); }
.form-msg code { font-family: ui-monospace, Menlo, monospace; background: var(--ground); padding: 2px 7px; border-radius: 5px; user-select: all; color: var(--paper); }
.users { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.users li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 14px; }
.users .u { flex: 1; min-width: 0; font-weight: 600; }
.users .u small { display: block; color: var(--muted); font-weight: 400; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--ground); color: var(--muted); }
.tag.ok { color: var(--ok); }

/* --- mobile --- */
/* accueil empilé : téléphone, et tablette tenue à la verticale */
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  body:has(#login:not([hidden])) { overflow: auto; }
  .welcome { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; min-height: 100dvh; }
  .hero { min-height: max(520px, 64dvh); }
  .hero-top { top: max(20px, env(safe-area-inset-top)); }
  .hero h1 { font-size: clamp(44px, 12vw, 104px); }
  .how { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .signin { align-items: center; border-left: 0; border-top: 1px solid var(--line); padding: 32px 20px max(36px, env(safe-area-inset-bottom)); }
  .signin > * { width: min(440px, 100%); }
}
@media (max-width: 600px) {
  .hero { min-height: max(400px, 56dvh); }
  .how { grid-template-columns: 1fr; gap: 8px; }
  .how li { padding-top: 7px; }
  .how li span { display: none; } /* les titres suffisent sur petit écran */
}
/* téléphone couché : deux colonnes, sans les étapes */
@media (max-height: 560px) and (orientation: landscape) {
  body:has(#login:not([hidden])) { overflow: hidden; }
  .welcome { grid-template-columns: minmax(0, 1fr) minmax(300px, 44vw); grid-template-rows: none; height: 100dvh; min-height: 0; }
  .hero { min-height: 0; }
  .hero-top { top: max(14px, env(safe-area-inset-top)); left: max(20px, env(safe-area-inset-left)); }
  .hero-copy { bottom: 18px; left: max(20px, env(safe-area-inset-left)); }
  .hero h1 { font-size: clamp(30px, 10vh, 48px); }
  .how { display: none; }
  .signin { align-items: stretch; justify-content: flex-start; border-top: 0; border-left: 1px solid var(--line); padding: 18px max(22px, env(safe-area-inset-right)) 18px 22px; gap: 12px; overflow-y: auto; }
  .signin > * { width: auto; }
  .signin-form { gap: 10px; }
  .signin h2 { font-size: 22px; }
  .signin .lede { margin: -6px 0 2px; font-size: 14px; }
  .signin input { padding: 9px 11px !important; }
  .signin .btn { margin-top: 2px; padding: 10px 14px; }
}
@media (max-width: 860px), (max-width: 1100px) and (orientation: portrait) {
  body:has(#app:not([hidden])) { overflow: hidden; }
  #app { grid-template-columns: 1fr; grid-template-rows: 46dvh minmax(0, 1fr); }
  #panel { border-left: 0; border-top: 1px solid var(--line); }
  .topbar { padding: max(10px, env(safe-area-inset-top)) 12px 0; gap: 8px; }
  .topbar .brand strong, #account-name { display: none; }
  .pill.account { padding: 0 4px; }
  .pill { max-width: 58vw; }
  .menu { right: 12px; top: 54px; }
  .empty { padding: 64px 16px 16px; }
  .empty-drop { padding: 24px 18px; }
  .empty-drop strong { font-size: 18px; }
  .dock { bottom: 10px; width: calc(100% - 24px); gap: 8px; padding: 6px 8px 6px 14px; }
  .dock label, .dock-sep, #btn-rotate { display: none; }
  .dock input[type="range"] { flex: 1; width: auto; min-width: 0; }
  .gizmo-bar { bottom: 10px; }
  .gizmo-bar .seg button { padding: 8px 9px; }
  .menu li .icon-btn { opacity: 1; }
  .composer { margin-bottom: max(12px, env(safe-area-inset-bottom)); }
  .hint { visibility: hidden; }
}
@media (min-width: 700px) and (max-width: 1100px) and (orientation: portrait) {
  #app { grid-template-rows: 52dvh minmax(0, 1fr); }
  .topbar .brand strong, #account-name { display: inline; }
  .pill.account { padding: 0 14px 0 4px; }
  .dock label, .dock-sep, #btn-rotate { display: inline-flex; }
  .dock { width: auto; padding: 8px 14px; }
  .dock input[type="range"] { flex: none; width: 240px; }
  .hint { visibility: visible; }
}
/* petit téléphone : plus de place pour le chat */
@media (max-width: 860px) and (max-height: 720px) and (orientation: portrait) {
  #app { grid-template-rows: 40dvh minmax(0, 1fr); }
  .tabs { margin-top: 10px; }
  .banner { margin-top: 10px; padding: 9px 12px; }
  .banner span { display: none; }
  .banner .link { margin-top: 2px; }
  .messages { padding: 12px 16px; }
  .composer textarea { min-height: 38px; }
}
@media (min-width: 1800px) {
  #app { grid-template-columns: minmax(0, 1fr) min(500px, 26vw); }
}
/* téléphone couché : vue 3D à gauche, panneau à droite */
@media (max-height: 560px) and (orientation: landscape) {
  #app { grid-template-columns: minmax(0, 1fr) min(360px, 46vw); grid-template-rows: 100dvh; }
  #panel { border-top: 0; border-left: 1px solid var(--line); }
  .topbar { padding: max(8px, env(safe-area-inset-top)) 10px 0 max(10px, env(safe-area-inset-left)); }
  .pill { height: 34px; }
  .tabs { margin: 8px 10px 0; }
  .tabs button { padding: 5px 8px; }
  .banner { margin: 8px 10px 0; padding: 8px 10px; font-size: 13px; }
  .banner span { display: none; }
  .messages { padding: 10px; gap: 10px; }
  .composer { margin: 0 10px max(8px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 34px; }
  .parts-panel { padding: 10px; }
  .parts-panel > .muted { display: none; }
  .dock { bottom: 8px; padding: 4px 6px 4px 12px; }
  .empty { padding: 50px 12px 12px; }
  .empty-drop { padding: 16px; gap: 4px; }
  .empty-drop span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
