@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Jost:wght@300;400;500;600&display=swap');

:root {
  --bg:       #1A1209;
  --surface:  #3B2F20;
  --surface2: #2A200F;
  --gold:     #B08A5A;
  --gold-lt:  #C9A876;
  --ivory:    #E8D5B0;
  --ivory-dim:#A89070;
  --red:      #B03A2E;
  --border:   rgba(176,138,90,0.2);
  --radius:   6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ivory);
  font-family: 'Jost', sans-serif;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── SCREENS ─────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  will-change: transform;
}
.screen.active  { transform: translateX(0); }
.screen.slide-left { transform: translateX(-30%); }

/* ── HEADER ──────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}
.app-header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  flex: 1;
}
.app-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ivory);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-sub {
  font-size: 11px;
  color: var(--ivory-dim);
  font-weight: 300;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-col { flex: 1; overflow: hidden; }

/* ── BUTTONS ─────────────────────────────────────────── */
button {
  cursor: pointer;
  font-family: 'Jost', sans-serif;
  border: none;
  outline: none;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation; /* supprime le délai 300ms iOS */
  -webkit-user-select: none;
  user-select: none;
}
button:active { transform: scale(0.96); }

.btn-icon {
  background: none;
  color: var(--gold);
  font-size: 22px;
  padding: 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.btn-primary {
  background: var(--gold);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 16px;
  min-height: 44px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary:hover { background: var(--gold-lt); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost {
  background: none;
  color: var(--ivory-dim);
  font-size: 13px;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-danger {
  background: none;
  color: var(--red);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(176,58,46,0.3);
}

.btn-generate {
  background: var(--gold);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--radius);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ── SCROLLABLE BODY ─────────────────────────────────── */
.screen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
}

/* ── HOME SCREEN ─────────────────────────────────────── */
.home-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--ivory-dim);
}
.home-empty .empty-icon { font-size: 48px; margin-bottom: 16px; }
.home-empty p { font-size: 14px; line-height: 1.6; }

.project-list { display: flex; flex-direction: column; gap: 12px; }

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.project-card:active { background: #4a3d2a; }

.project-card-info { flex: 1; overflow: hidden; }
.project-card-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--ivory);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-card-address {
  font-size: 12px;
  color: var(--ivory-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-card-meta {
  font-size: 11px;
  color: var(--gold);
  margin-top: 6px;
  display: flex;
  gap: 12px;
}
.project-card-chevron { color: var(--gold); font-size: 18px; opacity: 0.6; }

/* ── TABS ────────────────────────────────────────────── */
.tabs {
  flex-shrink: 0;
  display: flex;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  background: none;
  color: var(--ivory-dim);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 13px;
  min-height: 48px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── PARTICIPANTS ────────────────────────────────────── */
.field-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-bottom: 6px;
}

textarea, input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ivory);
  font-family: 'Jost', sans-serif;
  font-size: 16px; /* 16px minimum pour éviter le zoom automatique iOS */
  padding: 10px 12px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}
textarea:focus, input[type="text"]:focus {
  border-color: var(--gold);
}
textarea::placeholder, input::placeholder { color: var(--ivory-dim); }

/* ── ACTION ROW ──────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}
.action-row .btn-action {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ivory);
  font-size: 13px;
  font-weight: 500;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}
.action-row .btn-action:active { background: #4a3d2a; }
.action-row .btn-action .action-icon { font-size: 22px; }
.action-row .btn-action.recording {
  border-color: var(--red);
  background: rgba(176,58,46,0.1);
  color: var(--red);
}

/* ── RECORDING INDICATOR ─────────────────────────────── */
.recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(176,58,46,0.12);
  border: 1px solid rgba(176,58,46,0.35);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.rec-timer { font-size: 16px; font-weight: 600; color: var(--red); flex: 1; }
.rec-label { font-size: 12px; color: var(--ivory-dim); }

/* ── TRANSCRIPTION STATUS ────────────────────────────── */
.transcription-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(176,138,90,0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--gold);
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(176,138,90,0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TEXT INPUT ROW ──────────────────────────────────── */
.text-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.text-input-row textarea { flex: 1; min-height: 60px; }
.text-input-row button { flex-shrink: 0; height: 60px; }

/* ── OBSERVATION LIST ────────────────────────────────── */
.obs-list { display: flex; flex-direction: column; gap: 10px; }

.obs-date-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: capitalize;
  color: var(--gold);
}
.obs-date-header:first-child { margin-top: 4px; }
.obs-date-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.obs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.obs-card-body { padding: 12px 14px; }
.obs-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.obs-type-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(176,138,90,0.15);
  color: var(--gold);
}
.obs-type-badge.audio { background: rgba(70,130,180,0.15); color: #7ab4d4; }
.obs-type-badge.photo { background: rgba(100,160,80,0.15); color: #8bc87a; }
.obs-time { font-size: 11px; color: var(--ivory-dim); flex: 1; }
.obs-delete {
  background: none;
  color: var(--ivory-dim);
  font-size: 18px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.obs-content {
  font-size: 14px;
  color: var(--ivory);
  line-height: 1.55;
  white-space: pre-wrap;
}

.obs-photo-img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--border);
}
.obs-annotation {
  font-size: 13px;
  color: var(--ivory-dim);
  font-style: italic;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.obs-edit-annotation {
  background: none;
  color: var(--gold);
  font-size: 12px;
  padding: 12px 14px;
  min-height: 44px;
  text-align: left;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  width: 100%;
}

/* ── CR LIST ─────────────────────────────────────────── */
.cr-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--ivory-dim);
  font-size: 13px;
  line-height: 1.6;
}
.cr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.cr-card:active { background: #4a3d2a; }
.cr-card-info { flex: 1; }
.cr-card-date { font-size: 14px; font-weight: 500; color: var(--ivory); }
.cr-card-meta { font-size: 12px; color: var(--ivory-dim); margin-top: 3px; }
.cr-card-icon { font-size: 20px; color: var(--gold); opacity: 0.6; }

/* ── PHOTO ANNOTATION SCREEN ─────────────────────────── */
#screen-photo {
  display: flex;
  flex-direction: column;
}
#screen-photo .screen-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
}

/* Drawing toolbar */
.draw-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.draw-color-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: border-color 0.15s, transform 0.1s;
}
.draw-color-btn.active { border-color: var(--gold); transform: scale(1.2); }
.draw-tool-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ivory);
  font-size: 14px;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.draw-tool-btn.active {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
}
.draw-size-slider {
  flex: 1;
  min-width: 60px;
  max-width: 90px;
  accent-color: var(--gold);
}
.draw-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

/* Canvas photo */
.photo-canvas-wrap {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  margin: 0 16px;
}
#photo-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* Archived project card */
.project-card.archived {
  opacity: 0.5;
}
.project-card.archived .project-card-name {
  text-decoration: line-through;
}
.archived-toggle {
  text-align: center;
  padding: 14px 12px;
  min-height: 44px;
  color: var(--ivory-dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-archive {
  background: none;
  border: 1px solid var(--border);
  color: var(--ivory-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
}

/* ── CR VIEW SCREEN ──────────────────────────────────── */
.cr-actions-row {
  display: flex;
  gap: 8px;
}
.cr-view-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px;
}
.cr-markdown h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
  line-height: 1.3;
}
.cr-markdown h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--gold-lt);
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.cr-markdown p {
  font-size: 14px;
  color: var(--ivory);
  line-height: 1.65;
  margin-bottom: 8px;
}
.cr-markdown strong { color: var(--ivory); font-weight: 600; }
.cr-markdown em { color: var(--ivory-dim); }
.cr-markdown ul { padding-left: 18px; margin: 6px 0; }
.cr-markdown li { font-size: 14px; color: var(--ivory); line-height: 1.6; margin-bottom: 4px; }
.cr-markdown hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.cr-markdown .action-item {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--ivory);
  padding: 4px 0;
}

/* ── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px;
  padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 20px));
  width: 100%;
  border-top: 1px solid var(--border);
  animation: slideUp 0.25s cubic-bezier(0.4,0,0.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } }

.modal-sheet h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 20px;
}
.modal-field { margin-bottom: 14px; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions button { flex: 1; }

/* ── GENERATING OVERLAY ──────────────────────────────── */
.generating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  gap: 16px;
}
.generating-overlay .spinner { width: 36px; height: 36px; border-width: 3px; }
.generating-overlay p {
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ivory);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 3000;
  white-space: nowrap;
  animation: toastIn 0.2s, toastOut 0.2s 2s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ── HIDDEN ──────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── SAFE AREA (iPhone) ──────────────────────────────── */
.app-header { padding-top: max(14px, env(safe-area-inset-top)); }
.screen-body { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* ── DATE INPUT ──────────────────────────────────────── */
input[type="date"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ivory);
  font-family: 'Jost', sans-serif;
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  color-scheme: dark; /* picker sombre sur iOS */
}
input[type="date"]:focus { border-color: var(--gold); }

/* ── PARTICIPANT CHIPS ───────────────────────────────── */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  background: rgba(176,138,90,0.1);
  border: 1px solid rgba(176,138,90,0.3);
  color: var(--gold);
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 34px;
  display: flex;
  align-items: center;
}
.chip:active { background: rgba(176,138,90,0.25); transform: scale(0.96); }

/* ── CR TOOLBAR ──────────────────────────────────────── */
.cr-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  min-height: 44px;
}
.cr-edit-btn {
  font-size: 13px;
  color: var(--gold);
  padding: 10px 12px;
  min-height: 44px;
}

/* ── CR EDIT AREA ────────────────────────────────────── */
.cr-edit-area {
  flex: 1;
  background: var(--surface2);
  border: none;
  color: var(--ivory);
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  line-height: 1.65;
  padding: 20px 16px;
  resize: none;
  outline: none;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── BACKUP ROW ──────────────────────────────────────── */
.backup-row {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.backup-row button {
  flex: 1;
  font-size: 13px;
  min-height: 44px;
}

/* ── SECTION DIVIDER ─────────────────────────────────── */
.section-divider {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
