:root {
  --blue: #1d4ed8; --blue-dark: #1e40af; --bg: #f5f7fb; --card: #fff;
  --text: #16181d; --muted: #6b7280; --red: #dc2626; --green: #16a34a;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
.view { max-width: 560px; margin: 0 auto; padding: 16px; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 0 16px; }
.topbar h2 { font-size: 1.25rem; flex: 1; }
.btn-back { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--blue); padding: 4px 8px; }
.badge { background: #e3e9fb; color: var(--blue-dark); font-size: 0.75rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; }

/* Auth */
#view-auth { display: flex; min-height: 90vh; align-items: center; justify-content: center; }
.auth-box { width: 100%; max-width: 380px; background: var(--card); border-radius: var(--radius); padding: 28px 22px; box-shadow: 0 4px 24px rgba(0,0,0,0.07); }
.brand { text-align: center; font-size: 1.7rem; }
.brand span { color: var(--blue); }
.tagline { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 6px 0 20px; }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; border: none; background: none; padding: 9px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* Forms */
input, textarea {
  width: 100%; padding: 11px 12px; margin-bottom: 12px;
  border: 1.5px solid #dde2ec; border-radius: 10px; font-size: 1rem; font-family: inherit;
  background: #fff; color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--blue); }
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
label input, label textarea { margin-top: 5px; font-weight: 400; }
label small { font-weight: 400; }
.row2 { display: flex; gap: 10px; }
.row2 label { flex: 1; }

.btn-primary, .btn-secondary, .btn-ghost {
  width: 100%; padding: 13px; border-radius: 10px; font-size: 1rem; font-weight: 600;
  cursor: pointer; margin-bottom: 10px; border: none;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-dark); }
.btn-primary:disabled { opacity: 0.6; }
.btn-secondary { background: #e3e9fb; color: var(--blue-dark); }
.btn-ghost { background: none; color: var(--muted); }
.error { color: var(--red); font-size: 0.88rem; text-align: center; margin-top: 4px; }

/* Liste */
.list { display: flex; flex-direction: column; gap: 10px; }
.report-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}
.report-card .info { flex: 1; min-width: 0; }
.report-card .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-card .sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.ready { background: var(--green); }
.dot.processing { background: #f59e0b; animation: pulse 1.2s infinite; }
.dot.failed { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }
.empty { text-align: center; color: var(--muted); margin-top: 60px; line-height: 1.6; }

/* Enregistrement */
.record-zone { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 8vh; gap: 18px; }
#record-hint { color: var(--muted); font-size: 0.92rem; max-width: 320px; line-height: 1.5; }
.mic-btn {
  width: 110px; height: 110px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(29,78,216,0.4); transition: transform 0.15s, background 0.2s;
}
.mic-btn:active { transform: scale(0.94); }
.mic-btn.recording { background: var(--red); animation: recpulse 1.4s infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 18px rgba(220,38,38,0.12); } }
.timer { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 700; }
#record-status { color: var(--muted); }
.dictation-guide { background: var(--card); border-radius: var(--radius); padding: 14px 16px; max-width: 360px; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.dictation-guide .guide-title { font-size: 0.82rem; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.guide-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.guide-chips span { background: #eef2fb; color: var(--blue-dark); font-size: 0.78rem; padding: 4px 10px; border-radius: 99px; }
#record-actions { width: 100%; max-width: 320px; }
.playback { width: 100%; margin-bottom: 12px; }
.live-transcript {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  font-size: 0.9rem; color: var(--text); line-height: 1.55; max-width: 480px;
  text-align: left; box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}

/* Rapport */
.report-form { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.report-actions { margin-top: 6px; }
.empty-notice { background: #fff7e6; border: 1px solid #ffd591; color: #8a5a00; border-radius: 10px; padding: 10px 12px; font-size: 0.82rem; margin-bottom: 14px; line-height: 1.45; }
.field-empty input, .field-empty textarea { border-color: #ffce7a; background: #fffdf7; }
.transcript-box { margin-top: 14px; font-size: 0.85rem; color: var(--muted); }
.transcript-box p { margin-top: 8px; line-height: 1.5; }
.processing { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 10vh; color: var(--muted); }
.spinner {
  width: 44px; height: 44px; border: 4px solid #dde2ec; border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Nav */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(64px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid #e5e9f2;
  display: flex; justify-content: space-around; align-items: flex-start; padding-top: 8px;
}
.nav-btn { background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.68rem; cursor: pointer; width: 80px; }
.nav-btn.active { color: var(--blue); }
.nav-mic {
  background: var(--blue); color: #fff; border-radius: 50%; width: 54px; height: 54px;
  justify-content: center; margin-top: -16px; box-shadow: 0 4px 14px rgba(29,78,216,0.4);
}

/* Banniere d'installation PWA */
.install-banner {
  position: fixed; bottom: calc(74px + env(safe-area-inset-bottom)); left: 12px; right: 12px;
  max-width: 536px; margin: 0 auto;
  background: #1f2937; color: #fff; border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; z-index: 40;
  font-size: 0.85rem; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.install-banner .install-text { flex: 1; line-height: 1.45; }
.install-btn { background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.install-close { background: none; border: none; color: #9ca3af; font-size: 1.3rem; cursor: pointer; padding: 0 4px; flex-shrink: 0; }

/* Toast */
.toast {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 11px 20px; border-radius: 99px;
  font-size: 0.88rem; max-width: 90vw; text-align: center; z-index: 50;
  animation: fadein 0.25s;
}
.toast.err { background: var(--red); }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } }
