:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #5b9fd4;
  --accent-hover: #7ab3e0;
  --ok: #3d9a6a;
  --error: #d45b5b;
  --radius: 10px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--text); }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.page-head h1 { margin: 0 0 0.25rem; font-size: 1.75rem; }
.subtitle { color: var(--muted); margin: 0 0 1.25rem; }

.login-card {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  text-align: center;
}

.login-card h1 { margin-top: 0; }

.flash-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.flash-ok, .flash.ok { background: rgba(61, 154, 106, 0.2); color: #8fd4b0; }
.flash-error, .flash.error { background: rgba(212, 91, 91, 0.2); color: #f0a0a0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filters select,
.filters input,
.form-stack input,
.form-stack select,
.form-stack textarea,
.pos-input,
.search-input {
  background: var(--surface);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font: inherit;
}

.search-input { flex: 1; min-width: 140px; }

.item-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }

.item-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 4px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.item-card .item-main,
.item-card .item-actions {
  display: flex;
}

.item-card .item-main {
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.item-card .item-actions {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 2px dashed var(--surface2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: copy;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.item-card.drag-over {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px rgba(61, 154, 106, 0.35);
}

.item-card.drag-over .drop-zone,
.drop-zone:hover {
  border-color: var(--ok);
  background: rgba(61, 154, 106, 0.08);
  color: var(--text);
}

.drop-zone.drop-loading {
  opacity: 0.6;
  pointer-events: none;
}

.drop-zone-icon {
  font-size: 1rem;
  opacity: 0.85;
}

.item-card.type-livre_en_ligne .drop-zone {
  border-color: rgba(91, 159, 212, 0.45);
}

.item-card.type-video { border-left-color: #c45b8a; }
.item-card.type-livre_en_ligne { border-left-color: #5b9fd4; }
.item-card.type-livre_audio { border-left-color: #9b7bd4; }
.item-card.type-article { border-left-color: #d4a55b; }

.item-card h2 { margin: 0.35rem 0 0.25rem; font-size: 1.1rem; }
.item-card h2.item-title { color: var(--text); }

.item-url-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0.15rem 0 0.35rem;
}

.btn-open {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  background: var(--accent);
  color: #0f1419 !important;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
}

.btn-open:hover {
  background: var(--accent-hover);
  color: #0f1419 !important;
}

.item-url-raw {
  font-size: 0.78rem;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.35;
  cursor: pointer;
  pointer-events: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.item-url-raw:hover {
  color: var(--accent-hover);
}

.item-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--muted);
}

.status-en_cours { color: #8fd4b0; }
.status-en_pause { color: #d4c48f; }
.status-termine { color: var(--muted); }

.position { margin: 0.25rem 0; color: var(--accent); font-size: 0.95rem; }
.notes { margin: 0.25rem 0; color: var(--muted); font-size: 0.9rem; }
.dates { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--muted); }

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
  min-width: 140px;
}

.touch-form { display: flex; gap: 0.35rem; }
.pos-input { flex: 1; min-width: 0; font-size: 0.85rem; }

.btn-primary, .btn-primary-sm, .btn-touch, .btn-ghost, .btn-danger {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font: inherit;
  cursor: pointer;
  text-align: center;
  display: inline-block;
}

.btn-primary, .btn-primary-sm {
  background: var(--accent);
  color: #0f1419;
  font-weight: 600;
}
.btn-primary-sm { padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.btn-primary:hover, .btn-primary-sm:hover { background: var(--accent-hover); }

.btn-touch {
  background: var(--ok);
  color: #fff;
  white-space: nowrap;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--surface2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  margin-left: auto;
}

.form-stack label { display: block; margin: 0.75rem 0 0.25rem; color: var(--muted); font-size: 0.9rem; }
.form-stack input, .form-stack select, .form-stack textarea { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; align-items: center; }

.empty { color: var(--muted); text-align: center; padding: 2rem; }

.bookmarklet-help {
  margin-top: 2.5rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.bookmarklet-help h3 { margin-top: 0; font-size: 1rem; }
.bookmarklet {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--surface2);
  border-radius: 8px;
  font-weight: 600;
  cursor: grab;
}
.hint { color: var(--muted); font-size: 0.85rem; }

.muted { color: var(--muted) !important; }

.form-drop-url {
  position: relative;
  border: 2px dashed var(--surface2);
  border-radius: 8px;
  padding: 0.25rem;
  transition: border-color 0.15s, background 0.15s;
}

.form-drop-url.drag-over {
  border-color: var(--ok);
  background: rgba(61, 154, 106, 0.08);
}

.form-drop-url input {
  border: none;
  background: transparent;
  width: 100%;
}

.form-drop-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.5rem 0.35rem;
  pointer-events: none;
}

.form-url-preview {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.form-url-preview a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.book-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: 90vw;
  text-align: center;
}

.book-toast-ok {
  background: var(--ok);
  color: #fff;
}

.book-toast-error {
  background: var(--error);
  color: #fff;
}

.book-toast[hidden] {
  display: none;
}

@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
  .item-actions { width: 100%; }
}
