/* SEIJI-KAI — noir et bleu du logo, police du téléphone, Bodoni pour les grands titres */
@font-face {
  font-family: "Bodoni Moda";
  src: url("/fonts/bodoni-moda-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #141418;
  --surface2: #1E1E24;
  --line: #1E1E24;
  --line2: #2A2A32;
  --text: #F2F2F5;
  --muted: #9A9AA5;
  --soft: #C8C8D0;
  --accent: #3D3BDB;
  --accent-text: #8C8CFF;
  --on-accent: #FFFFFF;
  --on-accent-muted: #D6D6FF;
  --bar: #0A0A0D;
  --dim: #55555F;
  --ring: #6C6C74;
  --danger: #FF6B6B;
  --overlay: rgba(0, 0, 0, 0.6);
  --serif: "Bodoni Moda", "Didot", "Bodoni 72", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #FFFFFF;
    --surface: #F4F4F6;
    --surface2: #ECECF0;
    --line: #E8E8EC;
    --line2: #DCDCE2;
    --text: #111114;
    --muted: #6C6C74;
    --soft: #3A3A40;
    --accent: #003C8B;
    --accent-text: #003C8B;
    --on-accent-muted: rgba(255, 255, 255, 0.78);
    --bar: #F8F8FA;
    --dim: #B4B4BC;
    --ring: #A0A0A8;
    --danger: #C4271F;
    --overlay: rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; position: relative; }

/* ---------- En-têtes */
.top { padding: calc(var(--top) + 14px) 16px 10px 20px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.top h1 { margin: 0; flex: 1; font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.1; letter-spacing: 0.01em; }
.top .logo { width: 34px; height: 34px; border-radius: 50%; display: block; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn.plain { background: transparent; }
.icon-btn svg, .tab svg { display: block; }

.chat-top { padding: calc(var(--top) + 8px) 12px 6px 4px; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.chat-top .back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--accent-text); flex-shrink: 0; }
.chat-top h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-top .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chat-top .titles { flex: 1; min-width: 0; }

/* ---------- Défilement */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }

/* ---------- Barre d'onglets */
.tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 8px calc(var(--bottom) + 8px); border-top: 1px solid var(--line); background: var(--bar); flex-shrink: 0; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 4px; min-height: 48px; color: var(--muted); font-size: 11px; font-weight: 500; position: relative; }
.tab[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
.tab .dot { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* ---------- Carte du prochain rendez-vous */
.next { margin: 6px 16px 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); display: flex; align-items: center; gap: 12px; }
.next .day { width: 44px; text-align: center; flex-shrink: 0; }
.next .day b { display: block; font-size: 12px; font-weight: 600; color: var(--accent-text); text-transform: uppercase; }
.next .day span { display: block; font-size: 22px; font-weight: 600; line-height: 1.1; }
.next .what { flex: 1; min-width: 0; }
.next .what strong { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next .what span { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Liste des conversations */
.row { display: flex; gap: 12px; padding: 10px 16px; align-items: center; }
.row:active { background: var(--surface); }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--surface2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 24px; font-weight: 600; overflow: hidden; }
.avatar img { width: 100%; height: 100%; display: block; }
.row .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--line); padding: 2px 0 12px; }
.row .l1 { display: flex; align-items: baseline; gap: 8px; }
.row .name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .stage { flex: 1; font-size: 13px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.row .time { font-size: 13px; color: var(--muted); white-space: nowrap; margin-left: auto; }
.row .time.new { color: var(--accent-text); font-weight: 600; }
.row .l2 { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.row .preview { flex: 1; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.paused .name { color: var(--soft); }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sdot.idee { border: 2px solid var(--ring); }
.sdot.creuse { border: 2px solid var(--accent-text); }
.sdot.lance { background: var(--accent-text); }
.sdot.pause { background: var(--dim); }

.empty { padding: 40px 28px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* ---------- Sujet : étapes, décisions, onglets */
.rail { display: flex; align-items: center; gap: 8px; padding: 8px 20px 10px; font-size: 13px; flex-shrink: 0; }
.rail .st { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.rail .st i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--dim); display: inline-block; }
.rail .st.done i { background: var(--accent-text); border-color: var(--accent-text); }
.rail .st.now { color: var(--text); font-weight: 600; }
.rail .st.now i { width: 12px; height: 12px; border: 3px solid var(--accent-text); }
.rail .ln { flex: 1; height: 2px; background: var(--line2); }
.rail .ln.done { background: var(--accent-text); }
.rail.paused { color: var(--muted); }

.decisions { margin: 0 12px 8px; border-radius: 14px; background: var(--surface); flex-shrink: 0; }
.decisions > button { width: 100%; min-height: 44px; padding: 10px 14px; border: 0; background: transparent; display: flex; align-items: center; gap: 10px; text-align: left; }
.decisions > button span { flex: 1; font-size: 15px; font-weight: 600; }
.decisions > button em { font-style: normal; font-size: 13px; color: var(--muted); }
.decisions ol { margin: 0; padding: 0 14px 12px 42px; display: flex; flex-direction: column; gap: 10px; max-height: 38vh; overflow-y: auto; }
.decisions li { font-size: 15px; line-height: 1.4; white-space: pre-wrap; }
.decisions li small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; white-space: normal; }

.seg { margin: 0 12px; padding: 3px; border-radius: 10px; background: var(--surface); display: grid; gap: 3px; flex-shrink: 0; }
.seg button { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--line2); color: var(--text); font-weight: 600; }

/* ---------- Discussion */
.msgs { flex: 1; overflow-y: auto; padding: 12px 10px 8px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.daysep { align-self: center; font-size: 12px; color: var(--muted); padding: 4px 10px; border-radius: 8px; background: var(--surface); margin: 8px 0 4px; }
.bubble { max-width: 80%; padding: 7px 12px 6px; border-radius: 18px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.bubble.theirs { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 6px; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.bubble.gap { margin-top: 6px; }
.bubble .who { font-size: 13px; font-weight: 600; color: var(--accent-text); margin-bottom: 2px; }
.bubble .txt { font-size: 16px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .txt a { text-decoration: underline; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 3px; font-size: 11px; color: var(--muted); }
.bubble.mine .meta { color: var(--on-accent-muted); }
.bubble .ok { font-weight: 700; color: var(--accent-text); }
.bubble.mine .ok { color: var(--on-accent); }
.bubble.pressed { filter: brightness(0.85); }
.bubble img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; margin: 2px 0 4px; }
.filechip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 2px 0 4px; border-radius: 12px; background: rgba(127, 127, 140, 0.18); min-width: 200px; }
.filechip b { font-size: 10px; font-weight: 700; width: 34px; height: 40px; border-radius: 5px; background: rgba(127, 127, 140, 0.25); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; flex-shrink: 0; }
.filechip span { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(var(--bottom) + 8px); border-top: 1px solid var(--line); background: var(--bar); flex-shrink: 0; }
.composer textarea { flex: 1; min-height: 40px; max-height: 140px; margin: 2px 0; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line2); background: var(--surface); font-size: 16px; line-height: 1.3; resize: none; }
.composer .send { background: var(--accent); color: var(--on-accent); }
.composer .send:disabled { opacity: 0.45; }
.sending { font-size: 13px; color: var(--muted); padding: 0 16px 6px; }

/* ---------- Feuille d'actions */
.sheet-bg { position: fixed; inset: 0; background: var(--overlay); display: flex; flex-direction: column; justify-content: flex-end; z-index: 20; }
.sheet-bg .close { flex: 1; border: 0; background: transparent; }
.sheet { margin: 0 8px calc(var(--bottom) + 12px); display: flex; flex-direction: column; gap: 8px; max-width: 624px; width: calc(100% - 16px); align-self: center; }
.sheet .grp { border-radius: 14px; background: var(--surface2); overflow: hidden; }
.sheet .quote { padding: 12px 16px; font-size: 14px; color: var(--muted); line-height: 1.4; border-bottom: 1px solid var(--line2); max-height: 7.2em; overflow: hidden; }
.sheet .grp button, .sheet > button { width: 100%; min-height: 56px; border: 0; border-bottom: 1px solid var(--line2); background: transparent; font-size: 18px; }
.sheet .grp button:last-child { border-bottom: 0; }
.sheet .primary { color: var(--accent-text); font-weight: 600; }
.sheet .danger { color: var(--danger); }
.sheet > button { border-radius: 14px; background: var(--surface2); font-weight: 600; border: 0; }

/* ---------- Listes groupées (fichiers, réglages) */
.pad { padding: 14px 12px calc(var(--bottom) + 24px); }
.group { margin: 0; padding: 0; list-style: none; border-radius: 14px; background: var(--surface); overflow: hidden; }
.group li { border-bottom: 1px solid var(--line); }
.group li:last-child { border-bottom: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; border: 0; background: transparent; text-align: left; }
.item .ft { width: 40px; height: 48px; border-radius: 6px; background: var(--surface2); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; font-size: 10px; font-weight: 700; color: var(--soft); flex-shrink: 0; }
.item .tx { flex: 1; min-width: 0; }
.item .tx strong { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tx span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.dashed { margin-top: 14px; width: 100%; min-height: 50px; border-radius: 14px; border: 1px dashed var(--line2); background: transparent; color: var(--accent-text); font-size: 16px; font-weight: 600; }

/* ---------- Formulaires */
.form { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 15px; font-weight: 600; }
.field small, .hint { font-size: 13px; color: var(--muted); }
.input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); font-size: 17px; width: 100%; }
textarea.input { height: auto; padding: 12px 14px; line-height: 1.4; resize: vertical; min-height: 110px; }
select.input { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.two { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-size: 15px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line2); background: transparent; font-size: 15px; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg.full { margin: 0; }
.seg.full button { min-height: 40px; }
.btn { display: flex; align-items: center; justify-content: center; min-height: 54px; width: 100%; border-radius: 14px; border: 0; background: var(--accent); color: var(--on-accent); font-size: 17px; font-weight: 600; }
.btn:disabled { opacity: 0.5; }
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line2); }
.footer { padding: 10px 20px calc(var(--bottom) + 16px); border-top: 1px solid var(--line); flex-shrink: 0; }
.footer p { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; line-height: 1.4; }
.textlink { border: 0; background: transparent; color: var(--accent-text); font-size: 17px; min-height: 44px; padding: 0 12px; }
h2.sec { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.card { display: block; padding: 12px 14px; border-radius: 14px; background: var(--surface); }
.card strong { display: block; font-size: 16px; font-weight: 600; }
.card span { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }

/* ---------- Agenda */
.agenda { padding: 4px 12px calc(var(--bottom) + 16px); display: flex; flex-direction: column; gap: 18px; }
.agenda h2 { margin: 0 0 8px 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
.ev { border-radius: 16px; background: var(--surface); padding: 14px 14px 12px; }
.ev .head { display: flex; gap: 14px; }
.ev .hour { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 56px; }
.ev .info { flex: 1; min-width: 0; }
.ev .info strong { display: block; font-size: 17px; font-weight: 600; line-height: 1.3; }
.ev .info span, .ev .info a { display: block; font-size: 14px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.ev .info a.link { color: var(--accent-text); }
.ev .edit { align-self: flex-start; font-size: 14px; color: var(--accent-text); min-height: 32px; }
.ev .who { font-size: 14px; color: var(--soft); line-height: 1.4; margin: 12px 0 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.ev .answers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ev .answers button { min-height: 44px; border: 0; border-radius: 10px; background: var(--surface2); font-size: 15px; }
.ev .answers button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- Connexion */
.auth { flex: 1; overflow-y: auto; padding: calc(var(--top) + 48px) 24px calc(var(--bottom) + 24px); display: flex; flex-direction: column; }
.auth .brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth .brand img { width: 96px; height: 96px; border-radius: 50%; }
.auth .brand h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 34px; letter-spacing: 0.01em; }
.auth form { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.auth .seg { margin: 0 0 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.auth .seg button { min-height: 40px; }
.code { font-size: 28px; font-weight: 700; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 90px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 30; max-width: 90%; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up 0.18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
