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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #242836;
  --border: #2a2e3a;
  --text: #e4e6eb;
  --text-muted: #8b8fa3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  width: 100%;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  width: 100%;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

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

.tab--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab--active:hover {
  background: var(--accent-hover);
}

.tab__count {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
}

.tab--active .tab__count {
  background: rgba(255, 255, 255, 0.25);
}

.tab__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  color: inherit;
  font-size: 14px;
  cursor: pointer;
  border-radius: 3px;
  opacity: 0.5;
  line-height: 1;
}

.tab__delete:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.tab--add {
  border-style: dashed;
  color: var(--text-muted);
}

.tab--add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(59, 130, 246, 0.15);
}

/* Content layout: cards left, article list right */
.content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.content__left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 200px);
  grid-auto-rows: 200px;
  gap: 12px;
  padding: 20px 24px;
  align-content: start;
  flex-shrink: 0;
}

.card-slot {
  position: relative;
  height: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  overflow: hidden;
}

.card-slot--wide {
  grid-column: span 2;
}

.card-slot .pos-label {
  font-size: 48px;
  font-weight: 700;
  color: var(--border);
  user-select: none;
  pointer-events: none;
}

.card-slot.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.card-slot.drag-over .pos-label {
  color: var(--accent);
}

.card-slot--filled {
  border: none;
  cursor: grab;
}

.card-slot--filled:active {
  cursor: grabbing;
}

.card-slot--filled .pos-label {
  display: none;
}

/* Card content */
.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.card__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.card__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.1) 100%);
}

.card__no-image {
  position: absolute;
  inset: 0;
  background: var(--surface-hover);
  z-index: 0;
}

.card__no-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 60%);
}

.card__drag-handle {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s;
}

.card-slot:hover .card__drag-handle {
  opacity: 1;
}

.card__color-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.card-slot:hover .card__color-btn {
  opacity: 1;
}

.card__remove-btn {
  position: absolute;
  top: 8px;
  right: 44px;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.card-slot:hover .card__remove-btn {
  opacity: 1;
}

.card__remove-btn:hover {
  background: var(--danger);
}

.card__title {
  position: relative;
  z-index: 2;
  padding: 12px;
  padding-top: 24px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.card__color-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 33%;
  z-index: 1;
  pointer-events: none;
}

/* Article list */
.divider {
  width: 5px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
}

.divider:hover,
.divider.dragging {
  background: var(--accent);
}

.article-list {
  background: var(--surface);
  padding: 12px 8px;
  width: 380px;
  min-width: 250px;
  max-width: 700px;
  flex-shrink: 0;
  overflow-y: auto;
}

.article-list__header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px 8px;
}

.article-list__col--drag {
  width: 20px;
  flex-shrink: 0;
}

.article-list__sort {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  margin-right: 4px;
  transition: all 0.15s;
}

.article-list__sort:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.article-list__sort--active {
  color: var(--accent);
  border-color: var(--accent);
}

.article-list__sort--title {
  margin-left: auto;
}

.article-list__scroll {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.article-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  font-size: 12px;
  transition: all 0.15s;
}

.article-item:active {
  cursor: grabbing;
}

.article-item:hover {
  border-color: var(--text-muted);
}

.article-item.dragging {
  opacity: 0.2;
}

.article-item__drag {
  color: var(--text-muted);
  font-size: 12px;
  width: 20px;
  flex-shrink: 0;
}

.article-item__color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
  margin: 0 14px;
}

.article-item__pos {
  width: 32px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.article-item__edition {
  width: 40px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.article-item__title {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Color picker */
.color-picker {
  position: fixed;
  display: none;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
}

.color-picker.is-open {
  display: flex;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: #fff;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Responsive */
@media (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 12px;
    justify-content: center;
  }

  .card-slot--wide {
    grid-column: span 2;
  }

  .card-slot {
    min-height: 140px;
  }
}
