:root {
  --bg: #0f1428;
  --bg-2: #161b35;
  --sidebar: #0b0f21;
  --panel: #ffffff;
  --panel-soft: #f6f8ff;
  --border: #1f2847;
  --border-soft: #e1e6f5;
  --text: #ffffff;
  --text-dark: #1a1f3a;
  --muted: #8991b3;
  --muted-dark: #5e6480;
  --yellow: #ffcb05;
  --yellow-dark: #d4a400;
  --blue: #3d7dca;
  --blue-dark: #2a5fa0;
  --red: #ee1515;
  --red-dark: #c41111;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  font-weight: 400;
}

body {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(
      circle at 25% 15%,
      rgba(61, 125, 202, 0.18) 0,
      transparent 45%
    ),
    radial-gradient(
      circle at 85% 80%,
      rgba(255, 203, 5, 0.1) 0,
      transparent 50%
    );
}

/* Sidebar */
.sidebar {
  background: var(--sidebar);
  border-right: 3px solid var(--yellow);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--yellow), var(--blue));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.pokeball {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(238, 21, 21, 0.4));
  animation: wobble 3s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.brand h1 {
  font-family: "Bungee", "Inter", sans-serif;
  font-size: 18px;
  margin: 0;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--yellow), #ffe066);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.new-list {
  display: flex;
  gap: 8px;
}

.new-list input {
  flex: 1;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.new-list input::placeholder {
  color: var(--muted);
}

.new-list input:focus {
  border-color: var(--yellow);
  background: rgba(255, 255, 255, 0.1);
}

.new-list button {
  width: 44px;
  background: linear-gradient(180deg, var(--yellow), var(--yellow-dark));
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 #1a1a1a;
  transition: transform 0.05s;
}

.new-list button:hover {
  filter: brightness(1.08);
}

.new-list button:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #1a1a1a;
}

.list-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.list-item.active {
  background: linear-gradient(
    90deg,
    rgba(255, 203, 5, 0.15),
    rgba(61, 125, 202, 0.1)
  );
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(255, 203, 5, 0.15);
}

.list-item .count {
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 800;
  background: var(--yellow);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1.5px solid #1a1a1a;
  min-width: 28px;
  text-align: center;
}

.list-item.drop-target {
  background: rgba(238, 21, 21, 0.15);
  border-color: var(--red);
  transform: scale(1.02);
  box-shadow: 0 0 0 3px rgba(238, 21, 21, 0.25);
}

.sidebar-footer {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.sidebar-footer p {
  margin: 6px 0 0;
}

.ext-link {
  display: block;
  text-align: center;
  padding: 8px 14px;
  background: rgba(255, 203, 5, 0.1);
  border: 1px solid var(--yellow);
  border-radius: 8px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  transition: background 0.15s;
}

.ext-link:hover {
  background: rgba(255, 203, 5, 0.2);
}

/* Main */
.main {
  padding: 28px 36px;
  overflow-y: auto;
  background-image: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.04) 1.5px,
    transparent 1.5px
  );
  background-size: 28px 28px;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--border);
}

.main-header h2 {
  margin: 0;
  font-family: "Bungee", "Inter", sans-serif;
  font-size: 26px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 2px 2px 0 rgba(61, 125, 202, 0.5);
}

.main-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-count {
  color: var(--yellow);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

button.danger {
  background: var(--red);
  color: #fff;
  border: 2px solid #1a1a1a;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 #1a1a1a;
  font-family: inherit;
  transition: transform 0.05s;
}

button.danger:hover {
  background: var(--red-dark);
}

button.danger:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #1a1a1a;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

.card {
  background: var(--panel);
  border: 3px solid #1a1a1a;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.1s;
  cursor: grab;
  box-shadow: 0 4px 0 #1a1a1a, 0 6px 18px rgba(0, 0, 0, 0.45);
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--yellow), var(--red), var(--blue));
  z-index: 2;
}

.card:active {
  cursor: grabbing;
}

.card.dragging {
  opacity: 0.35;
}

.card.dragging * {
  pointer-events: none;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5),
    0 0 0 3px var(--yellow);
  transform-origin: top left;
  will-change: transform;
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.card.drop-before::after,
.card.drop-after::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 0;
  width: 6px;
  background: var(--yellow);
  border: 2px solid #1a1a1a;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(255, 203, 5, 0.6);
  z-index: 3;
  pointer-events: none;
}

.card.drop-before::after {
  left: -12px;
}

.card.drop-after::after {
  right: -12px;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 0 #1a1a1a, 0 12px 24px rgba(255, 203, 5, 0.25);
}

.card-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #ffffff;
  display: block;
  padding: 18px 18px 10px;
  box-sizing: border-box;
}

.card-body {
  padding: 6px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  background: var(--panel);
  color: var(--text-dark);
}

.card-name {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.25;
  color: var(--text-dark);
  font-family: "Inter", sans-serif;
}

.card-meta {
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-meta span {
  background: var(--blue);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  border: 1.5px solid #1a1a1a;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.card-meta span:nth-child(2) {
  background: var(--yellow);
  color: #1a1a1a;
}

.card-meta span:nth-child(3) {
  background: var(--red);
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
}

.card-actions a {
  color: var(--blue-dark);
  font-size: 11px;
  text-decoration: none;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.card-actions a:hover {
  color: var(--red);
  text-decoration: underline;
}

.card-actions button {
  background: transparent;
  color: var(--muted-dark);
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  font-weight: 700;
  border-radius: 6px;
}

.card-actions button:hover {
  color: var(--red);
  background: rgba(238, 21, 21, 0.1);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
}

.empty::before {
  content: "";
  display: block;
  width: 90px;
  height: 90px;
  margin: 0 auto 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='46' fill='%23fff' stroke='%23111' stroke-width='6'/%3E%3Cpath d='M4 50 A46 46 0 0 1 96 50 Z' fill='%23ee1515'/%3E%3Cpath d='M4 50 H96' stroke='%23111' stroke-width='6'/%3E%3Ccircle cx='50' cy='50' r='13' fill='%23fff' stroke='%23111' stroke-width='6'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.85;
  filter: drop-shadow(0 4px 10px rgba(238, 21, 21, 0.3));
}

.empty p:first-of-type {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.empty .hint {
  font-size: 13px;
  margin-top: 4px;
}

/* User section */
.user-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-icon {
  color: var(--yellow);
  font-size: 10px;
}

.username {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.logout-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

.api-key-section {
  margin-top: 10px;
}

.api-key-section summary {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.api-key-section summary:hover {
  color: var(--text);
}

.api-key-display {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.api-key-display code {
  flex: 1;
  font-size: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}

.copy-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--yellow);
  border-color: var(--yellow);
}

.hidden {
  display: none !important;
}
