/* Nemo — feuille de style. Chaleureux, rond, un peu marin. */

@font-face {
  font-family: "Nunito";
  src: url("/fonts/nunito-var.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Clin d'œil Google, adouci à l'aquarelle */
  --g-blue: #5b8def;
  --g-red: #e8604c;
  --g-yellow: #eda93b;
  --g-green: #58a55c;

  --coral: #ff8a5c;
  --coral-deep: #f0704a;

  --bg: #fbf8f2;
  --bg-soft: #f3eee4;
  --panel: #ffffff;
  --ink: #2a2d3a;
  --ink-soft: #6b6f80;
  --line: #e7e1d4;
  --bubble-nemo: #ffffff;
  --bubble-user: #ffe8dc;
  --shadow: 0 2px 14px rgba(60, 50, 30, 0.08);
  --radius: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131722;
    --bg-soft: #1a1f2e;
    --panel: #1d2333;
    --ink: #eceef4;
    --ink-soft: #9aa0b4;
    --line: #2a3145;
    --bubble-nemo: #222941;
    --bubble-user: #47342e;
    --shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ============================ Sidebar ============================ */
#sidebar {
  width: 272px;
  flex: none;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
  transition: margin-left 0.25s ease;
}
#sidebar.hidden { margin-left: -272px; }

.side-head { display: flex; align-items: center; gap: 8px; }

.btn-new {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1.5px dashed var(--ink-soft);
  background: transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  color: var(--ink);
  transition: all 0.15s;
}
.btn-new:hover { border-color: var(--coral); color: var(--coral-deep); background: var(--panel); }

.side-label {
  margin: 8px 6px 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.conv-item {
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 9px 12px;
  text-align: left;
  gap: 8px;
  color: var(--ink);
}
.conv-item .t {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  font-size: 14.5px;
}
.conv-item:hover, .conv-item.active { background: var(--panel); box-shadow: var(--shadow); }
.conv-item .del {
  border: 0; background: none; color: var(--ink-soft);
  border-radius: 8px; padding: 2px 6px; visibility: hidden; font-size: 15px;
}
.conv-item:hover .del { visibility: visible; }
.conv-item .del:hover { color: var(--g-red); }
.conv-empty { color: var(--ink-soft); font-size: 13.5px; padding: 10px 12px; font-style: italic; }

.side-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.side-note { font-size: 12px; color: var(--ink-soft); margin: 8px 6px 0; line-height: 1.5; }

.link-btn {
  border: 0; background: none; color: var(--g-blue);
  font-weight: 700; padding: 4px 6px; border-radius: 8px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.inline { padding: 0 2px; font-size: inherit; }

.icon-btn {
  border: 0; background: transparent; color: var(--ink-soft);
  border-radius: 12px; padding: 8px; display: inline-flex;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }

.side-veil { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40; }

/* ============================ Main ============================ */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100dvh; }

.top-bar { display: flex; align-items: center; padding: 10px 14px; gap: 10px; }
.top-spacer { flex: 1; }
.top-logo { font-size: 22px; font-weight: 800; }

/* Wordmark — quatre lettres, quatre couleurs (bonjour Google) */
.lg-n { color: var(--g-blue); }
.lg-e { color: var(--g-red); }
.lg-m { color: var(--g-yellow); }
.lg-o { color: var(--g-green); }

/* ---------------- Accueil ---------------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 24px 40px;
  gap: 26px;
  overflow-y: auto;
}
.hero { text-align: center; }

.logo { font-size: clamp(64px, 12vw, 96px); font-weight: 800; margin: 6px 0 0; line-height: 1; letter-spacing: -0.02em; }
.logo .lg { display: inline-block; animation: float-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) backwards; }
.logo .lg-e { animation-delay: 0.08s; }
.logo .lg-m { animation-delay: 0.16s; }
.logo .lg-o { animation-delay: 0.24s; }
@keyframes float-in {
  from { opacity: 0; transform: translateY(18px) rotate(-6deg); }
}

.tagline { color: var(--ink-soft); font-size: clamp(15px, 2.4vw, 18px); margin: 12px 0 0; font-weight: 600; }

/* Le poisson */
.fish-wrap { position: relative; width: 110px; margin: 0 auto; }
.fish { width: 110px; animation: swim 5s ease-in-out infinite; }
@keyframes swim {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-9px) rotate(4deg); }
}
.bubble {
  position: absolute; border: 1.5px solid var(--ink-soft); border-radius: 50%;
  opacity: 0; animation: rise 4s linear infinite;
}
.b1 { width: 7px; height: 7px; left: 88%; top: 30%; animation-delay: 0s; }
.b2 { width: 5px; height: 5px; left: 96%; top: 40%; animation-delay: 1.3s; }
.b3 { width: 9px; height: 9px; left: 92%; top: 36%; animation-delay: 2.6s; }
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 0.7; }
  80% { opacity: 0.3; }
  100% { transform: translateY(-46px); opacity: 0; }
}

/* ---------------- Barre de question (la barre de recherche, presque) ---------------- */
.ask {
  display: flex;
  align-items: center;
  width: min(660px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 10px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.ask:focus-within { border-color: var(--coral); box-shadow: 0 4px 22px rgba(240, 112, 74, 0.18); }
.ask.draw-armed { border-color: var(--g-yellow); box-shadow: 0 4px 22px rgba(237, 169, 59, 0.22); }

/* le crayon */
.mode-draw {
  border: 0; background: transparent; color: var(--ink-soft);
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; transition: all 0.15s;
}
.mode-draw:hover { background: var(--bg-soft); color: var(--ink); }
.mode-draw[aria-pressed="true"] {
  background: var(--g-yellow); color: #fff;
  transform: rotate(-12deg);
}

/* aperçu de l'image à envoyer */
.attach-preview {
  position: relative; flex: none; width: 40px; height: 40px; margin-left: 2px;
}
.attach-preview img {
  width: 40px; height: 40px; object-fit: cover;
  border-radius: 12px; border: 2px solid var(--g-blue); display: block;
}
.attach-preview .rm {
  position: absolute; top: -7px; right: -7px;
  width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: var(--ink); color: var(--bg); font-size: 13px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.attach-preview .rm:hover { background: var(--g-red); color: #fff; }

@media (max-width: 480px) {
  .mode-draw { width: 36px; height: 36px; }
}
.ask input {
  flex: 1; border: 0; outline: 0; background: none;
  font: inherit; font-size: 16.5px; color: var(--ink); padding: 10px 8px; min-width: 0;
}
.ask input::placeholder { color: var(--ink-soft); }
.send {
  border: 0; background: var(--coral); color: #fff;
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center; transition: transform 0.12s, background 0.15s;
}
.send:hover { background: var(--coral-deep); transform: scale(1.06) rotate(8deg); }
.send:disabled { opacity: 0.45; transform: none; cursor: default; }

/* ---------------- Suggestions ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 720px; }
.chip {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 9px 17px; font-size: 14.5px; font-weight: 600;
  color: var(--ink); box-shadow: var(--shadow);
  animation: float-in 0.6s cubic-bezier(0.2, 1.2, 0.4, 1) backwards;
  transition: transform 0.12s, border-color 0.15s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--g-yellow); }

.home-foot { color: var(--ink-soft); font-size: 13.5px; text-align: center; margin: 0; }

/* ---------------- Pensée du jour ---------------- */
.pensee {
  margin: 0;
  max-width: 540px;
  text-align: center;
  animation: pensee-in 0.9s ease 0.4s backwards;
}
@keyframes pensee-in { from { opacity: 0; transform: translateY(10px); } }
.pensee blockquote {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.6;
  font-style: italic;
  color: var(--ink);
}
.pensee blockquote::before { content: "« "; color: var(--g-yellow); font-weight: 800; }
.pensee blockquote::after { content: " »"; color: var(--g-yellow); font-weight: 800; }
.pensee figcaption {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pensee-say {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft);
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  transition: color 0.15s, transform 0.15s;
}
.pensee-say:hover { color: var(--coral-deep); transform: scale(1.1); }
.pensee-say.playing, .pensee-say.loading { color: var(--coral-deep); animation: say-pulse 1.1s ease-in-out infinite; }

/* ---------------- Chat ---------------- */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; align-items: center; padding: 0 16px; }
.log {
  flex: 1; overflow-y: auto; width: min(760px, 100%);
  display: flex; flex-direction: column; gap: 16px; padding: 12px 4px 24px;
}
.msg { display: flex; gap: 12px; animation: msg-in 0.3s ease backwards; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }

.msg .avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.msg.user { flex-direction: row-reverse; }
.msg .body {
  max-width: 78%; padding: 12px 17px; border-radius: var(--radius);
  background: var(--bubble-nemo); box-shadow: var(--shadow);
  font-size: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: break-word;
}
.msg.nemo .body { border-top-left-radius: 6px; }
.msg.user .body { background: var(--bubble-user); border-top-right-radius: 6px; }
.msg .body.error { color: var(--g-red); font-style: italic; }

/* dessins */
.msg .body.has-img { padding: 10px; max-width: min(78%, 440px); }
.drawing {
  display: block; width: 100%; border-radius: 16px;
  transform: rotate(-0.6deg);
}
.body.has-img .caption {
  margin: 10px 6px 4px; font-size: 15px; line-height: 1.5;
}
.body .caption { margin: 0; white-space: pre-wrap; }

/* bouton écouter */
.msg .say {
  align-self: flex-end;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft);
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  opacity: 0; transition: opacity 0.15s, color 0.15s, transform 0.15s;
}
.msg:hover .say, .msg .say.playing, .msg .say.loading { opacity: 1; }
.msg .say:hover { color: var(--coral-deep); transform: scale(1.1); }
.msg .say.playing { color: var(--coral-deep); animation: say-pulse 1.1s ease-in-out infinite; opacity: 1; }
.msg .say.loading { animation: say-pulse 0.6s ease-in-out infinite; }
@keyframes say-pulse { 50% { transform: scale(1.18); } }

/* bascule voix (barre du haut) */
#btn-voice.on { color: var(--coral-deep); background: var(--bubble-user); }
#btn-voice:not(.on) .waves { opacity: 0.25; }

/* indicateur dessin */
.thinking-label { margin-left: 10px; color: var(--ink-soft); font-size: 14px; font-style: italic; }
.thinking.draw i { background: var(--g-yellow); }
.thinking.draw i:nth-child(2) { background: var(--g-red); }
.thinking.draw i:nth-child(3) { background: var(--g-green); }

.chip-draw { border-style: dashed; border-color: var(--g-yellow); }

/* Nemo réfléchit (enfin, ressent) */
.thinking { display: inline-flex; gap: 5px; align-items: center; padding: 4px 0; }
.thinking i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--coral);
  animation: blub 1.2s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.18s; background: var(--g-yellow); }
.thinking i:nth-child(3) { animation-delay: 0.36s; background: var(--g-blue); }
@keyframes blub { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-6px); opacity: 1; } }

.ask-chat { margin-bottom: 6px; }
.chat-foot { color: var(--ink-soft); font-size: 12px; margin: 8px 0 12px; text-align: center; }

/* bouton aimant sur les dessins */
.msg .pin {
  align-self: flex-end;
  border: 1px solid var(--line); background: var(--panel);
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 14px; padding: 0;
  opacity: 0; transition: opacity 0.15s, transform 0.15s, border-color 0.15s;
  filter: grayscale(1);
}
.msg:hover .pin, .msg .pin.pinned { opacity: 1; }
.msg .pin:hover { transform: scale(1.12) rotate(-10deg); }
.msg .pin.pinned {
  filter: none; border-color: var(--coral);
  background: var(--bubble-user); transform: rotate(-10deg);
}
@media (hover: none) { .msg .pin { opacity: 1; } }

/* ---------------- Le frigo ---------------- */
.frigo { flex: 1; overflow-y: auto; padding: 10px 18px 30px; display: flex; justify-content: center; }
.frigo-door {
  position: relative;
  width: min(880px, 100%);
  align-self: flex-start;
  background: linear-gradient(175deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 34px 34px 40px;
  box-shadow: var(--shadow);
}
.frigo-handle {
  position: absolute; top: 30px; right: 22px;
  width: 9px; height: 84px; border-radius: 6px;
  background: var(--line);
}
.frigo-door h2 { margin: 0; font-size: 26px; }
.frigo-sub { color: var(--ink-soft); margin: 6px 0 24px; font-size: 14px; }
.frigo-empty { color: var(--ink-soft); font-style: italic; grid-column: 1 / -1; }

.frigo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 26px 20px;
}
.frigo-item {
  position: relative; margin: 0;
  background: var(--panel);
  padding: 9px 9px 10px;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(50, 40, 20, 0.16);
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.18s;
}
.frigo-item:hover { transform: rotate(0deg) scale(1.03); z-index: 2; }
.frigo-item img { width: 100%; display: block; border-radius: 3px; }
.frigo-item .magnet {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 17px; height: 17px; border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.25);
  z-index: 1;
}
.frigo-item figcaption { padding: 7px 3px 0; display: flex; flex-direction: column; gap: 2px; }
.frigo-item .cap-text {
  font-size: 12.5px; font-style: italic; line-height: 1.45; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.frigo-item .cap-date { font-size: 11px; color: var(--ink-soft); }
.frigo-item .unpin {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--ink); color: var(--bg); font-size: 14px; line-height: 1; padding: 0;
  display: grid; place-items: center;
  opacity: 0; transition: opacity 0.15s;
}
.frigo-item:hover .unpin { opacity: 1; }
.frigo-item .unpin:hover { background: var(--g-red); color: #fff; }
@media (hover: none) { .frigo-item .unpin { opacity: 1; } }

/* ---------------- À propos ---------------- */
.about {
  border: 0; border-radius: 26px; background: var(--panel); color: var(--ink);
  width: min(560px, calc(100vw - 32px));
  max-height: min(82dvh, 720px);
  padding: 0; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}
.about::backdrop { background: rgba(20, 18, 14, 0.55); backdrop-filter: blur(3px); }
.about article { padding: 30px 32px; overflow-y: auto; max-height: inherit; }
.about-fish { font-size: 40px; text-align: center; animation: swim 5s ease-in-out infinite; }
.about h2 { margin: 8px 0 14px; text-align: center; font-size: 26px; }
.about h3 { margin: 20px 0 6px; font-size: 16px; }
.about p { line-height: 1.65; font-size: 15px; margin: 0 0 12px; }
.about .about-meta { color: var(--ink-soft); font-size: 13.5px; }
.about form { text-align: center; margin-top: 18px; }
.btn-primary {
  border: 0; background: var(--coral); color: #fff; font-weight: 800;
  border-radius: 999px; padding: 12px 26px; font-size: 15px;
  transition: background 0.15s, transform 0.12s;
}
.btn-primary:hover { background: var(--coral-deep); transform: scale(1.03); }

/* ---------------- Responsive ---------------- */
.side-only { display: none; }
@media (max-width: 780px) {
  #sidebar {
    position: fixed; z-index: 50; height: 100dvh; margin-left: 0 !important;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.25);
  }
  #sidebar.open { transform: translateX(0); }
  .side-only { display: inline-flex; }
  .msg .body { max-width: 88%; }
  .msg .avatar { display: none; }
}

@media (hover: none) {
  .msg .say { opacity: 1; }
}

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