*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-hover: #f8f8fa;
  --border: #d1d1d6;
  --text: #1c1c1e;
  --text-secondary: #636366;
  --text-muted: #aeaeb2;
  --primary: #007aff;
  --primary-hover: #0066d6;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9500;
  --info: #5ac8fa;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-xl: 0 8px 40px rgba(0,0,0,0.12);
  --glass-bg: rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.25);
  --blur: 20px;

  --color-anime: #ff6b6b;
  --color-serie: #4ecdc4;
  --color-webtoon: #a29bfe;
  --color-film: #fdcb6e;
  --color-video: #e17055;
  --color-livre: #00b894;

  --ease-out: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dark-mode {
  --bg: #1c1c1e;
  --surface: #2c2c32;
  --surface-hover: #36363d;
  --border: #3a3a42;
  --text: #f2f2f7;
  --text-secondary: #98989e;
  --text-muted: #636366;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-xl: 0 8px 40px rgba(0,0,0,0.6);
  --glass-bg: rgba(44,44,50,0.8);
  --glass-border: rgba(255,255,255,0.06);
}

/* Lucide icons */
.lucide {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.15em;
  display: inline-block;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.btn-icon .lucide {
  width: 1.6em;
  height: 1.6em;
}

.modal-close .lucide {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.btn-owner .lucide,
.filters .btn .lucide,
.header-actions .btn .lucide {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.filter-badge .lucide {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
}

.toggle-password .lucide {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
}

.caps-lock-warning .lucide {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
  margin-right: 2px;
}

.cover-placeholder .lucide {
  width: 2.5rem;
  height: 2.5rem;
}

.lock-icon .lucide,
.confirm-icon .lucide {
  width: 2.5rem;
  height: 2.5rem;
}

.favorite-badge .lucide {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header */
header {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--primary), #5856d6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: 50%;
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  min-width: 130px;
  overflow: hidden;
  animation: fadeInDown 0.15s var(--ease-out);
}

.dropdown-menu-left {
  right: auto;
  left: 0;
}

.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  transition: background 0.15s;
  font-family: inherit;
}

.dropdown-menu button:hover {
  background: var(--surface-hover);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu,
.dropdown.open .dropdown-menu {
  display: block;
}

.mobile-menu {
  display: none;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s var(--ease-out);
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 9px 16px;
  font-size: 0.875rem;
}

.btn-label {
  margin-left: 4px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg);
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  flex-wrap: wrap;
  align-items: center;
  position: relative;
}

.filters input,
.filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--text);
  min-width: 0;
  flex: 1 1 auto;
  max-width: 220px;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}

.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.filters input {
  flex: 2 1 200px;
  max-width: 320px;
}

#resetFiltersBtn {
  flex: 0 0 auto;
}

/* Filters toggle (mobile) */
.filters-toggle {
  display: none;
}

.filters-toggle-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filters-chevron {
  transition: transform 0.25s var(--ease-out);
}

.filters-toggle.collapsed .filters-chevron {
  transform: rotate(-180deg);
}

.filters-body {
  display: contents;
}

.filters-body.collapsed {
  display: none;
}

/* Active filter badges */
.active-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 24px 8px;
  margin-top: -4px;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  animation: scaleIn 0.15s var(--ease-spring);
}

.filter-badge button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.filter-badge button:hover {
  opacity: 1;
}

/* Item grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  padding: 0 24px 80px;
}

.items-grid.loading {
  opacity: 0.6;
  pointer-events: none;
}

.item-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
  position: relative;
  animation: fadeInUp 0.3s var(--ease-out) both;
  border: 1px solid var(--border);
}

.item-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: transparent;
}

.item-card .cover {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--bg);
  display: block;
  transition: transform 0.3s var(--ease-out);
}

.item-card:hover .cover {
  transform: scale(1.03);
}

.item-card .cover-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}

.cover-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--border), var(--bg));
  opacity: 0.5;
}

.cover-placeholder .type-icon {
  position: relative;
  z-index: 1;
}

.item-card .card-body {
  padding: 14px;
}

.item-card .card-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card .card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.card-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-secondary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tag-more {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.card-tag.clickable {
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.card-tag.clickable:hover {
  background: var(--primary);
  color: #fff;
}

/* Type accent borders */
.item-card.type-anime { --type-color: var(--color-anime); }
.item-card.type-serie { --type-color: var(--color-serie); }
.item-card.type-webtoon { --type-color: var(--color-webtoon); }
.item-card.type-film { --type-color: var(--color-film); }
.item-card.type-video { --type-color: var(--color-video); }
.item-card.type-livre { --type-color: var(--color-livre); }

.item-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--type-color, var(--primary));
  opacity: 0;
  transition: opacity 0.25s var(--ease-out);
}

.item-card:hover::after {
  opacity: 1;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

.badge-status { background: var(--bg); color: var(--text-secondary); }
.badge-status.en-cours { background: #d4edda; color: #155724; }
.badge-status.termine { background: #cce5ff; color: #004085; }
.badge-status.a-regarder { background: #fff3cd; color: #856404; }

.dark-mode .badge-status.en-cours { background: rgba(52, 199, 89, 0.2); color: #34c759; }
.dark-mode .badge-status.termine { background: rgba(0, 122, 255, 0.2); color: #5ac8fa; }
.dark-mode .badge-status.a-regarder { background: rgba(255, 149, 0, 0.2); color: #ff9500; }

.badge-type {
  color: var(--text-secondary);
  background: var(--bg);
  font-weight: 600;
}

.type-anime .badge-type { color: var(--color-anime); }
.type-serie .badge-type { color: var(--color-serie); }
.type-webtoon .badge-type { color: var(--color-webtoon); }
.type-film .badge-type { color: #d4a017; }
.type-video .badge-type { color: var(--color-video); }
.type-livre .badge-type { color: var(--color-livre); }

.rating-bar {
  width: 100%;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.rating-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--warning), #ffbb33);
  border-radius: 2px;
  transition: width 0.4s var(--ease-out);
}

.favorite-badge {
  color: var(--warning);
  font-size: 0.875rem;
}

/* Owner button */
.btn-owner {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-size: 0.8125rem;
  padding: 9px 12px;
}

.btn-owner:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-owner.active {
  background: var(--success);
  border-color: var(--success);
}

.btn-owner.active:hover {
  opacity: 0.9;
}

.visitor-mode .owner-only {
  display: none !important;
}

.visitor-mode .fab {
  display: none !important;
}

.visitor-mode .item-select {
  display: none !important;
}

.visitor-mode .selection-bar {
  display: none !important;
}

.visitor-mode .item-card {
  cursor: pointer;
}

.visitor-mode .empty-state .sub {
  display: none;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #5856d6);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-out);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.fab:active {
  transform: scale(0.95);
}

.fab-shifted {
  bottom: 64px;
}

/* Toast */
#toastContainer {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-spring);
  pointer-events: auto;
  max-width: 90vw;
  text-align: center;
  white-space: nowrap;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }

.toast.removing {
  animation: toastOut 0.2s var(--ease-out) forwards;
}

.dark-mode .toast:not(.toast-success):not(.toast-error):not(.toast-info):not(.toast-warning) {
  background: var(--surface);
  color: var(--text);
}

/* Skeleton */
.skeleton {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.skeleton .skeleton-cover {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(90deg, var(--bg) 25%, var(--surface-hover) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton .skeleton-body {
  padding: 14px;
}

.skeleton .skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, var(--bg) 25%, var(--surface-hover) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton .skeleton-line:last-child {
  width: 60%;
}

/* ========== Scroll Lock ========== */
body.modal-open {
  overflow: hidden;
}

/* ========== Modal ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease, background 0.3s ease;
}

.dark-mode .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-overlay.closing {
  opacity: 0;
  pointer-events: none;
}

.modal-overlay.active .modal {
  animation: modalIn 0.3s var(--ease-spring);
}

.modal-overlay.closing .modal {
  animation: modalOut 0.2s var(--ease-out) forwards;
}

.modal {
  background: var(--surface);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  transition: background 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: all 0.15s var(--ease-out);
  flex-shrink: 0;
  margin: -4px;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Fill remaining space in item modal */
#itemForm {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.modal label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 16px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal label:first-child {
  margin-top: 0;
}

.modal input[type="text"],
.modal input[type="password"],
.modal input[type="number"],
.modal select,
.modal textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}

.modal input[type="text"]:focus,
.modal input[type="password"]:focus,
.modal input[type="number"]:focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
  background: var(--surface);
}

.modal input[type="text"].input-error,
.modal input[type="password"].input-error,
.modal input[type="number"].input-error,
.modal select.input-error,
.modal textarea.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.modal input[type="file"] {
  font-size: 0.8125rem;
  padding: 8px 0;
}

.modal input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.modal fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 16px;
  transition: border-color 0.15s var(--ease-out);
}

.modal fieldset:last-child {
  margin-bottom: 0;
}

.modal legend {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-row > * {
  flex: 1;
}

.form-row label {
  margin-top: 0;
}

.metadata-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.metadata-row label {
  margin: 0;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.metadata-row input {
  width: 70px;
}

.metadata-timecode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.metadata-timecode input {
  width: 50px;
  text-align: center;
}

.metadata-timecode span {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

#coverPreview img {
  max-width: 140px;
  max-height: 90px;
  border-radius: var(--radius-xs);
  margin-top: 8px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

/* Link entries */
.link-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.link-entry:first-of-type {
  margin-top: 0;
}

.link-entry input[type="text"] {
  flex: 1;
  min-width: 0;
}

.link-entry .link-name {
  max-width: 140px;
}

.link-entry .link-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--danger);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}

.link-entry .link-remove .lucide {
  width: 1em;
  height: 1em;
}

.link-entry .link-remove:hover {
  background: rgba(255, 59, 48, 0.1);
}

#addLinkBtn {
  width: 100%;
  border-style: dashed;
  opacity: 0.7;
  transition: opacity 0.15s;
}

#addLinkBtn:hover {
  opacity: 1;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Confirm modal */
.confirm-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 2.5rem;
}

.confirm-message {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.modal-sm .modal-actions {
  justify-content: center;
  gap: 12px;
}

/* Auth modal */
.modal-auth .modal-header {
  justify-content: center;
  padding-bottom: 4px;
}

.modal-auth-body {
  text-align: center;
  padding-top: 4px;
}

.lock-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.auth-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Password wrapper */
.password-wrapper {
  position: relative;
  margin-bottom: 4px;
}

.password-wrapper label {
  display: block;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.toggle-password {
  position: absolute;
  right: 8px;
  bottom: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s;
  border-radius: 4px;
}

.toggle-password:hover {
  opacity: 1;
  background: var(--surface-hover, rgba(128,128,128,0.1));
}

.eye-icon {
  font-size: 1.1rem;
  display: block;
}

/* Error state */
.auth-error {
  min-height: 20px;
  font-size: 0.75rem;
  color: var(--danger, #e74c3c);
  margin-top: 6px;
  text-align: left;
  line-height: 1.4;
  animation: fadeIn 0.2s ease;
}

.auth-error:empty {
  display: none;
}

.input-error {
  border-color: var(--danger, #e74c3c) !important;
  box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.15) !important;
}

/* Caps lock warning */
.caps-lock-warning {
  font-size: 0.75rem;
  color: var(--warning, #f39c12);
  margin-top: 6px;
  text-align: left;
  animation: fadeIn 0.2s ease;
}

.caps-lock-warning[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-auth-actions {
  justify-content: center;
  gap: 12px;
}

/* Loading spinner on buttons */
.btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  inset: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-secondary.btn-loading::after {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--text);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}



.btn-danger.btn-loading::after {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}

/* Selection */
.item-card {
  position: relative;
}

.item-select {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  z-index: 2;
  cursor: pointer;
  accent-color: var(--primary);
  opacity: 0;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-spring);
}

.item-card:hover .item-select,
.item-select:checked {
  opacity: 1;
  transform: scale(1);
}

.item-select:not(:checked) {
  transform: scale(0.8);
}

.item-card.selected {
  box-shadow: 0 0 0 2px var(--primary), var(--shadow-lg);
}

.selection-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-top: 1px solid var(--glass-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  transition: background 0.3s var(--ease-out);
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
  color: var(--text);
}

.select-all-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.selection-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Inline form */
.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--bg);
  color: var(--text);
}

#folderList, #tagList {
  list-style: none;
  margin-top: 8px;
}

#folderList li, #tagList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

#folderList li:last-child, #tagList li:last-child {
  border-bottom: none;
}

#folderList li span, #tagList li span {
  font-weight: 500;
}

#folderList li button, #tagList li button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.15s;
}

#folderList li button:hover, #tagList li button:hover {
  background: rgba(255, 59, 48, 0.1);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-weight: 500;
  font-size: 0.8125rem;
  background: var(--bg);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  user-select: none;
  text-transform: none;
  letter-spacing: normal;
}

.checkbox-group label:hover {
  background: var(--border);
}

.checkbox-group label:has(input:checked) {
  background: var(--primary);
  color: #fff;
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .emoji {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
}

.empty-state p {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-state .sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 24px 32px;
  flex-wrap: wrap;
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.pagination .page-btn {
  min-width: 36px;
  text-align: center;
}

.pagination .page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination .page-btn.active:hover {
  background: var(--primary-hover);
}

.pagination .page-ellipsis {
  padding: 4px 8px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  user-select: none;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(4px);
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(100%);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Responsive */
@media (max-width: 600px) {
  header {
    padding: 8px 12px;
  }

  header h1 {
    font-size: 1rem;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn-sm {
    padding: 6px 8px;
    font-size: 0.8125rem;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }

  .header-actions .btn .btn-label {
    display: none;
  }

  .header-actions .btn {
    min-width: 34px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn-owner {
    padding: 6px 8px;
  }

  /* Mobile menu burger */
  .mobile-menu {
    display: block;
  }

  #foldersBtn,
  #tagsBtn,
  .export-dropdown {
    display: none !important;
  }

  .mobile-menu .dropdown-menu {
    left: auto;
    right: 0;
    min-width: 180px;
  }

  /* Dropdown */
  .dropdown-menu {
    min-width: 140px;
  }

  /* Filters toggle */
  .filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    grid-column: 1 / -1;
    transition: border-color 0.15s var(--ease-out);
  }

  .filters-toggle:hover {
    border-color: var(--text-muted);
  }

  .filters-body.collapsed {
    display: none;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px 12px;
    align-items: center;
  }

  #searchInput {
    grid-column: 1 / -1;
  }

  .filters input,
  .filters select {
    max-width: none;
    width: 100%;
    padding: 8px 10px;
    font-size: 0.8125rem;
  }

  #resetFiltersBtn,
  #sortDirBtn {
    width: 100%;
    padding: 8px 10px;
    min-height: 36px;
  }

  .active-filters {
    padding: 0 12px 6px;
  }

  .items-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0 12px 72px;
  }

  .item-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    transform: none !important;
  }

  .item-card .cover {
    width: 80px;
    aspect-ratio: auto;
    object-fit: cover;
    flex-shrink: 0;
    align-self: stretch;
    transform: none !important;
  }

  .item-card .cover-placeholder {
    width: 80px;
    aspect-ratio: auto;
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  .item-card .card-body {
    padding: 10px;
    flex: 1;
    min-width: 0;
  }

  .item-card::after {
    width: 3px;
    height: 100%;
    top: 0;
    left: 0;
    right: auto;
  }

  .item-card .card-tags {
    margin-top: 3px;
  }

  .item-card .rating-bar {
    margin-top: 4px;
    height: 3px;
  }

  /* Modal item — plein écran */
  #itemModal.modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  #itemModal .modal {
    margin: 0;
    max-width: 100%;
    max-height: 100vh;
    height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  #itemModal.modal-overlay.active .modal {
    animation: modalSlideUp 0.3s var(--ease-spring);
  }

  #itemModal.modal-overlay.closing .modal {
    animation: modalSlideDown 0.2s var(--ease-out) forwards;
  }

  .modal {
    margin: 8px;
    max-height: 90vh;
  }

  .modal-header {
    padding: 14px 16px 0;
  }

  .modal-body {
    padding: 14px 16px 0;
  }

  .modal-actions {
    padding: 10px 16px 14px;
    gap: 6px;
  }

  .modal-actions .btn {
    padding: 10px 14px;
    font-size: 0.8125rem;
    min-height: 44px;
  }

  .form-row {
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
  }

  .modal fieldset {
    padding: 10px;
    margin-top: 12px;
  }

  .metadata-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .metadata-row input {
    width: 100%;
  }

  .metadata-timecode input {
    width: 50px;
  }

  .link-entry {
    flex-wrap: wrap;
    gap: 4px;
  }

  .link-entry .link-name {
    max-width: none;
    flex: 1 1 100%;
  }

  .link-entry input[type="text"] {
    flex: 1;
    min-width: 0;
  }

  #coverPreview img {
    max-width: 100px;
    max-height: 70px;
  }

  .checkbox-group label {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .modal-sm .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-sm .modal-actions .btn {
    min-height: 44px;
  }

  /* FAB */
  .fab {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
    bottom: 16px;
    right: 16px;
  }

  .fab-shifted {
    bottom: 76px;
  }

  /* Selection bar */
  .selection-bar {
    padding: 10px 12px;
  }

  .selection-bar .btn {
    padding: 8px 12px;
    font-size: 0.8125rem;
    min-height: 36px;
  }

  .select-all-label {
    font-size: 0.8125rem;
  }

  /* Pagination */
  .pagination {
    gap: 3px;
    padding: 10px 12px 20px;
  }

  .pagination .btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
    min-width: 32px;
    min-height: 32px;
  }

  /* Empty state */
  .empty-state {
    padding: 40px 16px;
  }

  .empty-state .emoji {
    font-size: 3rem;
  }

  .empty-state p {
    font-size: 1rem;
  }

  /* Toast */
  #toastContainer {
    bottom: 72px;
    left: 12px;
    right: 12px;
    transform: none;
  }

  .toast {
    max-width: 100%;
    white-space: normal;
    font-size: 0.8125rem;
    padding: 10px 16px;
  }

  /* Skeleton */
  .skeleton {
    display: flex;
    flex-direction: row;
    align-items: stretch;
  }

  .skeleton .skeleton-cover {
    width: 80px;
    aspect-ratio: auto;
    align-self: stretch;
    flex-shrink: 0;
  }

  .skeleton .skeleton-body {
    padding: 10px;
    flex: 1;
  }
}

@media (max-width: 400px) {
  header h1 {
    font-size: 0.9rem;
  }

  .header-actions .btn-sm {
    padding: 5px 6px;
    font-size: 0.75rem;
  }

  .filters {
    gap: 4px;
    padding: 8px 8px;
  }

  .filters input,
  .filters select {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .items-grid {
    gap: 8px;
    padding: 0 8px 72px;
  }

  .modal-header h2 {
    font-size: 1.1rem;
  }
}
