/* Encore Un Livre — feuille de style */

:root {
  --ink: #111111;
  --paper: #FFFFFF;
  --cream: #F5F5F3;
  --line: #D8D5CF;
  --stone: #6B6258;
  --accent: #8A6A4A;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 1px 2px rgba(17, 17, 17, 0.04), 0 8px 24px rgba(17, 17, 17, 0.05);
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

button { font-family: inherit; }
input { font-family: inherit; }

.app { min-height: 100vh; }

/* ---------- Onboarding ---------- */

.screen-onboarding {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.onboarding-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  box-shadow: var(--shadow-soft);
  text-align: left;
}

.eyebrow {
  font-family: var(--font-serif);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 16px;
}

.onboarding-card h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.3;
  margin: 0 0 20px;
  font-weight: 600;
}

.lede {
  font-size: 15px;
  color: var(--stone);
  margin: 0 0 12px;
}

#form-onboarding input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 16px;
  margin-bottom: 14px;
  background: var(--cream);
  color: var(--ink);
}

#form-onboarding input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--paper);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: #000000; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--stone); }

.icon-btn {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--line); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Header ---------- */

.app-header {
  position: sticky;
  top: 0;
  background: rgba(245, 245, 243, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 16px 20px;
  z-index: 10;
}

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.01em;
}

.greeting {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--stone);
}

/* ---------- Main content ---------- */

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

.intro {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  margin: 4px 0 24px;
}

/* ---------- Today selection ---------- */

.today-selection {
  margin-bottom: 24px;
}

.today-selection-list {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.today-selection-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--cream);
}
.today-selection-item:last-child { border-bottom: none; }

.today-selection-position {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
  min-width: 20px;
}

.today-selection-info .title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.today-selection-info .author {
  font-size: 12px;
  color: var(--stone);
  margin: 2px 0 0;
}

/* ---------- Current choice ---------- */

.current-choice {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 24px;
}

.current-choice .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 6px;
}

.current-choice .title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 2px;
}

.current-choice .meta {
  font-size: 13px;
  color: var(--stone);
  margin: 0 0 12px;
}

.current-choice .actions {
  display: flex;
  gap: 10px;
}

.current-choice .actions button {
  padding: 9px 14px;
  font-size: 13px;
}

/* ---------- Propose box ---------- */

.propose-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-soft);
}

.propose-box h2 {
  font-family: var(--font-serif);
  font-size: 17px;
  margin: 0 0 14px;
}

#form-propose input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 10px;
  background: var(--cream);
  color: var(--ink);
}

#form-propose input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--paper);
}

.hint {
  font-size: 13px;
  color: var(--stone);
  margin: 10px 0 0;
  min-height: 16px;
}

.hint.error { color: #B3372C; }
.hint.success { color: #3A6B4A; }

/* ---------- Books list ---------- */

.books-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--stone);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 14px;
}
.books-heading svg { width: 16px; height: 16px; }

.books-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.book-card.is-mine { border-left: 3px solid var(--accent); }

.book-info { min-width: 0; }

.book-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 2px;
  overflow-wrap: anywhere;
}

.book-author {
  font-size: 13px;
  color: var(--stone);
  margin: 0 0 6px;
}

.book-votes {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}

.book-proposer {
  font-size: 12px;
  color: var(--stone);
}

.book-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.vote-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--stone);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
}
.vote-btn svg { width: 26px; height: 26px; }
.vote-btn.voted { color: var(--accent); }
.vote-btn.voted svg { fill: var(--accent); }
.vote-btn:active { transform: scale(1.2); }
.vote-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.vote-count { font-size: 12px; color: var(--stone); font-weight: 600; }

.delete-link {
  background: none;
  border: none;
  color: var(--stone);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px;
}
.delete-link:hover { color: #B3372C; }

.empty-state {
  text-align: center;
  color: var(--stone);
  font-size: 14px;
  padding: 30px 0;
}

/* ---------- History overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.panel {
  background: var(--paper);
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 640px) {
  .overlay { align-items: center; }
  .panel { border-radius: var(--radius-lg); max-height: 76vh; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-family: var(--font-serif);
  font-size: 17px;
  margin: 0;
}

.panel-body {
  padding: 16px 20px 28px;
  overflow-y: auto;
}

.history-group { margin-bottom: 22px; }

.history-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--stone);
  font-weight: 700;
  margin: 0 0 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--cream);
  gap: 10px;
}

.history-item:last-child { border-bottom: none; }

.history-item .title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.history-item .meta {
  font-size: 12px;
  color: var(--stone);
  margin: 2px 0 0;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.active { background: #E7EFE9; color: #3A6B4A; }
.status-pill.selected { background: #EFE6DC; color: var(--accent); }
.status-pill.unavailable { background: #F3E3E1; color: #B3372C; }
.status-pill.expired { background: var(--cream); color: var(--stone); }
.status-pill.deleted { background: var(--cream); color: var(--stone); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  max-width: 90%;
  text-align: center;
  z-index: 100;
  box-shadow: var(--shadow-soft);
}
.toast.error { background: #B3372C; }
