@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #141b26;
  --ink-panel: #1d2635;
  --ink-line: #2c3a4f;
  --paper: #efe7d4;
  --paper-dim: #c9bfa4;
  --brass: #c99a3a;
  --brass-light: #e6c877;
  --rust: #b0563b;
}

:root { --header-h: 62px; }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ink); color: var(--paper);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

.cv-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--ink-line);
  background: var(--ink-panel);
  min-height: var(--header-h);
}
@media (display-mode: standalone) {
  .cv-header { padding-top: calc(14px + env(safe-area-inset-top)); }
}
.cv-eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--brass); margin-bottom: 2px;
}
.cv-title { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; margin: 0; }

.cv-body { display: flex; height: calc(100dvh - var(--header-h)); }

.cv-sidebar {
  width: 280px; flex-shrink: 0; border-right: 1px solid var(--ink-line);
  background: var(--ink-panel); overflow-y: auto; padding: 10px;
}
.cv-sidebar.hidden { display: none; }

.cv-empty { color: var(--paper-dim); font-size: 13px; line-height: 1.6; padding: 24px 10px; text-align: center; }

.cv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cv-card {
  background: var(--paper); color: #2a2114; border-radius: 4px; padding: 10px 12px;
  cursor: pointer; border-left: 3px solid var(--brass);
}
.cv-card-top { display: flex; align-items: center; gap: 8px; }
.cv-card-mood { font-size: 16px; }
.cv-card-name { font-family: 'Fraunces', serif; font-weight: 600; font-size: 14.5px; flex: 1; }
.cv-card-delete { background: none; border: none; color: #8a6420; cursor: pointer; font-size: 12px; padding: 2px; }
.cv-card-note { font-size: 12.5px; margin: 5px 0 3px; line-height: 1.45; color: #4a3f2c; }
.cv-card-date { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #8a7c5e; }

.cv-mapwrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

.cv-error {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--rust); color: #fff; padding: 8px 14px; border-radius: 4px;
  font-size: 12.5px; z-index: 1000;
}

.cv-btn-ghost {
  background: transparent; border: 1px solid var(--ink-line); color: var(--paper-dim);
  padding: 7px 12px; border-radius: 4px; font-size: 12.5px; cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.cv-btn-brass {
  background: var(--brass); border: none; color: #241a05; font-weight: 600;
  padding: 8px 16px; border-radius: 4px; font-size: 13px; cursor: pointer;
}

.cv-overlay {
  position: fixed; inset: 0; background: rgba(10,14,20,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px;
}
.cv-modal {
  background: var(--ink-panel); border: 1px solid var(--ink-line); border-radius: 6px;
  padding: 20px; width: 100%; max-width: 340px;
}
.cv-mood-row { display: flex; gap: 6px; margin: 12px 0; }
.cv-mood-btn {
  width: 36px; height: 36px; border-radius: 4px; border: 1px solid var(--ink-line); font-size: 16px;
  cursor: pointer; background: transparent;
}
.cv-mood-btn.active { border-color: var(--brass); background: rgba(201,154,58,0.15); }

.cv-rating-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--paper-dim); margin-bottom: 6px;
}
.cv-rating-row { display: flex; gap: 4px; margin-bottom: 14px; }
.cv-star {
  font-size: 22px; cursor: pointer; color: var(--ink-line); background: none; border: none;
  transition: color 0.1s ease; line-height: 1;
}
.cv-star.filled { color: var(--brass); }
.cv-card-stars { font-size: 11px; color: var(--brass); letter-spacing: 1px; margin-top: 2px; }
.cv-popup-stars { color: #a9791b; letter-spacing: 1px; font-size: 12px; }

.cv-locate-btn {
  position: absolute; bottom: 90px; right: 10px; z-index: 900;
  width: 34px; height: 34px; border-radius: 4px; border: 1px solid var(--ink-line);
  background: var(--ink-panel); color: var(--brass-light); font-size: 16px; cursor: pointer;
}

.cv-user-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #4a9fe0; border: 2px solid #fff; box-shadow: 0 0 0 rgba(74,159,224,0.5);
  animation: cv-pulse 2s infinite;
}
@keyframes cv-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74,159,224,0.5); }
  70%  { box-shadow: 0 0 0 12px rgba(74,159,224,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,159,224,0); }
}

.cv-card-edit {
  background: none; border: none; color: #6b5f45; cursor: pointer; font-size: 11.5px; padding: 2px;
}
.cv-popup-edit {
  margin-top: 6px; display: inline-block; background: var(--brass); color: #241a05; border: none;
  border-radius: 3px; padding: 4px 9px; font-size: 11.5px; cursor: pointer; font-family: 'Inter', sans-serif;
}

.cv-input, .cv-textarea {
  width: 100%; background: var(--ink); border: 1px solid var(--ink-line);
  color: var(--paper); border-radius: 4px; padding: 9px 10px; font-size: 13.5px; margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
}
.cv-textarea { resize: vertical; margin-bottom: 14px; }

.cv-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.cv-pin {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: radial-gradient(circle at 35% 30%, var(--brass-light), var(--brass));
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5); border: 1.5px solid #8a6420;
}
.cv-pin > * { transform: rotate(45deg); display: block; }

.leaflet-popup-content-wrapper { background: var(--paper); color: #2a2114; border-radius: 3px; font-family: 'Inter', sans-serif; }
.leaflet-popup-tip { background: var(--paper); }
.cv-popup strong { font-family: 'Fraunces', serif; font-size: 15px; }
.cv-popup p { margin: 4px 0 2px; font-size: 13px; line-height: 1.4; }
.cv-popup-date { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #6b5f45; }

.leaflet-control-zoom a {
  background: var(--ink-panel) !important; color: var(--brass-light) !important; border-color: var(--ink-line) !important;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-line); border-radius: 4px; }

/* ===================== Responsive ===================== */

/* Tablette et mobile : la carte occupe tout l'écran,
   le carnet devient un tiroir qui glisse depuis le bas. */
@media (max-width: 820px) {
  :root { --header-h: 54px; }

  .cv-header { padding: 10px 14px; }
  .cv-title { font-size: 18px; }
  .cv-eyebrow { font-size: 9.5px; }
  .cv-btn-ghost { padding: 6px 10px; font-size: 11.5px; }

  .cv-body { position: relative; }

  .cv-sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 48vh;
    border-right: none;
    border-top: 1px solid var(--ink-line);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.45);
    z-index: 800;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .cv-sidebar::before {
    content: "";
    display: block;
    width: 36px; height: 4px;
    background: var(--ink-line);
    border-radius: 2px;
    margin: 4px auto 10px;
  }
  .cv-sidebar.hidden { display: none; }

  .cv-mapwrap { width: 100%; }

  .cv-locate-btn { bottom: calc(16px + env(safe-area-inset-bottom)); right: 12px; }

  .cv-modal { max-width: 100%; margin: 0 8px; max-height: 88vh; overflow-y: auto; }
}

/* Petits mobiles : resserre encore le formulaire */
@media (max-width: 380px) {
  .cv-mood-btn, .cv-star { width: 30px; height: 30px; font-size: 15px; }
  .cv-title { font-size: 16px; }
}

/* Bureau large : ne pas laisser le carnet devenir trop étroit ou trop large */
@media (min-width: 1400px) {
  .cv-sidebar { width: 320px; }
}
