@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap');

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

body {
  font-family: 'Inter', sans-serif;
  background-color: #0d0d0d;
  color: #ffffff;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

pre[class*="language-"] {
  background: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
  text-shadow: none !important;
}
code[class*="language-"], pre[class*="language-"] {
  color: #e2e8f0 !important;
  font-family: 'Fira Code', 'Fira Mono', Consolas, monospace !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
}
.token.keyword { color: #c678dd !important; }
.token.function { color: #61afef !important; }
.token.string { color: #98c379 !important; }
.token.comment { color: #5c6370 !important; font-style: italic; }
.token.number { color: #d19a66 !important; }
.token.operator { color: #56b6c2 !important; }
.token.class-name { color: #e5c07b !important; }
.token.boolean { color: #d19a66 !important; }
.token.punctuation { color: #abb2bf !important; }

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── SIDEBAR ─── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  display: none;
  transition: opacity 0.3s;
}
.sidebar {
  position: fixed;
  inset-y: 0; left: 0;
  width: 85%;
  max-width: 280px;
  background: #121212;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid #2d2d2d;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.9);
}
.sidebar-open { transform: translateX(0) !important; }
.sidebar-header { padding: 1.5rem; flex-shrink: 0; }
.sidebar-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.03em; color: #fff; }
.sidebar-close { background: none; border: none; cursor: pointer; color: #9ca3af; transition: color 0.15s; padding: 0.25rem; }
.sidebar-close:hover { color: #fff; }
.sidebar-nav { padding: 0 1rem; }
.nav-section-title { color: #6b7280; font-weight: 600; margin-bottom: 0.75rem; font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; }
.nav-item {
  width: 100%;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
  cursor: pointer;
  background: none;
  border: 1px solid transparent;
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.875rem;
}
.nav-item.active { background: #1e1e1e; color: #fff; border-color: #2d2d2d; }
.nav-item:not(.active):hover { background: #1a1a1a; color: #fff; }
.nav-item-inner { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-footer { margin-top: auto; padding: 1.25rem 1rem; border-top: 1px solid #2d2d2d; background: #0f0f0f; flex-shrink: 0; }

/* ─── DESKTOP SIDEBAR ALWAYS OPEN ─── */
@media (min-width: 1024px) {
  .sidebar {
    width: 240px;
    max-width: 240px;
    transform: translateX(0) !important;
    transition: none;
    box-shadow: none;
  }
  .sidebar-close { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .btn-hamburger { display: none !important; }
  header {
    left: 240px;
    width: calc(100% - 240px);
  }
  main {
    margin-left: 240px;
  }
}

/* ─── HEADER ─── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13,13,13,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  padding: 0.5rem;
  border-radius: 0.75rem;
  transition: background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }

/* ─── MAIN ─── */
main {
  padding-top: 5.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-bottom: 5rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 768px) {
  main { padding-left: 2rem; padding-right: 2rem; }
}
@media (min-width: 1024px) {
  main {
    margin-left: 240px;
    margin-right: auto;
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

/* ─── TERMINAL ─── */
.terminal-box {
  background: #141414;
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.75rem;
  border: 1px solid #2d2d2d;
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
}
.terminal-dots { display: flex; gap: 0.375rem; margin-bottom: 1rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }
.terminal-prompt {
  font-family: 'Fira Code', Consolas, monospace;
  font-size: 13px;
  display: flex;
  align-items: center;
}
.terminal-cursor {
  width: 8px; height: 20px;
  background: #fff;
  margin-left: 4px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
#search-input::placeholder { color: #9ca3af; }
#search-input { width: 100%; }

/* ─── FILTER TABS ─── */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tabs { -ms-overflow-style: none; scrollbar-width: none; }
.tab-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}
.tab-btn.active { background: #fff; color: #000; border-color: #fff; }
.tab-btn:not(.active) { background: #1a1a1a; color: #9ca3af; border-color: #2d2d2d; }
.tab-btn:not(.active):hover { color: #fff; }

/* ─── SCRIPT LIST ─── */
.group-label {
  color: #4b5563;
  font-weight: 700;
  margin-bottom: 1rem;
  margin-left: 0.25rem;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.script-list {
  background: #141414;
  border-radius: 1rem;
  border: 1px solid #2d2d2d;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.4);
}
.script-item {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid #2d2d2d;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.script-item:last-child { border-bottom: none; }
.script-item:hover { background: #1a1a1a; }
.script-item:hover .item-icon { border-color: rgba(255,255,255,0.2); }
.script-item:hover .item-icon svg { color: #fff; }
.script-item:hover .chevron { color: #fff; transform: translateX(4px); }

.item-icon {
  background: #1e1e1e;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #333;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.item-icon svg { color: #9ca3af; transition: color 0.15s; }
.item-content { flex: 1; min-width: 0; }
.item-title { font-weight: 700; font-size: 1.05rem; color: #fff; margin-bottom: 0.4rem; letter-spacing: -0.02em; }
.item-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tag {
  background: rgba(0,0,0,0.4);
  color: #6b7280;
  font-size: 10px;
  padding: 0.2rem 0.6rem;
  border-radius: 0.375rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255,255,255,0.05);
  transition: color 0.15s;
}
.script-item:hover .tag { color: #d1d5db; }
.chevron { color: #374151; transition: all 0.15s; flex-shrink: 0; }

/* ─── CODE VIEW ─── */
.code-box {
  background: #141414;
  border-radius: 1rem;
  border: 1px solid #2d2d2d;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.code-toolbar {
  background: #1a1a1a;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2d2d2d;
}
.code-actions { display: flex; gap: 0.5rem; }
.action-btn {
  height: 2.5rem;
  width: 2.5rem;
  background: #252525;
  border: 1px solid #3d3d3d;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #d1d5db;
  transition: background 0.15s;
}
.action-btn:hover { background: #333; }
.raw-btn {
  padding: 0.5rem 1rem;
  background: #252525;
  border: 1px solid #3d3d3d;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 11px;
  font-weight: 700;
  color: #d1d5db;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.15s;
  text-decoration: none;
}
.raw-btn:hover { background: #333; }
.code-body {
  padding: 1.25rem;
  overflow-x: auto;
  background: rgba(10,10,10,0.5);
}

/* ─── DETAIL PAGE ─── */
.back-btn {
  margin-bottom: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  transition: color 0.15s;
  text-decoration: none;
}
.back-btn:hover { color: #fff; }
.detail-title { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 900; margin-bottom: 0.75rem; color: #fff; letter-spacing: -0.03em; line-height: 1.2; }
.detail-meta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.meta-date { display: flex; align-items: center; gap: 0.5rem; color: #6b7280; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.meta-dot { width: 4px; height: 4px; border-radius: 50%; background: #374151; }
.meta-status { color: #27c93f; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.views-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #4b5563;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── TOAST ─── */
#toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(2.5rem);
  background: #fff;
  color: #000;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  z-index: 9999;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── LOADING / EMPTY ─── */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
}
.spinner {
  width: 32px; height: 32px;
  border: 2px solid #2d2d2d;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: #4b5563;
}
.empty-state p { margin-top: 0.5rem; font-size: 0.875rem; }

.space-y-6 > * + * { margin-top: 1.5rem; }

/* ─── ANIME CHARACTER DECORATION (DESKTOP ONLY) ─── */
.anime-char-wrapper {
  display: none;
}
@media (min-width: 1200px) {
  .anime-char-wrapper {
    display: block;
    position: fixed;
    right: 0;
    bottom: 0;
    width: 38vw;
    max-width: 560px;
    height: 92vh;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.3) 15%, rgba(0,0,0,0.7) 28%, black 45%),
                        linear-gradient(to top, transparent 0%, black 8%);
    -webkit-mask-composite: destination-in;
    mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.3) 15%, rgba(0,0,0,0.7) 28%, black 45%),
                linear-gradient(to top, transparent 0%, black 8%);
    mask-composite: intersect;
  }
  .anime-char-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    opacity: 0.88;
  }
}
