/* ===================== EthnologIA — styles ===================== */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --chip: #eef0f3;
  --chip-on: #4f46e5;
  --chip-on-ink: #ffffff;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 14px;
  --tabbar-h: 64px;
  --maxw: 640px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8eaed;
    --muted: #9aa1ac;
    --border: #262b34;
    --accent: #8b87ff;
    --accent-ink: #0f1115;
    --chip: #1f232c;
    --chip-on: #8b87ff;
    --chip-on-ink: #0f1115;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout : vues plein écran, scrollables, au-dessus de la tabbar ---- */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 24px);
  min-height: 100dvh;
}
.view[hidden] { display: none; }

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 14px;
}
.app-title { font-size: 1.25rem; margin: 0; letter-spacing: -.01em; }
.cal-title, .day-title { font-size: 1.1rem; margin: 0; flex: 1; text-align: center; }
.header-spacer { width: 40px; }
.capture-now { margin-left: auto; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 400; }

/* ---- Saisie ---- */
.capture { display: flex; flex-direction: column; gap: 18px; }
.note-text {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  resize: vertical;
  min-height: 120px;
  box-shadow: var(--shadow);
}
.note-text:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---- Chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  font: inherit;
  font-size: .9rem;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: transform .04s ease;
}
.chip:active { transform: scale(.96); }
.chip.is-on { background: var(--chip-on); color: var(--chip-on-ink); border-color: transparent; }
.chip--display { cursor: default; background: var(--surface-2); font-size: .82rem; padding: 4px 10px; }

.add-row { display: flex; gap: 8px; }
.add-input {
  flex: 1; font: inherit; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.add-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.add-btn {
  width: 44px; font-size: 1.25rem; line-height: 1;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
}

/* ---- Ressenti ---- */
.ressenti { display: flex; gap: 8px; }
.ressenti-btn {
  flex: 1; font-size: 1.5rem; padding: 8px 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; filter: grayscale(.5) opacity(.7);
  transition: transform .05s ease, filter .1s ease;
}
.ressenti-btn:active { transform: scale(.95); }
.ressenti-btn.is-on { filter: none; border-color: var(--accent); background: var(--surface-2); transform: scale(1.05); }

/* ---- Boutons ---- */
.btn-primary, .btn-secondary {
  font: inherit; font-weight: 600; font-size: 1rem;
  padding: 14px 18px; border-radius: 12px; border: none; cursor: pointer; width: 100%;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); margin-top: 10px; }
.btn-ghost { font: inherit; background: none; border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.icon-btn { font-size: 1.1rem; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }

/* ---- Calendrier ---- */
.cal-toolbar { display: flex; justify-content: center; margin-bottom: 10px; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekdays { color: var(--muted); font-size: .75rem; text-align: center; margin-bottom: 6px; }
.cal-cell {
  aspect-ratio: 1 / 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--surface); color: var(--text); font-size: .95rem; cursor: default;
  font-variant-numeric: tabular-nums;
}
.cal-cell.is-empty { background: transparent; }
.cal-cell.has-notes { cursor: pointer; border-color: var(--border); }
.cal-cell.is-today { outline: 2px solid var(--accent); outline-offset: -2px; font-weight: 700; }
.cal-dot {
  position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.cal-dot[data-count="2"] { width: 8px; height: 8px; }
.cal-dot[data-count="3"] { width: 10px; height: 10px; }

/* ---- Jour ---- */
.day-count { color: var(--muted); margin: 0 0 12px; }
.day-list { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.note-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.note-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.note-ressenti { margin-left: auto; font-size: 1.15rem; }
.note-body { white-space: pre-wrap; word-break: break-word; }
.note-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---- Export ---- */
.export-body { display: flex; flex-direction: column; gap: 16px; }
.note-hint { color: var(--muted); font-size: .92rem; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.stats > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.stats dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stats dd { margin: 4px 0 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cloud-placeholder { margin-top: 8px; padding: 16px; border: 1px dashed var(--border); border-radius: 12px; text-align: center; opacity: .6; }
.cloud-title { font-weight: 600; }
.cloud-sub { font-size: .85rem; color: var(--muted); }

/* ---- Empty ---- */
.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

/* ---- Tabbar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--muted); cursor: pointer; font: inherit;
}
.tab-ico { font-size: 1.3rem; line-height: 1; filter: grayscale(1) opacity(.7); }
.tab-txt { font-size: .72rem; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-ico { filter: none; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; z-index: 20;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 560px) {
  .tabbar { max-width: var(--maxw); margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
