/* Ajouts propres à Nova en ligne (le reste vient de style.css, copié de la version locale). */

/* Bouton « Essayer » sur les blocs de code HTML */
.code-block summary .run-code { font-size: 11.5px; padding: 3px 10px; border-radius: 7px; background: var(--grad); color: #1a0d04; font-weight: 700; white-space: nowrap; box-shadow: 0 4px 14px rgba(255, 122, 26, .3); }
.code-block summary .run-code:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Fenêtre d'aperçu du code */
.run-sheet { width: min(1100px, 96vw); height: min(780px, 90vh); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.run-head { display: flex; align-items: center; gap: 10px; }
.run-head b { font-size: 15px; }
.run-note { flex: 1; font-size: 12.5px; color: var(--muted); }
#runFrame { flex: 1; width: 100%; border: 1px solid var(--line-2); border-radius: 14px; background: #fff; }

/* Image en cours de création */
.gen-image.wait { width: min(460px, 100%); }
.img-wait { aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; color: var(--soft); font-size: 13.5px;
  background: radial-gradient(circle at 50% 45%, rgba(255, 122, 26, .16), transparent 65%); }
.img-wait .nova-logo { width: 64px; height: 64px; }
.img-wait .btn { display: inline-flex; align-items: center; gap: 6px; }
.img-wait .btn svg { width: 15px; height: 15px; }

/* Message d'erreur : logo + bulle rouge */
.msg.ai.error .text { padding: 10px 14px; }
.msg-actions .retry svg { width: 16px; height: 16px; }

/* Réglages : « À savoir » */
.about-list { margin: 0; padding-left: 18px; color: var(--soft); font-size: 13.4px; line-height: 1.55; }
.about-list li { margin-bottom: 8px; }
.about-list b { color: var(--text); }

/* Le bouton envoyer disparaît pendant que Nova écrit (le bouton stop prend sa place). */
.c-btn.send.hidden { display: none !important; }

@media (max-width: 760px) {
  .run-note { display: none; }
  .hint-line { font-size: 11px; padding: 6px 8px 0; }
}

/* Bouton « Nouvelle image » sous une image */
.gen-image .cap .redo-img { display: inline-flex; align-items: center; gap: 5px; color: var(--soft); font-size: 12px; padding: 3px 8px; border-radius: 7px; background: rgba(255,255,255,.06); white-space: nowrap; }
.gen-image .cap .redo-img:hover { color: #fff; background: rgba(255,255,255,.12); }
.gen-image .cap .redo-img svg { width: 13px; height: 13px; }

/* ================================================================ téléphone */
html, body { -webkit-tap-highlight-color: transparent; }
.app { height: 100dvh; }
.menu-mem { display: none; }

/* Écrans tactiles : pas de survol, donc les petits boutons restent visibles. */
@media (hover: none) {
  .msg-actions { opacity: .85; transform: none; }
  .sb-acts, .mem-item button { opacity: 1; }
  .card-btn:hover, .icon-btn:hover, .send:hover { transform: none; }
}

/* Sur tablette et téléphone, la liste des conversations passe par-dessus : un voile sombre derrière. */
@media (max-width: 900px) {
  .sidebar { width: min(300px, 86vw); box-shadow: 20px 0 60px rgba(0, 0, 0, .55); background: linear-gradient(180deg, rgba(20, 14, 10, .97), rgba(12, 9, 6, .97)); }
  body:not(.sb-closed) .chat::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1; animation: fade .25s; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  /* Barre du haut sur une seule ligne */
  .topbar { grid-template-columns: auto 1fr auto; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .actions { grid-column: auto; justify-content: flex-end; gap: 6px; }
  .brand { gap: 8px; }
  .brand-text, #voiceBtn, #memoryBtn { display: none; }
  .menu-mem { display: block; }
  .brand .nova-logo { width: 32px; height: 32px; }
  .icon-btn { width: 38px; height: 38px; border-radius: 11px; }
  .center-group { justify-content: center; min-width: 0; }
  .mode-switch { height: 38px; padding: 3px; border-radius: 13px; }
  .mode-switch button { padding: 0 10px; font-size: 12.5px; border-radius: 10px; }

  /* Zone de discussion */
  .chat { padding: 4px 8px calc(8px + env(safe-area-inset-bottom)); }
  .scroll { padding: 6px 2px 16px; }
  .msg { gap: 9px; margin-bottom: 16px; }
  .msg > .nova-logo { width: 28px; height: 28px; }
  .body { max-width: 90%; }
  .msg.ai .body { max-width: calc(100% - 37px); }
  .msg.user .text { padding: 9px 14px; border-radius: 18px 18px 6px 18px; }
  .text { line-height: 1.55; }
  .text pre { font-size: 12px; }
  .code-block summary { gap: 7px; padding: 8px 9px; flex-wrap: wrap; }
  .code-block summary .first { display: none; }
  .gen-image, .gen-image.wait { width: 100%; max-width: 100%; }

  /* Accueil */
  .hero { padding-top: 1vh; }
  .hero-logo { width: 116px; height: 116px; }
  .hero-logo .nova-logo.big { width: 92px; height: 92px; }
  .hero h1 { font-size: 27px; line-height: 1.2; margin: 4px 0 8px; }
  .hero p { font-size: 14.5px; margin: 0 0 18px; padding: 0 6px; }
  .cards { gap: 8px; }
  .card-btn { padding: 12px 13px; }
  .card-btn small { font-size: 12.5px; }

  /* Zone de texte : 16 px minimum, sinon l'iPhone zoome tout seul quand on tape */
  .composer-wrap { padding: 2px 0 0; }
  .composer { gap: 2px; padding: 5px; border-radius: 20px; }
  .composer textarea { font-size: 16px; padding: 10px 4px; max-height: 140px; }
  .c-btn { width: 40px; height: 40px; border-radius: 13px; }
  .attach, .mic { width: 36px; }
  .hint-line { font-size: 10.5px; padding: 5px 6px 0; line-height: 1.4; }
  .to-bottom { right: 14px; bottom: 92px; width: 40px; height: 40px; }
  .toasts { bottom: 96px; width: 92vw; }
  .toast { font-size: 13.5px; }

  /* Panneaux (mémoire, réglages) en plein écran */
  .drawer-panel { inset: 0; width: 100%; border-radius: 0; border: 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); padding-top: max(16px, env(safe-area-inset-top)); }
  .drawer input:not([type=checkbox]):not([type=range]), .drawer select { font-size: 16px; }
  .erase-grid { grid-template-columns: 1fr; }

  /* Aperçu d'un jeu ou d'un site en plein écran */
  .modal { place-items: stretch; }
  .run-sheet { width: 100vw; height: 100dvh; max-width: none; border-radius: 0; border: 0; padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .run-head { gap: 6px; }
  .run-head .btn { padding: 0 10px; }
  #runFrame { border-radius: 10px; }
}

/* Très petits téléphones */
@media (max-width: 360px) {
  .brand .nova-logo { display: none; }
  .mode-switch button { padding: 0 8px; font-size: 12px; }
}

/* Le panneau des réglages est une colonne flexible : on empêche ses éléments d'être écrasés. */
.drawer-panel > * { flex-shrink: 0; }
.menu-mem.btn.wide { margin-top: 18px; }
/* Texte d'aide de la zone de texte sur une seule ligne, sans barre de défilement */
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .composer textarea { scrollbar-width: none; } .composer textarea::-webkit-scrollbar { display: none; } }

/* ================================================================ mode Nova Code : un look bien à lui (accent bleu) */
.mode-banner { display: none; }
body.mode-code .mode-banner {
  display: flex; align-items: center; gap: 8px; align-self: center; max-width: calc(100% - 12px);
  margin: 2px auto 6px; padding: 6px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap; overflow: hidden;
  background: linear-gradient(90deg, rgba(56, 189, 248, .16), rgba(255, 122, 26, .12)); border: 1px solid rgba(56, 189, 248, .35);
  box-shadow: 0 0 24px rgba(56, 189, 248, .15); animation: rise .45s var(--spring) both;
}
body.mode-code .mode-banner b { color: #7dd3fc; }
body.mode-code .mode-banner small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
body.mode-code .brand-text .name { background: linear-gradient(90deg, #ffc163, #ff7a1a 50%, #38bdf8); -webkit-background-clip: text; background-clip: text; color: transparent; }
body.mode-code .composer { border-color: rgba(56, 189, 248, .4); }
body.mode-code .composer:focus-within { box-shadow: 0 20px 60px rgba(0, 0, 0, .45), 0 0 44px rgba(56, 189, 248, .25); }
body.mode-code .send { background: linear-gradient(135deg, #ff7a1a, #38bdf8); background-size: 200% 200%; box-shadow: 0 6px 20px rgba(56, 189, 248, .35); }
body.mode-code .msg.user .text { background: linear-gradient(135deg, #ff8c2e 0%, #f97316 35%, #0ea5e9 130%); box-shadow: 0 10px 30px rgba(14, 165, 233, .22), inset 0 1px 0 rgba(255,255,255,.25); }
body.mode-code .b3 { background: #0369a1; }
body.mode-code .grid { opacity: .9; }
body.mode-code .new-conv { background: linear-gradient(135deg, #ff7a1a, #0ea5e9); }
body.mode-code .hero h1 .grad-text { background: linear-gradient(90deg, #ffc163, #ff7a1a 45%, #38bdf8); -webkit-background-clip: text; background-clip: text; }
@media (max-width: 640px) {
  body.mode-code .mode-banner { font-size: 12px; padding: 5px 12px; margin: 0 auto 4px; }
  body.mode-code .mode-banner small { font-size: 11px; }
}

/* Tableaux dans les réponses (défilent sur le côté sur téléphone) */
.text .table-wrap { overflow-x: auto; margin: 6px 0 10px; border: 1px solid var(--line-2); border-radius: 12px; }
.text table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.text th, .text td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.text th { background: rgba(255, 122, 26, .12); color: var(--text); font-weight: 600; white-space: nowrap; }
.text tr:last-child td { border-bottom: 0; }

/* ================================================================ menu « + » et options */
.composer-wrap { position: relative; }
.plus-menu {
  position: absolute; left: 6px; bottom: calc(100% + 8px); z-index: 12; width: min(330px, calc(100vw - 24px));
  padding: 6px; border-radius: 18px; background: rgba(24, 17, 12, .97); border: 1px solid var(--line-2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55); backdrop-filter: blur(20px); animation: rise .25s var(--spring) both;
}
.plus-menu button { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 12px; transition: background .15s; }
.plus-menu button:hover { background: rgba(255, 255, 255, .06); }
.plus-menu button.on { background: rgba(255, 122, 26, .16); box-shadow: inset 0 0 0 1px rgba(255, 160, 64, .35); }
.plus-menu button span { grid-row: 1 / 3; font-size: 20px; display: grid; place-items: center; }
.plus-menu button b { font-size: 14px; font-weight: 600; }
.plus-menu button small { color: var(--muted); font-size: 12px; }
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tool-chips:empty { display: none; }
.tool-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: #ffd8b0; background: rgba(255, 122, 26, .16); border: 1px solid rgba(255, 160, 64, .4); animation: popIn .3s var(--spring) both; }
.tool-chip span { opacity: .7; font-size: 15px; line-height: 1; }
.tool-chip:hover span { opacity: 1; }
body.opt-image .composer { border-color: rgba(255, 160, 64, .6); }
#plusBtn svg { transition: transform .25s var(--spring); }

/* Pièces jointes dans un message envoyé */
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line-2); color: var(--soft); font-size: 12.5px; max-width: 240px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip svg { width: 15px; height: 15px; flex: none; }
.msg.user .files img { max-width: 200px; max-height: 200px; object-fit: cover; }
.msg.user .body { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user:hover .msg-actions, .user-actions.keep { opacity: 1; transform: none; }
.user-actions { justify-content: flex-end; margin-top: 4px; }

/* Réflexion de Nova */
.reflexion { margin: 0 0 8px; border-left: 2px solid rgba(255, 160, 64, .4); padding-left: 10px; }
.reflexion summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; user-select: none; }
.reflexion summary::-webkit-details-marker { display: none; }
.reflexion[open] summary span { color: #ffd8b0; }
.reflexion-texte { white-space: pre-wrap; color: var(--muted); font-size: 12.8px; line-height: 1.5; margin-top: 6px; max-height: 260px; overflow-y: auto; }

/* Sources de la recherche internet */
.sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.sources .src-titre { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-right: 2px; }
.sources .src-titre svg { width: 14px; height: 14px; }
.sources a { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 4px 10px 4px 4px; border-radius: 999px; font-size: 12.5px; color: var(--soft); text-decoration: none; background: rgba(255, 255, 255, .05); border: 1px solid var(--line-2); transition: all .15s; }
.sources a:hover { color: #fff; border-color: rgba(255, 160, 64, .5); background: rgba(255, 122, 26, .1); }
.sources a b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; background: rgba(255, 122, 26, .25); color: #ffd8b0; flex: none; }
.sources a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Exécuter du code */
.code-block summary .exec-code { font-size: 11.5px; padding: 3px 10px; border-radius: 7px; background: linear-gradient(135deg, #22c55e, #0ea5e9); color: #04150c; font-weight: 700; white-space: nowrap; }
.code-block summary .exec-code:hover { filter: brightness(1.1); }
.run-output { margin: -2px 0 10px; border: 1px solid rgba(34, 197, 94, .35); border-radius: 0 0 12px 12px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.run-out-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.run-out-head b { color: #86efac; }
.run-out-head .run-info { flex: 1; }
.run-out-head button { font-size: 16px; color: var(--muted); padding: 0 4px; }
.run-output pre { margin: 0; padding: 10px 12px; max-height: 300px; overflow: auto; font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; color: #e5e7eb; }
.run-output pre .err { color: #fca5a5; }

/* Maths et code coloré */
.text .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.text .katex { font-size: 1.08em; }
.code-block pre code.hljs { background: transparent; padding: 0; }

/* Nova utilise le même fond noir et la même navigation que l’application Windows. */
:root { --bg: #000; }
.backdrop { background: #000; }
.topbar { background: rgba(0, 0, 0, .84); }
@media (min-width: 901px) {
  .app { padding-left: 64px; }
  .topbar { display: flex; justify-content: center; min-height: 60px; animation: none; z-index: 4; }
  .brand, .actions { position: fixed; left: 0; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
  .topbar { backdrop-filter: none; }
  .app::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 64px; background: #080808; border-right: 1px solid var(--line); }
  .brand { top: 12px; }
  .brand .nova-logo { order: -1; }
  .brand-text { display: none; }
  .actions { top: 110px; bottom: 12px; justify-content: flex-start; }
  #settingsBtn { margin-top: auto; }
  .chat:has(#welcome) { justify-content: center; }
  .chat:has(#welcome) .scroll { flex: 0 1 auto; padding-bottom: 16px; }
  .chat:has(#welcome) .hero { padding-top: 0; }
  .chat:has(#welcome) .hero-logo { width: 112px; height: 112px; }
  .chat:has(#welcome) .hero-logo .nova-logo { width: 100%; height: 100%; }
}

/* Surlignage : noir dans les bulles orange de l utilisateur, orange ailleurs */
::selection { background: #ff6a00; color: #000; }
.msg.user .text::selection, .msg.user .text *::selection { background: #000; color: #ff9a3c; }
