:root {
  /* ===== Brand tokens (also written inline by js/mode.js on toggle — keep names stable) ===== */
  --bg: #0a0f1a;
  --card: rgba(15, 23, 42, 0.95);
  --card-solid: #0f172a;
  --card-hover: rgba(30, 41, 59, 0.98);
  --accent: #a78bfa;
  --accent2: #c4b5fd;
  --accent-glow: rgba(167, 139, 250, 0.35);
  --text: #e8f4fc;
  --muted: #8ba3b8;
  --border: #a78bfa;
  --border-dim: rgba(167, 139, 250, 0.32);
  --on-accent: #2e1065;
  --fire: #ef4444;
  --water: #3b82f6;
  --wind: #22c55e;
  --earth: #a16207;
  --lightning: #c026d3;
  --none: #64748b;
  --match: #22c55e;
  --mismatch: #ef4444;
  --panel-shadow: 0 8px 32px rgba(0,0,0,0.65), inset 0 0 15px rgba(167,139,250,0.12);

  /* ===== Layout scale (new — pure CSS, not touched by JS) ===== */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.55);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 80px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at top, rgba(167,139,250,0.08) 0%, transparent 55%),
    radial-gradient(ellipse at bottom, rgba(0,0,0,0.55) 0%, transparent 60%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

::selection { background: var(--accent-glow); color: var(--text); }

/* Visible keyboard focus everywhere, on top of any component-specific rules */
:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ===== Header ===== */
header {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(10, 15, 26, 0.92) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-dim);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  padding: 0 var(--space-5);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 640px) {
  header { height: auto; padding: 0.75rem 1rem; }
  .header-right { width: 100%; justify-content: space-between; }
  .credits { font-size: 0.75rem !important; }
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  line-height: 0;
  flex-shrink: 0;
}
.logo-img {
  display: block;
  height: 100px;
  width: auto;
  max-width: min(280px, 52vw);
  object-fit: contain;
  position: absolute;
}
.container { max-width: 1400px; margin: 0 auto; padding: var(--space-6) var(--space-5); }

/* ===== MAIN TWO-COLUMN LAYOUT ===== */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-5);
  align-items: start;
}
.main-left { min-width: 0; }
.main-right {
  position: sticky;
  top: calc(var(--header-h) + var(--space-4));
  max-height: calc(100vh - var(--header-h) - var(--space-6));
  overflow-y: auto;
  padding-right: 0.25rem;
}
.main-right::-webkit-scrollbar { width: 6px; }
.main-right::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: var(--radius-full);
}

.sidebar-title {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4) !important;
  z-index: 1;
}

/* skill panels stack vertically on the right */
#skill-panels {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: stretch;
}
#skill-panels:empty::before {
  content: "Pilih ninja dulu untuk mengatur skill";
  display: block;
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--card);
  border: 2px dashed var(--border-dim);
  border-radius: var(--radius-md);
}
.skill-panel {
  width: 100%;
  margin-bottom: 0 !important;
}
/* tighter slots for narrow right column */
.main-right .skill-slot {
  width: 50px;
  height: 50px;
}
.main-right .skill-panel-header img {
  width: 48px;
  height: 48px;
}
.main-right .skill-panel-header h3 {
  font-size: 0.95rem;
}
.main-right .skill-panel {
  padding: var(--space-4);
}
.main-right .skill-panel-header {
  margin-bottom: var(--space-4);
  gap: 0.65rem;
}

@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .main-right {
    position: static;
    max-height: none;
    order: 2;
  }
  .sidebar-title { position: static; background: none; }
  .main-left { order: 1; }
  .main-right .skill-slot {
    width: 64px;
    height: 64px;
  }
  #skill-panels {
    flex-direction: column;
  }
  .skill-slot .placeholder { padding: 8px; }
}

@media (max-width: 640px) {
  .container { padding: var(--space-5) var(--space-4); }
  .main-right .skill-slot { width: 56px; height: 56px; }
  .lineup-slots { flex-direction: column; }
  .ninja-slot { max-width: none; }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: var(--space-2);
  }
  .item-card img { width: 56px; height: 56px; }
  .logo-img {
    height: 70px;
    max-width: min(240px, 58vw);
    position: relative;
    top: 65px;
    margin-top: -70px;
  }
  .skill-slot .placeholder { padding: 4px; }
}

/* ===== Step eyebrow labels (workflow really is 2 sequential steps) ===== */
.section-title, .sidebar-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.section-title::before, .sidebar-title::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}
#ninja-section .section-title::before { content: '1'; }
.sidebar-title::before { content: '2'; }
.section-title .hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

/* ===== Lineup bar (top toolbar / dashboard card) ===== */
.lineup-bar {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(10, 15, 26, 0.95) 100%);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  box-shadow: var(--panel-shadow);
}
.lineup-bar h2 {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-4);
  font-weight: 700;
}
.lineup-slots {
  display: flex;
  gap: var(--space-4);
  align-items: stretch;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.ninja-slot {
  flex: 1; min-width: 180px; max-width: 280px;
  background: rgba(10, 15, 26, 0.85);
  border: 2px dashed var(--border-dim);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  cursor: pointer; transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease); position: relative;
}
.ninja-slot:hover { border-color: var(--accent); background: rgba(30, 41, 59, 0.95); transform: translateY(-2px); }
.ninja-slot.active { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.ninja-slot.filled { border-style: solid; border-color: var(--accent2); box-shadow: 0 0 14px var(--accent-glow); }
.ninja-slot .slot-num {
  position: absolute; top: 6px; left: 8px;
  font-size: 0.7rem; font-weight: 700; color: var(--muted);
  background: var(--card); padding: 0.1rem 0.4rem; border-radius: var(--radius-sm);
}
.ninja-slot .remove-ninja {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #ef4444; color: white; border: none; font-size: 0.85rem;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  line-height: 1; z-index: 2; transition: transform 0.15s var(--ease);
}
.ninja-slot .remove-ninja:hover { transform: scale(1.1); }
.ninja-slot.filled:hover .remove-ninja { display: flex; }
.ninja-slot img { width: 72px; height: 72px; object-fit: contain; border-radius: var(--radius-sm); background: rgba(10, 15, 26, 0.9); }
.ninja-slot .placeholder-icon {
  width: 72px; height: 72px; border-radius: var(--radius-sm); background: rgba(15, 23, 42, 0.9);
  display: flex; justify-content: center;
  font-size: 2rem; color: var(--muted); opacity: 0.5; padding: 8px;
}
.ninja-slot .n-name {
  font-size: 0.85rem; font-weight: 700; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.ninja-slot .n-meta { font-size: 0.72rem; color: var(--muted); }
.add-ninja-hint { font-size: 0.8rem; color: var(--muted); margin-top: var(--space-1); }

.ninja-slot.add-slot {
  border-style: dashed;
  opacity: 0.85;
}
.ninja-slot.add-slot:hover {
  opacity: 1;
  border-color: var(--accent2);
}

/* ===== Rarity tabs — segmented pill control ===== */
.rarity-tabs {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: var(--space-1);
  background: rgba(10, 15, 26, 0.5);
  /* border: 1px solid var(--border-dim); */
  border-radius: var(--radius-sm);
}
.rarity-tab {
  padding: 0.45rem 0.95rem; border-radius: var(--radius-full); border: 1px solid var(--accent);
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.85rem; font-weight: 700; transition: all 0.18s var(--ease);
}
.rarity-tab:hover { background: var(--card-hover); color: var(--text); }
.rarity-tab.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.rarity-tab[data-rarity="UR"].active { background: #00c8ff; border-color: #00c8ff; color: #04202a; }
.rarity-tab[data-rarity="SSS"].active { background: #ff00f7; border-color: #ff00f7; color: #2a0028; }
.rarity-tab[data-rarity="SS"].active { background: #dade03; border-color: #dade03; color: #2a2c00; }
.rarity-tab[data-rarity="S"].active { background: #e00d0d; border-color: #e00d0d; color: #fff; }
.rarity-tab[data-rarity="A"].active { background: #7800c3; border-color: #7800c3; color: #fff; }
.rarity-tab[data-rarity="B"].active { background: #0460eb; border-color: #0460eb; color: #fff; }
.rarity-tab[data-rarity="C"].active { background: #00c714; border-color: #00c714; color: #042a08; }
.rarity-tab[data-rarity="D"].active { background: #3d3d3d; border-color: #3d3d3d; color: #fff; }

/* ===== Search ===== */
.search-box {
  width: 100%; max-width: 320px; padding: 0.65rem 1rem 0.65rem 2.35rem; border-radius: var(--radius-full);
  border: 1px solid var(--border-dim); background: rgba(10, 15, 26, 0.85) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238ba3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 0.85rem center;
  color: var(--text);
  font-size: 0.92rem; margin-bottom: var(--space-4);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.search-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-box::placeholder { color: var(--muted); }

/* ===== Grid & item cards ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-3); margin-bottom: var(--space-5);
}
.item-card {
  background: rgba(15, 23, 42, 0.9); border: 2px solid transparent; border-radius: var(--radius-md);
  padding: var(--space-2); text-align: center; cursor: pointer; transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease); position: relative;
}
.item-card:hover { background: var(--card-hover); transform: translateY(-3px); border-color: var(--border-dim); box-shadow: var(--shadow-sm); }
.item-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.item-card.in-lineup { border-color: var(--accent2); box-shadow: 0 0 10px var(--accent-glow); }
.item-card img {
  width: 72px; height: 72px; object-fit: contain; border-radius: var(--radius-sm);
  background: rgba(10, 15, 26, 0.9); display: block; margin: 0 auto 0.4rem;
}
.item-card .name {
  font-size: 0.72rem; color: var(--muted); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chakra-badge {
  display: inline-block; font-size: 0.65rem; padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm); margin-top: var(--space-1); font-weight: 700;
}
.chakra-Fire { background: rgba(239,68,68,0.22); color: #ef4444; }
.chakra-Water { background: rgba(59,130,246,0.22); color: #3b82f6; }
.chakra-Wind { background: rgba(34,197,94,0.22); color: #22c55e; }
.chakra-Earth { background: rgba(146,64,14,0.25); color: #a16207; }
.chakra-Lightning { background: rgba(168,85,247,0.22); color: #c026d3; }
.chakra-None { background: rgba(100,116,139,0.2); color: #64748b; }

/* ===== Skill panel (sidebar) ===== */
.skill-panel {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(10, 15, 26, 0.95) 100%);
  border-radius: var(--radius-md); padding: var(--space-5);
  margin-bottom: 0; border: 1px solid var(--border-dim); display: none;
  box-shadow: var(--panel-shadow);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.skill-panel.active-panel { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-glow), var(--panel-shadow); }
.skill-panel.visible { display: block; }

.capture-btn {
  margin-left: auto;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent2);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}
.capture-btn:hover {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.capture-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.skill-panel.capturing {
  border-color: var(--accent2) !important;
  box-shadow: 0 0 0 3px var(--accent-glow), var(--panel-shadow);
}

.skill-panel-header {
  display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap;
}
.skill-panel-header img {
  width: 64px; height: 64px; border-radius: var(--radius-sm); background: #0f172a; object-fit: contain;
}
.skill-panel-header h3 { font-size: 1.1rem; font-weight: 800; }
.skill-panel-header .meta { font-size: 0.85rem; color: var(--muted); }
.slots-section h4 {
  font-size: 0.75rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: var(--space-3); font-weight: 700;
}
.slots-row {
  display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-5); align-items: flex-start;
}
.slot-group { display: flex; flex-direction: column; gap: var(--space-1); }
.slot-label { font-size: 0.72rem; color: var(--muted); text-align: center; font-weight: 700; }

.skill-slot {
  width: 76px; height: 76px; border-radius: var(--radius-md); background: rgba(10, 15, 26, 0.9);
  border: 2px dashed var(--border-dim);
  display: flex; justify-content: center;
  cursor: pointer; position: relative; transition: border-color 0.2s var(--ease), background 0.2s var(--ease); overflow: visible;
}
.skill-slot:hover { border-color: var(--accent); background: rgba(30, 41, 59, 0.98); }
.skill-slot.filled { border-style: solid; border-color: var(--accent2); }
.skill-slot img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.skill-slot .placeholder { font-size: 1.6rem; color: var(--muted); opacity: 0.4; display: flex; justify-content: center; width: 100%; }
.skill-slot .remove-btn {
  position: absolute; top: -5px; right: -5px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #ef4444; color: white; font-size: 0.7rem;
  display: none; align-items: center; justify-content: center;
  border: none; cursor: pointer; line-height: 1; z-index: 3;
}
.skill-slot.filled:hover .remove-btn { display: flex; }

.compat-badge {
  position: absolute; top: -5px; left: -5px;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4); pointer-events: none;
}
.compat-badge.match { background: var(--match); color: #fff; }
.compat-badge.mismatch { background: var(--mismatch); color: #fff; }

/* ===== Tooltip ===== */
#tooltip {
  position: fixed; z-index: 9999; max-width: 320px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(10, 15, 26, 0.98) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-4); box-shadow: var(--panel-shadow), var(--shadow-lg);
  pointer-events: none; opacity: 0; transition: opacity 0.15s var(--ease); font-size: 0.85rem;
}
#tooltip.visible { opacity: 1; }
#tooltip .tt-title {
  font-weight: 800; font-size: 0.95rem; margin-bottom: var(--space-2);
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}
#tooltip .tt-row {
  display: flex; justify-content: space-between; gap: var(--space-4);
  padding: 0.2rem 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
#tooltip .tt-row:last-child { border-bottom: none; }
#tooltip .tt-label { color: var(--muted); white-space: nowrap; }
#tooltip .tt-value { text-align: right; font-weight: 600; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6, 9, 16, 0.78);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: var(--space-4);
}
.modal-overlay.open { display: flex; }
.modal {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(10, 15, 26, 0.98) 100%);
  border-radius: var(--radius-lg); width: 100%;
  max-width: 720px; max-height: 85vh;
  display: flex; flex-direction: column; border: 1px solid var(--border-dim);
  box-shadow: var(--panel-shadow), var(--shadow-lg);
}
.modal-header {
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-dim);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 800; }
.modal-close {
  background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1;
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.modal-close:hover { background: var(--card-hover); color: var(--text); }
.modal-body { padding: var(--space-4) var(--space-5) var(--space-5); overflow-y: auto; flex: 1; }
.modal-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.filter-btn {
  padding: 0.32rem 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-dim);
  background: transparent; color: var(--muted); font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s var(--ease);
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.filter-btn[data-rarity="UR"].active { background: #00c8ff; border-color: #00c8ff; color: #04202a; }
.filter-btn[data-rarity="SSS"].active { background: #ff00f7; border-color: #ff00f7; color: #2a0028; }
.filter-btn[data-rarity="SS"].active { background: #dade03; border-color: #dade03; color: #2a2c00; }
.filter-btn[data-rarity="S"].active { background: #e00d0d; border-color: #e00d0d; color: #fff; }
.filter-btn[data-rarity="A"].active { background: #7800c3; border-color: #7800c3; color: #fff; }
.filter-btn[data-rarity="B"].active { background: #0460eb; border-color: #0460eb; color: #fff; }
.filter-btn[data-rarity="C"].active { background: #00c714; border-color: #00c714; color: #042a08; }
.filter-btn[data-rarity="D"].active { background: #3d3d3d; border-color: #3d3d3d; color: #fff; }

.filter-btn[data-chakra="Fire"].active { background: #ef4444; border-color: #ef4444; color: #fff; }
.filter-btn[data-chakra="Water"].active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.filter-btn[data-chakra="Wind"].active { background: #22c55e; border-color: #22c55e; color: #04240f; }
.filter-btn[data-chakra="Earth"].active { background: #a16207; border-color: #a16207; color: #fff; }
.filter-btn[data-chakra="Lightning"].active { background: #c026d3; border-color: #c026d3; color: #fff; }
.filter-btn[data-chakra="None"].active { background: #64748b; border-color: #64748b; color: #fff; }

/* ===== Loading / empty states ===== */
.loading { text-align: center; padding: var(--space-7); color: var(--muted); }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border-dim);
  border-top-color: var(--accent2); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto var(--space-4);
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: var(--space-6); color: var(--muted); }
.item-card.compatible { border-color: rgba(34,197,94,0.45); }
.item-card.incompatible { opacity: 0.42; }

@media (max-width: 640px) {
  .skill-slot { width: 64px; height: 64px; }
  .item-card img { width: 60px; height: 60px; }
  .ninja-slot { min-width: 140px; }
}

/* ===== Mobile / touch: always show remove buttons ===== */
@media (hover: none), (pointer: coarse) {
  .ninja-slot.filled .remove-ninja,
  .skill-slot.filled .remove-btn {
    display: flex !important;
  }
}
@media (max-width: 768px) {
  .ninja-slot.filled .remove-ninja,
  .skill-slot.filled .remove-btn {
    display: flex !important;
  }
}

/* ===== Mode toggle (dark / light) ===== */
.mode-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: rgba(10, 15, 26, 0.85);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.35);
}
html[data-mode="light"] .mode-toggle {
  background: rgba(245, 250, 252, 0.95);
  box-shadow: inset 0 0 8px var(--accent-glow);
}
.mode-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent2), var(--accent));
  box-shadow: 0 2px 6px var(--accent-glow);
  transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
}
.mode-toggle.is-light .mode-toggle-knob {
  transform: translateX(24px);
  background: linear-gradient(145deg, var(--accent2), var(--accent));
}
.mode-toggle-icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  pointer-events: none;
  font-size: 11px;
  opacity: 0.7;
}
.mode-toggle-icons .icon-moon { color: var(--accent2); }
.mode-toggle-icons .icon-sun { color: var(--accent2); }

/* ===== Nav ===== */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  background: rgba(10, 15, 26, 0.5);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-full);
  padding: 3px;
}
.nav-link {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--text);
  background: var(--card-hover);
}
.nav-link.active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.nav-burger {
  display: none;
  width: 40px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  transition: border-color 0.15s var(--ease);
}
.nav-burger:hover { border-color: var(--accent); }

@media (max-width: 720px) {
  .nav-burger { display: inline-flex; }
  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-2);
    background: var(--card);
    margin-top: var(--space-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
  }
  .site-nav.open { display: flex; }
  .nav-link {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    text-align: center;
  }
  .header-right {
    width: 100%;
    justify-content: flex-end;
    gap: var(--space-3);
  }
  .logo-img {
    height: 70px;
    max-width: min(240px, 58vw);
    position: relative;
    top: 85px;
    margin-top: -100px;
  }
}

/* ===== Footer ===== */
.site-footer {
  margin-top: var(--space-7);
  position: relative;
  border-top: 1px solid var(--border-dim);
  background: linear-gradient(180deg, rgba(167,139,250,0.03) 0%, rgba(167,139,250,0.08) 100%);
  padding: var(--space-7) var(--space-5) var(--space-5);
  overflow: hidden;
}
.site-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: min(320px, 60%);
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent2), transparent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr;
  gap: var(--space-6) var(--space-6);
  align-items: start;
}
.footer-brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  margin-top: -35px;
  /* margin-bottom: var(--space-2); */
}
.footer-logo { height: 120px; width: auto; }
.footer-brand span { color: var(--accent2); }
.footer-tagline {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 280px;
}
.footer-col-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent2);
  margin-bottom: var(--space-3);
}
.footer-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: color 0.15s var(--ease), transform 0.15s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.footer-links a::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-dim);
  transition: background 0.15s var(--ease);
}
.footer-links a:hover { color: var(--accent2); transform: translateX(3px); }
.footer-links a:hover::before { background: var(--accent2); }
.footer-credits {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.65;
}
.footer-credits a {
  color: var(--accent2);
  text-decoration: none;
  font-weight: 700;
}
.footer-credits a:hover { text-decoration: underline; }
.footer-bottom {
  max-width: 1400px;
  margin: var(--space-6) auto 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-dim);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.02em;
}
.footer-bottom strong {
  color: var(--text);
  font-weight: 700;
}
.footer-bottom a {
  color: var(--accent2);
  text-decoration: none;
  font-weight: 700;
}
.footer-bottom a:hover { text-decoration: underline; }

@media (max-width: 800px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
}

/* ===== Back to top ===== */
.back-to-top {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 90;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, var(--accent2), var(--accent));
  color: var(--on-accent);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md), 0 0 20px var(--accent-glow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s var(--ease), visibility 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.2s var(--ease);
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  box-shadow: var(--shadow-lg), 0 0 26px var(--accent-glow);
  transform: translateY(-2px);
}
.back-to-top:active { transform: translateY(0); }

/* ===== List pages (ninjas / skills) ===== */
.page-title {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 800;
  margin-bottom: var(--space-2);
  letter-spacing: 0;
}
.page-subtitle {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: var(--space-5);
  max-width: 640px;
}
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
}
.list-toolbar .search-box { flex: 1; min-width: 180px; max-width: 360px; margin-bottom: 0; }
.list-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: var(--space-4);
}
.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}
.list-card {
  background: var(--card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease);
  text-align: center;
  cursor: pointer;
  color: inherit;
  font: inherit;
  width: 100%;
}
.list-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--card-hover);
  box-shadow: var(--shadow-sm);
}
.list-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.list-card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: rgba(10, 15, 26, 0.55);
}
html[data-mode="light"] .list-card img {
  background: var(--accent-glow);
}
.list-card .lc-name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 0.1rem;
}
.list-card .lc-tier {
  display: flex;
  justify-content: center;
}
.list-card .lc-chakra {
  display: flex;
  justify-content: center;
}

/* Tier / rarity badges */
.tier-badge {
  display: inline-block;
  padding: 0.14rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  line-height: 1.3;
}
.tier-UR { background: #00c8ff; color: #04202a; }
.tier-SSS { background: #ff00f7; color: #2a0028; }
.tier-SS { background: #dade03; color: #2a2c00; }
.tier-S { background: #e00d0d; }
.tier-A { background: #7800c3; }
.tier-B { background: #0460eb; }
.tier-C { background: #00c714; color: #042a08; }
.tier-D { background: #3d3d3d; }

/* Detail modal (list pages) */
.detail-modal {
  max-width: 440px;
  width: calc(100% - 2rem);
  max-height: min(88vh, 640px);
}
.detail-hero {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-dim);
}
.detail-hero img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: rgba(10, 15, 26, 0.55);
  flex-shrink: 0;
}
html[data-mode="light"] .detail-hero img {
  background: var(--accent-glow);
}
.detail-hero-text { min-width: 0; flex: 1; }
.detail-name {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: var(--space-2);
}
.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.detail-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-dim);
  font-size: 0.88rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .tt-label { color: var(--muted); white-space: nowrap; }
.detail-row .tt-value { text-align: right; font-weight: 600; word-break: break-word; }
.detail-section-title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.detail-rel {
  /* background: var(--accent-glow); */
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.detail-rel.muted {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.detail-rel-title { margin-bottom: var(--space-2); }
.detail-rel-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.85rem;
  padding: 0.15rem 0;
}
.rel-label.strong { color: #22c55e; font-weight: 700; }
.rel-label.weak { color: #ef4444; font-weight: 700; }
.rel-val { font-weight: 700; }

/* ===== Light mode adjustments for existing components ===== */
html[data-mode="light"] body {
  background: var(--bg);
}
html[data-mode="light"] .lineup-bar {
  background: linear-gradient(180deg, rgba(245,250,252,0.98) 0%, rgba(226,238,246,0.95) 100%);
}
html[data-mode="light"] .ninja-slot {
  background: rgba(245, 250, 252, 0.9);
}
html[data-mode="light"] .ninja-slot img,
html[data-mode="light"] .item-card img {
  background: var(--accent-glow);
}
html[data-mode="light"] .modal {
  background: var(--card-solid);
}
html[data-mode="light"] #tooltip {
  background: #f5fafc;
  color: var(--text);
  border-color: var(--border);
}
html[data-mode="light"] .rarity-tabs,
html[data-mode="light"] .site-nav {
  background: rgba(245, 250, 252, 0.75);
}
html[data-mode="light"] .rarity-tab:hover,
html[data-mode="light"] .nav-link:hover {
  background: var(--card-hover);
}
html[data-mode="light"] .search-box {
  background-color: rgba(245, 250, 252, 0.95);
  color: var(--text);
}
html[data-mode="light"] .skill-panel {
  background: var(--card);
}
html[data-mode="light"] .item-card {
  background: var(--card);
}
html[data-mode="light"] header {
  background: linear-gradient(180deg, rgba(245,250,252,0.92) 0%, rgba(226,238,246,0.92) 100%);
}
html[data-mode="light"] .sidebar-title {
  background: var(--bg);
}

@media (max-width: 640px) {
  .list-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-2);
  }
  .list-card img { width: 56px; height: 56px; }
}
