:root {
  --bg: #0b0e14;
  --surface: #131822;
  --surface-hover: #19202e;
  --surface-elevated: #1c2434;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f5f8;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.14);

  --high: #f43f5e;
  --high-soft: rgba(244, 63, 94, 0.14);
  --medium: #38bdf8;
  --medium-soft: rgba(56, 189, 248, 0.14);
  --low: #94a3b8;
  --low-soft: rgba(148, 163, 184, 0.14);

  --success: #22c55e;
  --danger: #ef4444;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(245, 158, 11, 0.11), transparent 42%),
    radial-gradient(circle at 85% 15%, rgba(56, 189, 248, 0.07), transparent 38%);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-icon {
  font-size: 1.7rem;
  line-height: 1;
}

.title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.list-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-title:hover {
  color: var(--accent-hover);
}

.title-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.title-edit-form input {
  background: var(--surface-elevated);
  border: 1px solid var(--accent);
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  min-width: 200px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.25s;
}

.sync-badge.live .sync-dot {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: pulse 2s infinite;
}

.sync-badge.offline .sync-dot {
  background: var(--danger);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.meta-sep {
  opacity: 0.4;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.1s, color 0.16s;
  white-space: nowrap;
}

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

.btn-sm {
  font-size: 0.8rem;
  padding: 6px 11px;
}

.btn-primary {
  background: var(--accent);
  color: #0b0e14;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--border-strong);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.icon-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

/* Add Card */
.add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-main-row {
  display: flex;
  gap: 10px;
}

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.input::placeholder {
  color: var(--text-dim);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-title {
  font-size: 0.98rem;
  font-weight: 500;
}

.add-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.input-note {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

.priority-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.picker-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 2px;
}

.prio-chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.prio-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.prio-chip.active[data-prio="high"] {
  background: var(--high-soft);
  border-color: var(--high);
  color: #fda4af;
}

.prio-chip.active[data-prio="medium"] {
  background: var(--medium-soft);
  border-color: var(--medium);
  color: #7dd3fc;
}

.prio-chip.active[data-prio="low"] {
  background: var(--low-soft);
  border-color: var(--low);
  color: #cbd5e1;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.progress-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-text-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
}

.stats-text {
  color: var(--text-muted);
  font-weight: 500;
}

.progress-percent {
  color: var(--accent);
  font-weight: 700;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  transition: width 0.3s ease;
}

.toolbar-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.filter-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-tab:hover {
  color: var(--text);
}

.filter-tab.active {
  background: var(--surface-elevated);
  color: var(--text);
}

.drag-hint {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Movie List */
.movie-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.movie-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 12px 12px 8px;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s, transform 0.15s;
}

.movie-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.movie-item.watched {
  opacity: 0.58;
  background: rgba(19, 24, 34, 0.65);
}

.movie-item.dragging {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--accent);
}

.movie-item.drag-over-top {
  box-shadow: 0 -2px 0 0 var(--accent);
}

.movie-item.drag-over-bottom {
  box-shadow: 0 2px 0 0 var(--accent);
}

/* Drag Handle */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 36px;
  color: var(--text-dim);
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  touch-action: none;
}

.drag-handle:hover {
  color: var(--text-muted);
}

.drag-handle:active {
  cursor: grabbing;
}

/* Rank Badge */
.rank-badge {
  min-width: 30px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  flex-shrink: 0;
}

.rank-badge.rank-top {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.movie-item.watched .rank-badge {
  background: transparent;
  color: var(--text-dim);
  border: none;
}

/* Custom Checkbox */
.check-btn {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--border-strong);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: transparent;
  transition: all 0.16s ease;
  padding: 0;
}

.check-btn:hover {
  border-color: var(--accent);
}

.movie-item.watched .check-btn {
  background: var(--success);
  border-color: var(--success);
  color: #052e16;
}

/* Movie Content */
.movie-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.movie-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.movie-title {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.movie-item.watched .movie-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.movie-note {
  font-size: 0.81rem;
  color: var(--text-muted);
  word-break: break-word;
}

/* Priority Pill on Item */
.prio-pill {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s;
  flex-shrink: 0;
}

.prio-pill:hover {
  filter: brightness(1.15);
}

.prio-pill:active {
  transform: scale(0.95);
}

.prio-pill.high {
  background: var(--high-soft);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.3);
}

.prio-pill.medium {
  background: var(--medium-soft);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.25);
}

.prio-pill.low {
  background: var(--low-soft);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.25);
}

/* Item Actions */
.item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 52px 24px;
  background: rgba(19, 24, 34, 0.5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 2.6rem;
  margin-bottom: 10px;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 700;
}

.empty-state p {
  margin: 0 auto;
  max-width: 440px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 620px) {
  .app-shell {
    padding: 18px 12px 72px;
  }

  .header {
    gap: 12px;
  }

  .list-title {
    font-size: 1.3rem;
  }

  .add-main-row {
    flex-direction: column;
  }

  .add-submit-btn {
    width: 100%;
  }

  .movie-item {
    gap: 8px;
    padding: 10px 8px 10px 6px;
  }

  .item-actions {
    gap: 0;
  }

  .icon-btn {
    width: 28px;
    height: 28px;
  }
}
