/* MovieTracker UI — Enhanced CSS v2.0.0
   - Smooth animations
   - Improved accessibility
   - Better mobile experience
   - Loading states
   - Enhanced visual effects
*/

/* ===== CSS VARIABLES ===== */
:root {
  /* UI Scale */
  --ui-scale: 1.0;
  
  /* Core Colors */
  --c-bg: #f6f7fb;
  --c-bg-2: #eef2ff;
  --c-surface: rgba(255,255,255,.86);
  --c-surface-2: rgba(255,255,255,.96);
  --c-border: rgba(15,23,42,.12);
  --c-text: #0f172a;
  --c-muted: rgba(15,23,42,.68);
  --c-muted-2: rgba(15,23,42,.46);
  
  --c-primary: #4f46e5;
  --c-primary-2: #7c3aed;
  --c-success: #16a34a;
  --c-danger: #dc2626;
  --c-warning: #f59e0b;
  
  /* Radii */
  --r-xl: 22px;
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;
  
  /* Shadows */
  --sh-xs: 0 1px 0 rgba(15,23,42,.04);
  --sh-sm: 0 1px 2px rgba(15,23,42,.08), 0 8px 18px rgba(15,23,42,.06);
  --sh-md: 0 10px 30px rgba(15,23,42,.10);
  
  /* Focus */
  --ring: 0 0 0 4px rgba(79,70,229,.22);
  
  /* Glow */
  --glow-1: rgba(99,102,241,.22);
  --glow-2: rgba(124,58,237,.18);
  --glow-3: rgba(34,197,94,.14);
  
  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Bottom nav height */
  --bottom-nav-h: 0px;
}

/* Dark theme */
html[data-theme="dark"] {
  --c-bg: #0b1220;
  --c-bg-2: #0b1626;
  --c-surface: rgba(15,23,42,.78);
  --c-surface-2: rgba(15,23,42,.92);
  --c-border: rgba(226,232,240,.12);
  --c-text: #e5e7eb;
  --c-muted: rgba(226,232,240,.70);
  --c-muted-2: rgba(226,232,240,.48);
  
  --c-primary: #6366f1;
  --c-primary-2: #a855f7;
  
  --sh-xs: 0 1px 0 rgba(0,0,0,.25);
  --sh-sm: 0 2px 10px rgba(0,0,0,.35);
  --sh-md: 0 24px 60px rgba(0,0,0,.55);
  
  --ring: 0 0 0 4px rgba(99,102,241,.28);
  
  --glow-1: rgba(99,102,241,.14);
  --glow-2: rgba(168,85,247,.12);
  --glow-3: rgba(34,197,94,.10);
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html {
  zoom: var(--ui-scale);
}

@supports not (zoom: 1) {
  html { zoom: 1; }
  body { overflow-x: hidden; }
  .app-root { 
    transform: scale(var(--ui-scale)); 
    transform-origin: top left; 
    width: calc(100% / var(--ui-scale)); 
  }
  .toasts { 
    transform: scale(var(--ui-scale)); 
    transform-origin: bottom right; 
  }
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--c-text);
  background:
    radial-gradient(1100px 520px at 10% 5%, var(--glow-2), transparent 60%),
    radial-gradient(900px 520px at 90% 15%, var(--glow-1), transparent 60%),
    radial-gradient(900px 520px at 35% 95%, var(--glow-3), transparent 60%),
    linear-gradient(180deg, var(--c-bg), var(--c-bg-2));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

::selection { background: rgba(99,102,241,.26); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== LAYOUT ===== */
.app-root { min-height: 100vh; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.view { padding-top: 14px; }

.glass {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
  transition: box-shadow 0.3s var(--ease-in-out), transform 0.2s var(--ease-out);
}

.glass:hover {
  box-shadow: var(--sh-sm), 0 20px 40px rgba(15,23,42,.08);
}

@supports (backdrop-filter: blur(12px)) {
  .glass { backdrop-filter: blur(12px); }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 14px 30px rgba(99,102,241,.22); }
  50% { box-shadow: 0 14px 40px rgba(99,102,241,.35); }
}

@keyframes glow {
  from { box-shadow: 0 4px 15px rgba(79,70,229,.3); }
  to { box-shadow: 0 4px 25px rgba(79,70,229,.5); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes selectPop {
  50% { transform: scale(1.1); }
}

@keyframes cardEnter {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes countUpdate {
  50% { transform: scale(1.3); color: var(--c-primary); }
}

@keyframes toastEnter {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

@keyframes fillBar {
  from { width: 0; }
}

@keyframes growUp {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes dialogEnter {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes backdropEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 70%, transparent);
  animation: slideDown 0.5s var(--ease-out);
}

@supports (backdrop-filter: blur(12px)) {
  .topbar { backdrop-filter: blur(12px); }
}

.topbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.brand__logo {
  display: grid;
  place-items: center;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  box-shadow: 0 14px 30px rgba(99,102,241,.22);
  flex: 0 0 auto;
  animation: pulse 2s var(--ease-in-out) infinite;
  font-size: 20px;
}

.brand__title { line-height: 1.25; }
.brand__title b { display: block; font-size: 15px; letter-spacing: -0.025em; }
.brand__title span { color: var(--c-muted); font-size: 12px; }

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 75%, transparent);
  color: var(--c-muted);
  box-shadow: var(--sh-xs);
  cursor: pointer;
}

.nav__pill:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
  background: color-mix(in srgb, var(--c-surface-2) 90%, transparent);
}

.nav__pill[aria-current="page"] {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  border-color: transparent;
  color: white;
  animation: glow 1.5s var(--ease-in-out) infinite alternate;
}

.nav__pill[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  box-shadow: var(--sh-sm);
  transition: transform 0.2s var(--ease-out);
}

.avatar:hover {
  transform: scale(1.1);
}

.userbar__name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-lg);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 80%, transparent);
  color: var(--c-text);
  box-shadow: var(--sh-xs);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn:hover::after {
  transform: translateX(100%);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn--solid {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  border-color: transparent;
  color: white;
}

.btn--primary {
  background: var(--c-primary);
  border-color: transparent;
  color: white;
}

.btn--danger {
  background: var(--c-danger);
  border-color: transparent;
  color: white;
}

.btn--ghost {
  background: transparent;
  color: var(--c-text);
}

/* Loading button */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 80%, transparent);
  box-shadow: var(--sh-xs);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.icon-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--sh-sm);
}

.icon-btn--danger {
  background: color-mix(in srgb, var(--c-danger) 18%, var(--c-surface-2));
}

/* ===== INPUTS ===== */
.input, .select, .textarea {
  width: 100%;
  border-radius: var(--r-lg);
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 88%, transparent);
  color: var(--c-text);
  box-shadow: var(--sh-xs);
  transition: all 0.2s var(--ease-out);
}

.input:hover, .select:hover, .textarea:hover {
  border-color: color-mix(in srgb, var(--c-primary) 50%, var(--c-border));
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: var(--ring);
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input::placeholder {
  color: var(--c-muted-2);
}

.label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-muted);
}

.field {
  display: grid;
  gap: 8px;
}

.grid {
  display: grid;
  gap: 12px;
}

.hr {
  height: 1px;
  background: var(--c-border);
  margin: 14px 0;
}

.helper {
  color: var(--c-muted);
  font-size: 12px;
  line-height: 1.45;
}

.muted { color: var(--c-muted); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 80%, transparent);
}

/* ===== AUTH ===== */
.auth-wrap {
  min-height: calc(100vh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 18px;
  animation: fadeInUp 0.6s var(--ease-out);
}

.auth-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px;
}

.auth-card p {
  margin: 0;
  color: var(--c-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 10px 0 14px;
}

.auth-tab {
  border-radius: var(--r-lg);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 82%, transparent);
  color: var(--c-muted);
  cursor: pointer;
}

.auth-tab:hover {
  background: color-mix(in srgb, var(--c-surface-2) 95%, transparent);
}

.auth-tab[aria-current="page"] {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  border-color: transparent;
  color: white;
}

/* ===== FILTERS ===== */
.filters { padding: 12px; }

.filters__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filters__grow { flex: 1 1 320px; }

.search { position: relative; }

.search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.75;
}

.search .input { padding-left: 34px; }

.search__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 88%, transparent);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.search__clear:hover {
  background: var(--c-danger);
  color: white;
}

.filters__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  margin-left: 8px;
  background: color-mix(in srgb, var(--c-primary) 20%, transparent);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  animation: bounce 0.3s var(--ease-out);
}

.filters__panel {
  margin-top: 12px;
  animation: slideDown 0.3s var(--ease-out);
}

.filters__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

@media (max-width: 720px) {
  .filters__grid { grid-template-columns: 1fr; }
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 82%, transparent);
  color: var(--c-muted);
  cursor: pointer;
}

.chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-xs);
}

.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--c-primary) 20%, transparent);
  color: var(--c-text);
  border-color: color-mix(in srgb, var(--c-primary) 50%, var(--c-border));
  animation: selectPop 0.2s var(--ease-out);
}

/* Color picker */
.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  border: 2px solid color-mix(in srgb, var(--c-surface-2) 50%, var(--c-border));
  box-shadow: 0 6px 14px rgba(15,23,42,.10);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.color:hover {
  transform: translateY(-2px) scale(1.1);
  box-shadow: var(--sh-sm);
}

.color[aria-pressed="true"] {
  border-color: white;
  box-shadow: 0 0 0 3px var(--c-primary), var(--sh-sm);
  animation: selectPop 0.2s var(--ease-out);
}

/* Mobile segment */
.mobile-segment { display: none; }

.segment-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: var(--r-lg);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 84%, transparent);
  color: var(--c-muted);
  box-shadow: var(--sh-xs);
  cursor: pointer;
}

.segment-btn:hover {
  transform: translateY(-1px);
}

.segment-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  border-color: transparent;
  color: white;
  animation: glow 1.5s var(--ease-in-out) infinite alternate;
}

.segment-btn span {
  font-size: 12px;
  font-weight: 700;
  border-radius: 9999px;
  padding: 2px 8px;
  background: rgba(255,255,255,.18);
}

/* ===== BOARD ===== */
.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.column {
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 55%, transparent);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  min-height: 420px;
  transition: box-shadow 0.3s var(--ease-in-out);
  animation: fadeIn 0.5s var(--ease-out);
  animation-fill-mode: both;
}

.column:nth-child(1) { animation-delay: 0s; }
.column:nth-child(2) { animation-delay: 0.1s; }
.column:nth-child(3) { animation-delay: 0.2s; }

.column:hover {
  box-shadow: var(--sh-md);
}

.column__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 80%, transparent);
}

.column__title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.column__title b {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.column__title small {
  display: block;
  font-size: 12px;
  color: var(--c-muted);
}

.col-icon {
  display: grid;
  place-items: center;
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 85%, transparent);
  transition: transform 0.2s var(--ease-out);
}

.col-icon:hover {
  transform: scale(1.1) rotate(5deg);
}

.col-icon--want { box-shadow: inset 0 0 0 9999px rgba(79,70,229,.10); }
.col-icon--watching { box-shadow: inset 0 0 0 9999px rgba(245,158,11,.12); }
.col-icon--watched { box-shadow: inset 0 0 0 9999px rgba(22,163,74,.12); }

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 86%, transparent);
  transition: all 0.2s var(--ease-out);
}

.count-pill.updated {
  animation: countUpdate 0.3s var(--ease-out);
}

.column__list {
  padding: 12px;
  display: grid;
  gap: 12px;
  min-height: 100px;
}

.column__list.drag-over {
  background: color-mix(in srgb, var(--c-primary) 5%, transparent);
  border-radius: var(--r-lg);
}

.empty {
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  border: 1px dashed color-mix(in srgb, var(--c-border) 80%, transparent);
  color: var(--c-muted);
  background: color-mix(in srgb, var(--c-surface-2) 65%, transparent);
  transition: all 0.3s var(--ease-out);
}

.empty:hover {
  border-color: var(--c-primary);
  background: color-mix(in srgb, var(--c-primary) 5%, transparent);
}

/* ===== CARDS ===== */
.card {
  position: relative;
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-xl);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 88%, transparent);
  box-shadow: var(--sh-xs);
  transition: all 0.2s var(--ease-out);
  animation: cardEnter 0.3s var(--ease-out);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-sm);
}

.card.dragging {
  opacity: 0.5;
  transform: scale(0.95) rotate(2deg);
  cursor: grabbing;
}

.card__accent {
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 5px;
  border-radius: 9999px;
  transition: all 0.2s var(--ease-out);
}

.card:hover .card__accent {
  top: 6px;
  bottom: 6px;
}

.poster {
  width: 86px;
  height: 124px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: color-mix(in srgb, var(--c-surface) 70%, transparent);
  border: 1px solid var(--c-border);
  display: grid;
  place-items: center;
  transition: transform 0.3s var(--ease-out);
}

.card:hover .poster {
  transform: scale(1.03);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__main { min-width: 0; }

.card__title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 4px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 55%, transparent);
  color: var(--c-text);
  transition: all 0.2s var(--ease-out);
}

.badge:hover {
  transform: translateY(-1px);
}

.badge--soft { color: var(--c-muted); }
.badge--want { box-shadow: inset 0 0 0 9999px rgba(79,70,229,.12); }
.badge--watching { box-shadow: inset 0 0 0 9999px rgba(245,158,11,.14); }
.badge--watched { box-shadow: inset 0 0 0 9999px rgba(22,163,74,.14); }

.stars {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.star {
  font-size: 16px;
  line-height: 1;
  transition: all 0.2s var(--ease-out);
  color: rgba(148,163,184,.65);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.star[aria-pressed="true"] {
  color: #f59e0b;
}

.star:hover {
  transform: translateY(-2px) scale(1.1);
  color: #f59e0b;
}

.rewatch {
  margin-top: 8px;
  font-size: 12px;
  color: var(--c-muted);
}

.card__note {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 55%, transparent);
  font-size: 12px;
  color: var(--c-text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  transition: all 0.2s var(--ease-out);
}

.card__note:hover {
  -webkit-line-clamp: unset;
}

.card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card__mobile-move { display: none; }

.movebtn {
  width: 100%;
  border-radius: var(--r-lg);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 84%, transparent);
  color: var(--c-text);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.movebtn:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-xs);
}

/* ===== DIALOG ===== */
dialog {
  border: none;
  padding: 0;
  background: transparent;
  width: min(980px, calc(100% - 24px));
  border-radius: var(--r-xl);
  animation: dialogEnter 0.3s var(--ease-out);
}

dialog::backdrop {
  background: rgba(2,6,23,.45);
  animation: backdropEnter 0.3s var(--ease-out);
}

@supports (backdrop-filter: blur(10px)) {
  dialog::backdrop { backdrop-filter: blur(10px); }
}

.modal {
  width: 100%;
  max-height: min(82vh, 860px);
  overflow: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
}

.modal__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 740px) {
  .modal__grid { grid-template-columns: 1fr; }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--c-border);
}

.modal__body { padding: 14px; }

.modal__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--c-border);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs button {
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 82%, transparent);
  color: var(--c-muted);
  cursor: pointer;
}

.tabs button:hover {
  background: color-mix(in srgb, var(--c-surface-2) 95%, transparent);
}

.tabs button[aria-current="page"] {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  border-color: transparent;
  color: white;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 60%, transparent);
  border-radius: var(--r-xl);
  padding: 12px;
  box-shadow: var(--sh-xs);
  transition: all 0.3s var(--ease-out);
  animation: fadeIn 0.5s var(--ease-out);
  animation-fill-mode: both;
}

.stat:nth-child(1) { animation-delay: 0s; }
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }

.stat:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-sm);
}

.stat__icon {
  display: grid;
  place-items: center;
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 85%, transparent);
  transition: transform 0.3s var(--ease-out);
}

.stat:hover .stat__icon {
  transform: scale(1.1) rotate(5deg);
}

.stat__icon--want { box-shadow: inset 0 0 0 9999px rgba(79,70,229,.10); }
.stat__icon--watching { box-shadow: inset 0 0 0 9999px rgba(245,158,11,.12); }
.stat__icon--watched { box-shadow: inset 0 0 0 9999px rgba(22,163,74,.12); }
.stat__icon--rating { box-shadow: inset 0 0 0 9999px rgba(245,158,11,.12); }

.stat__value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.stat__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-muted);
  margin-top: 4px;
}

.panel {
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 65%, transparent);
  border-radius: var(--r-xl);
  padding: 14px;
  box-shadow: var(--sh-xs);
  transition: all 0.3s var(--ease-out);
  animation: fadeIn 0.4s var(--ease-out);
}

.panel:hover {
  box-shadow: var(--sh-sm);
}

.panel h3 { margin: 0 0 10px; font-size: 15px; }

.kv { display: grid; gap: 8px; }

.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: var(--c-muted);
}

.kv-row span:last-child {
  color: var(--c-text);
  font-weight: 700;
}

.bars { display: grid; gap: 12px; }
.bar { display: grid; gap: 8px; }

.bar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  color: var(--c-muted);
}

.bar__track {
  height: 10px;
  border-radius: 9999px;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 75%, transparent);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  animation: fillBar 0.8s var(--ease-out);
  animation-fill-mode: both;
}

.months {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.month {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 34px;
}

.month__bar {
  width: 100%;
  border-radius: 9999px;
  background: linear-gradient(180deg, var(--c-primary), var(--c-primary-2));
  opacity: 0.85;
  animation: growUp 0.5s var(--ease-out);
  animation-fill-mode: both;
  transform-origin: bottom;
}

.month__bar:hover { opacity: 1; }

.month__lab {
  font-size: 11px;
  color: var(--c-muted);
}

.stats-details {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--c-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: color-mix(in srgb, var(--c-surface-2) 85%, transparent);
}

.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  font-size: 13px;
}

.table th {
  font-size: 12px;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table tr {
  transition: background 0.2s var(--ease-out);
}

.table tr:hover {
  background: color-mix(in srgb, var(--c-primary) 5%, transparent);
}

/* ===== FAMILY ===== */
.family-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 1600px) {
  .family-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1020px) {
  .family-grid { grid-template-columns: 1fr; }
}

.family-card {
  position: relative;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 86%, transparent);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-xs);
  display: flex;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  transition: all 0.3s var(--ease-out);
  animation: cardEnter 0.4s var(--ease-out);
  animation-fill-mode: both;
}

.family-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-sm);
}

.family-card__poster {
  width: 118px;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 70%, transparent);
  display: grid;
  place-items: center;
  flex: none;
  transition: transform 0.3s var(--ease-out);
}

.family-card:hover .family-card__poster {
  transform: scale(1.03);
}

.family-card__poster img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.family-card__poster-fallback {
  font-size: 42px;
  color: color-mix(in srgb, var(--c-muted) 70%, transparent);
}

.family-card__bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.family-card__badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.family-card__body {
  padding: 0;
  min-width: 0;
  flex: 1;
}

.family-card__title {
  font-weight: 800;
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.family-card__meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--c-muted);
}

.memberlist {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 60%, transparent);
}

.memberlist__text {
  font-size: 12px;
  color: var(--c-muted);
}

.memberlist__avatars {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.memberlist__more {
  font-size: 12px;
  color: var(--c-muted);
}

.family-actions {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface) 60%, transparent);
}

.family-actions__label {
  font-size: 12px;
  color: var(--c-muted);
}

.family-actions__row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mini-btn {
  border-radius: var(--r-lg);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  border: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-surface-2) 84%, transparent);
  cursor: pointer;
}

.mini-btn:hover:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: var(--sh-xs);
}

.mini-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== TOASTS ===== */
.toasts {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--bottom-nav-h, 0px));
  display: grid;
  gap: 10px;
  z-index: 100;
}

.toast {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-radius: var(--r-xl);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  box-shadow: var(--sh-sm);
  min-width: 240px;
  animation: toastEnter 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--c-primary);
  animation: toastProgress 3.8s linear forwards;
}

.toast--error::after { background: var(--c-danger); }
.toast--success::after { background: var(--c-success); }
.toast--warn::after { background: var(--c-warning); }

.toast b { display: block; font-size: 13px; }
.toast span { display: block; font-size: 12px; color: var(--c-muted); margin-top: 2px; }

.toast__dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  margin-top: 3px;
  background: var(--c-primary);
}

.toast--error .toast__dot { background: var(--c-danger); }
.toast--success .toast__dot { background: var(--c-success); }
.toast--warn .toast__dot { background: var(--c-warning); }

/* ===== BOTTOM NAV ===== */
.bottom-nav { display: none; }

.bottom-nav__row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--bottom-nav-h, 0px);
}

.bottom-nav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--c-muted);
  width: 33.33%;
  height: 100%;
  transition: all 0.2s var(--ease-out);
  position: relative;
  cursor: pointer;
}

.bottom-nav__btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 40px;
  height: 3px;
  background: var(--c-primary);
  border-radius: 0 0 4px 4px;
  transition: transform 0.2s var(--ease-out);
}

.bottom-nav__btn[aria-current="page"] {
  color: var(--c-text);
}

.bottom-nav__btn[aria-current="page"]::before {
  transform: translateX(-50%) scaleX(1);
}

.bottom-nav__btn[aria-disabled="true"] {
  opacity: 0.45;
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--c-surface) 50%, transparent) 25%,
    color-mix(in srgb, var(--c-surface) 70%, transparent) 50%,
    color-mix(in srgb, var(--c-surface) 50%, transparent) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  
  .mobile-segment {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
  }
  
  .column { display: none; }
  .column[data-hidden="false"] { display: block; }
}

@media (max-width: 720px) {
  .nav { display: none; }
  
  .bottom-nav {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    border-top: 1px solid var(--c-border);
    background: color-mix(in srgb, var(--c-surface) 80%, transparent);
    animation: slideUp 0.3s var(--ease-out);
  }
  
  @supports (backdrop-filter: blur(12px)) {
    .bottom-nav { backdrop-filter: blur(12px); }
  }
  
  :root { --bottom-nav-h: 64px; }
  .container { padding-bottom: calc(28px + var(--bottom-nav-h)); }
  
  .board { margin-top: 10px; }
  .card { grid-template-columns: 84px 1fr; }
  .card__actions { display: none; }
  .card__mobile-move { display: grid; gap: 8px; margin-top: 10px; }
  
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .family-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .family-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .userbar__name { display: none; }
}

/* ===== FOCUS VISIBLE ===== */
.input:focus-visible, .select:focus-visible, .textarea:focus-visible,
.btn:focus-visible, .icon-btn:focus-visible, .nav__pill:focus-visible,
.chip:focus-visible, .mini-btn:focus-visible, .movebtn:focus-visible, .star:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
