/* Keres : thème sombre et néon, inspiré de Kères (mythologie grecque). */
:root {
  --bg: #07060d;
  --bg-2: #0f0c1a;
  --surface: rgba(255, 255, 255, 0.04);
  --line: rgba(190, 150, 255, 0.14);
  --text: #f1edff;
  --muted: #8d84a8;
  --violet: #b56cff;
  --magenta: #ff3dbb;
  --cyan: #3ef0ff;
  --danger: #ff4d6d;
  --glow: 0 0 18px rgba(181, 108, 255, 0.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { min-height: 100vh; overflow-x: hidden; }

/* Halo lumineux de fond */
.aura {
  position: fixed; inset: -20% -20% auto -20%; height: 70vh; pointer-events: none; z-index: 0;
  background:
    radial-gradient(closest-side, rgba(181, 108, 255, 0.28), transparent 70%) 20% 30% / 60% 60% no-repeat,
    radial-gradient(closest-side, rgba(255, 61, 187, 0.18), transparent 70%) 80% 10% / 50% 50% no-repeat,
    radial-gradient(closest-side, rgba(62, 240, 255, 0.12), transparent 70%) 50% 80% / 60% 60% no-repeat;
  filter: blur(10px);
}

.screen { position: relative; z-index: 1; min-height: 100vh; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.screen[hidden], .view[hidden] { display: none !important; }

.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Marque */
.brand { text-align: center; margin: 28px 0 32px; }
.brand h1 {
  margin: 8px 0 6px; font-size: 30px; letter-spacing: 0.32em; text-transform: uppercase;
  text-shadow: var(--glow); font-weight: 300;
}
.sigil {
  display: inline-block; font-size: 28px; color: var(--magenta);
  text-shadow: 0 0 14px rgba(255, 61, 187, 0.8);
  animation: pulse 3.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

/* Points du PIN */
.dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0 10px; }
.dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--violet); transition: all 0.2s ease;
}
.dots span.on {
  background: var(--violet); box-shadow: var(--glow);
}
.dots.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.msg { min-height: 20px; text-align: center; color: var(--danger); font-size: 14px; margin: 6px 0 14px; }

/* Pavé numérique */
.pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  max-width: 300px; margin: 0 auto;
}
.pad button {
  aspect-ratio: 1.25; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 24px; font-weight: 300; cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.pad button:active { transform: scale(0.94); border-color: var(--cyan); box-shadow: 0 0 14px rgba(62, 240, 255, 0.35); }
.pad button[data-key="del"] { color: var(--muted); }

/* Espace principal */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 2px 18px;
}
.brand-mini { font-size: 16px; letter-spacing: 0.25em; text-transform: uppercase; text-shadow: var(--glow); }
.brand-mini .sigil { font-size: 16px; animation: none; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.view h2 { margin: 6px 0 8px; font-size: 24px; font-weight: 400; }
.view { animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  margin-top: 18px; padding: 18px; border-radius: 20px;
  background: linear-gradient(160deg, rgba(181, 108, 255, 0.12), rgba(255, 61, 187, 0.04));
  border: 1px solid var(--line); box-shadow: var(--glow);
}
.card.goal { display: grid; gap: 8px; }
.card.goal > span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; }
.card.goal > strong { font-size: 28px; font-weight: 500; }
.bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--violet), var(--magenta), var(--cyan));
  box-shadow: 0 0 12px rgba(255, 61, 187, 0.6);
}

/* Barre de navigation basse */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 8px;
  border-radius: 22px; background: rgba(15, 12, 26, 0.85); backdrop-filter: blur(14px);
  border: 1px solid var(--line); z-index: 2;
}
.tabbar button {
  background: none; border: 0; color: var(--muted); font-size: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; cursor: pointer;
}
.tabbar button span { font-size: 11px; letter-spacing: 0.04em; }
.tabbar button.active { color: var(--cyan); text-shadow: 0 0 10px rgba(62, 240, 255, 0.7); }

#home { padding-bottom: 120px; }

/* Revenus */
.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 6px 0 12px; }
.head-row h2 { margin: 0; }
.small { font-size: 12px; }
.center { text-align: center; margin: 18px 0 0; }

.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-bottom: 4px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: none; color: var(--muted); padding: 9px 0; border-radius: 10px;
  font-size: 14px; cursor: pointer; transition: all 0.2s ease;
}
.seg button.on {
  color: var(--text); background: linear-gradient(135deg, rgba(181, 108, 255, 0.35), rgba(255, 61, 187, 0.25));
  box-shadow: var(--glow);
}

.card-title { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); margin-bottom: 10px; }
.card-title .muted { text-transform: none; letter-spacing: 0; margin-left: 6px; }
.card.goal .big { font-size: 40px; font-weight: 500; display: block; margin: 4px 0 12px; color: var(--text); letter-spacing: -0.01em; }
.goal-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 10px;
  font-size: 13px; color: var(--muted); text-transform: none; letter-spacing: 0;
}
.goal-line .amt { color: var(--text); }
.card.warn { border-color: rgba(255, 77, 109, 0.4); box-shadow: 0 0 18px rgba(255, 77, 109, 0.2); }
.bar.thin { height: 6px; flex: 1; margin: 0; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.kpi {
  padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  display: grid; gap: 4px;
}
.kpi > span { font-size: 12px; color: var(--muted); }
.kpi > strong { font-size: 22px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
.kpi em { font-style: normal; font-size: 11px; color: var(--cyan); }

.weekdays, .calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekdays span { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 4px; }
.cell {
  min-height: 46px; border-radius: 10px; padding: 4px 3px; font-size: 11px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
}
.cell b { font-weight: 500; color: var(--muted); }
.cell i { font-style: normal; font-size: 10px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.empty { border: 0; background: none; }
.cell.future { opacity: 0.35; }
.cell.l1 { background: rgba(181, 108, 255, 0.12); }
.cell.l2 { background: rgba(181, 108, 255, 0.25); }
.cell.l3 { background: rgba(255, 61, 187, 0.35); box-shadow: 0 0 10px rgba(255, 61, 187, 0.3); }
.cell.l4 { background: rgba(62, 240, 255, 0.35); box-shadow: 0 0 12px rgba(62, 240, 255, 0.4); }

.row-bar { display: grid; grid-template-columns: 70px 1fr 80px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.row-bar span { color: var(--muted); }
.row-bar b { font-weight: 500; text-align: right; }

.card.calendar-card { padding: 14px; }

/* Conversations */
.searchbar input {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 15px; outline: none;
}
.searchbar input:focus { border-color: var(--violet); box-shadow: var(--glow); }
.small-seg { margin: 10px 0 14px; max-width: 220px; }
.small-seg button { padding: 7px 0; font-size: 13px; }

.chat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chat-grid .wide { grid-column: 1 / -1; }
.chat-card {
  text-align: left; color: var(--text); cursor: pointer; border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(181, 108, 255, 0.10), rgba(255, 255, 255, 0.02));
  border-radius: 18px; padding: 12px; display: grid; gap: 8px; min-width: 0;
  transition: transform 0.1s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.chat-card:active { transform: scale(0.97); border-color: var(--cyan); box-shadow: 0 0 14px rgba(62, 240, 255, 0.3); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--violet), var(--magenta)); font-weight: 600; box-shadow: var(--glow);
}
.who { display: grid; gap: 2px; min-width: 0; }
.who b, .sheet-title b { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small, .sheet-title small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-style: normal; font-size: 10px; padding: 2px 7px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.ai-on { color: var(--cyan); border-color: rgba(62, 240, 255, 0.5); box-shadow: 0 0 8px rgba(62, 240, 255, 0.25); }
.chip.ai-off { color: var(--danger); border-color: rgba(255, 77, 109, 0.4); }
.meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text); }
.meta span:last-child { color: var(--muted); }
.snippet { margin: 0; font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Conversation plein écran */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: grid; grid-template-rows: auto 1fr auto; padding-top: env(safe-area-inset-top);
}
.sheet[hidden] { display: none !important; }
body.sheet-open .tabbar { display: none; }
body.sheet-open #home { padding-bottom: 0; }
.sheet-top {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: rgba(15, 12, 26, 0.9); backdrop-filter: blur(12px);
}
.sheet-title { display: grid; min-width: 0; }
.ghost {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.thread { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.bubble.fan { align-self: flex-start; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, rgba(181, 108, 255, 0.35), rgba(255, 61, 187, 0.25)); border: 1px solid rgba(255, 61, 187, 0.35); border-bottom-right-radius: 4px; }
.bubble .fr { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(241, 237, 255, 0.2); color: var(--cyan); font-style: italic; font-size: 13px; }
.bmeta { margin-top: 4px; font-size: 10px; color: var(--muted); display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.ai-tag { color: var(--cyan); border: 1px solid rgba(62, 240, 255, 0.4); border-radius: 6px; padding: 0 4px; font-size: 9px; }

.composer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(15, 12, 26, 0.95); }
.composer textarea, .preview textarea {
  width: 100%; resize: none; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 10px 12px; font: inherit; font-size: 15px; outline: none;
}
.composer textarea:focus, .preview textarea:focus { border-color: var(--violet); box-shadow: var(--glow); }
.row-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.primary, .send {
  border: 0; border-radius: 14px; padding: 10px 16px; font-size: 14px; color: #0b0812; cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), var(--violet)); box-shadow: 0 0 16px rgba(62, 240, 255, 0.35); font-weight: 600;
}
.send:disabled { opacity: 0.5; }
.preview { display: grid; gap: 6px; }
.preview-label { font-size: 12px; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; margin: 6px 0; }

/* À valider (propositions des agents) */
.agent-status { display: grid; gap: 8px; margin-top: 0; }
.agent-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.pill { font-size: 10px; padding: 2px 8px; border-radius: 99px; margin-left: 6px; letter-spacing: 0.04em; text-transform: uppercase; }
.pill.ok { color: var(--cyan); border: 1px solid rgba(62, 240, 255, 0.5); box-shadow: 0 0 8px rgba(62, 240, 255, 0.25); }
.pill.off { color: var(--danger); border: 1px solid rgba(255, 77, 109, 0.4); }
.warn-line { color: #ffb86b; font-size: 13px; margin: 0; }
.wide-seg { margin: 16px 0 6px; max-width: none; }
.prop-list { display: grid; gap: 12px; margin-top: 10px; }
.prop {
  border-radius: 18px; padding: 14px; border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(181, 108, 255, 0.10), rgba(255, 255, 255, 0.02));
}
.prop h3 { margin: 8px 0 6px; font-size: 16px; font-weight: 500; }
.prop p { margin: 6px 0; font-size: 14px; line-height: 1.45; }
.prop header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.prop blockquote {
  margin: 8px 0; padding: 6px 10px; border-left: 2px solid var(--magenta); color: var(--muted); font-style: italic; font-size: 13px;
}
.prop .label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; }
.prop .who-line { font-size: 13px; color: var(--text); }
.prop .conf { display: grid; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.type-badge { font-size: 11px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.06em; }
.type-badge.alert { color: var(--danger); border-color: rgba(255, 77, 109, 0.5); }
.type-badge.tag { color: var(--magenta); border-color: rgba(255, 61, 187, 0.5); }
.type-badge.insight { color: var(--cyan); border-color: rgba(62, 240, 255, 0.5); }
.status-line { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* Montant en USD avec équivalent en euro au survol (ordinateur) ou au toucher (téléphone) */
.amt {
  position: relative; cursor: help; white-space: nowrap;
  border-bottom: 1px dotted rgba(141, 132, 168, 0.6);
  outline: none;
}
.amt::after {
  content: attr(data-eur);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 6px 10px; border-radius: 10px; white-space: nowrap; z-index: 5;
  background: rgba(15, 12, 26, 0.96); border: 1px solid var(--cyan);
  box-shadow: 0 0 14px rgba(62, 240, 255, 0.35); color: var(--cyan);
  font-size: 12px; font-weight: 500; pointer-events: none;
  opacity: 0; transition: opacity 0.15s ease;
}
.amt:hover::after, .amt:focus::after, .amt.open::after { opacity: 1; }
.kpi .amt, .card.goal .amt { font-variant-numeric: tabular-nums; }

/* Studio (phase 6) */
#studio, #research, #scripts { display: grid; gap: 14px; }
#studio input, #studio textarea, #studio select,
#research input, #research textarea, #research select {
  width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
}
#studio .card input, #studio .card textarea, #studio .card select,
#research .card input, #research .card textarea, #research .card select { display: block; }
#research .card textarea { resize: vertical; min-height: 64px; }
#research .row-btns { align-items: stretch; }
#research .row-btns select { flex: 1; width: auto; margin: 0; }
#research .row-btns button { white-space: nowrap; }
#studio audio { width: 100%; margin: 6px 0; }
.studio-item { display: grid; gap: 8px; }
.studio-img { width: 100%; border-radius: 14px; border: 1px solid var(--line); }
.wide-btn { width: 100%; text-align: left; margin: 4px 0; }

/* Composeur vocal (dans la conversation) */
.voice-box { display: grid; gap: 10px; }
.voice-group { display: grid; gap: 4px; }
.voice-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-btn { padding: 6px 10px; font-size: 13px; }
#voice-text { width: 100%; box-sizing: border-box; border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
#voice-result audio { width: 100%; margin: 6px 0; }

/* Composeur vocal compact (v2) */
#draft-zone:has(.voice-box) { max-height: 62vh; }
.voice-box { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; padding-right: 2px; }
.voice-result { position: sticky; top: 0; z-index: 1; display: grid; gap: 6px; padding: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.voice-result audio { width: 100%; }
#voice-text { width: 100%; box-sizing: border-box; border-radius: 12px; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.cat-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-btn { padding: 5px 10px; font-size: 12px; }
.cat-btn.on { border-color: var(--cyan); color: var(--cyan); }
.tag-panel { display: flex; flex-wrap: wrap; gap: 6px; max-height: 96px; overflow-y: auto; padding: 4px 0; }
.tag-panel[hidden] { display: none; }
.tag-btn { padding: 5px 10px; font-size: 12px; }
.recent summary { cursor: pointer; padding: 4px 0; }
.recent-list { display: grid; gap: 6px; max-height: 130px; overflow-y: auto; }
.recent-clip { display: grid; gap: 4px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); }

/* Images de référence (Studio) */
.refs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ref-slot { display: grid; gap: 4px; }
.ref-slot input[type=file] { font-size: 12px; color: var(--muted); }
.ref-preview img { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 4px; }

.import-box { display: grid; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--line); }
.import-box input[type=file] { font-size: 12px; color: var(--muted); }

/* Recherche */
.research-item { display: grid; gap: 8px; }
.research-item p { margin: 0; line-height: 1.5; }
/* Scripts (lecture seule) */
.script-item { cursor: pointer; display: grid; gap: 6px; }
.script-item:active { border-color: var(--cyan); }
.script-revenue { font-size: 13px; color: var(--text); margin-top: 4px; }
.script-step { display: grid; gap: 8px; }
.script-step p { margin: 0; line-height: 1.5; }
.sub-msg { padding-left: 10px; border-left: 2px solid var(--line); font-size: 14px; }
.research-meta { font-size: 12px; color: var(--muted); }
.sources { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.sources li { font-size: 13px; }
.sources a {
  display: block; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--cyan); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
