/* -----------------------------
   Minimal Reset & Base
----------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font:
    15px/1.6 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Ubuntu,
    Cantarell,
    Noto Sans,
    sans-serif;
  color: #1f2937;
  background: #eef1f5;
}
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Responsive images in content */
.card img:not(.gallery-item img) {
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Character images */
.char img {
  width: 100%;
  height: auto;
  border-radius: 8px 8px 0 0;
}

/* Gallery images */
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16/9;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.02);
}

/* Cover image */
.cover img {
  width: 100%;
  height: auto;
  border-radius: 12px;
}

/* Footer */
footer {
  background: #1e3a8a;
  color: #ffffff;
  padding: 20px 0;
  text-align: center;
  margin-top: 40px;
  font-size: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  color: #ffffff;
}

.footer-copyright {
  margin: 0;
}

.footer-tagline {
  margin: 8px 0 0;
  opacity: 0.8;
  font-size: 0.9em;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
}

/* -----------------------------
   Theme Tokens (tweak freely)
----------------------------- */
:root {
  --mal-blue: #2e51a2; /* primary brand-ish */
  --mal-blue-2: #24458e; /* darker for hover */
  --mal-accent: #3b82f6; /* secondary accents */
  --fg: #111827; /* text */
  --muted: #6b7280; /* secondary text */
  --bg: #eef1f5; /* page bg */
  --card: #ffffff; /* card bg */
  --line: #e5e7eb; /* borders */
  --chip: #f3f4f6; /* subtle chip */
  --shadow: 0 6px 18px rgba(2, 6, 23, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --container: 1200px;
}

/* -----------------------------
   Header
----------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #1e3a8a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.topbar-inner {
  max-width: var(--container);
  margin: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  color: #c7d2fe;
  background: #1e3a8a;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .topbar-inner {
    padding: 8px 10px;
    gap: 8px;
  }
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.logo-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #fff;
  color: var(--mal-blue);
  display: grid;
  place-items: center;
  font-weight: 900;
}

/* Desktop Nav */
.nav {
  display: flex;
  gap: 8px;
  margin-left: 8px;
  transition: all 0.3s ease;
}
.nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: #e8eeff;
  font-weight: 600;
  opacity: 0.95;
  transition: all 0.2s ease;
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  z-index: 60;
}

/* Mobile Menu */
@media (max-width: 900px) {
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
    padding: 0;
    margin-right: 10px;
  }

  .nav {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    background: #1e3a8a;
    flex-direction: column;
    padding: 80px 20px 20px;
    margin: 0;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease-in-out;
    z-index: 1000;
    overflow-y: auto;
  }

  .nav.active {
    right: 0;
  }

  .nav a {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.05);
    display: block;
    transition: background-color 0.2s ease;
  }
  
  .nav a:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .search {
    order: 0;
    width: 100%;
    margin: 15px 0;
    padding: 0 10px;
  }
  
  /* Overlay when menu is open */
  .nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }
  
  .nav.active + .nav-overlay {
    display: block;
  }
}

.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
}
.search input {
  width: 100%;
  max-width: 340px;
  min-width: 120px;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: #111;
  outline: 3px solid transparent;
  font-size: 14px;
}
@media (max-width: 768px) {
  .search {
    order: 1;
    width: 100%;
    margin: 8px 0 0;
  }
  .search input {
    max-width: 100%;
  }
}
.search input:focus {
  outline-color: rgba(255, 255, 255, 0.35);
}
.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-ava {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--mal-blue);
  font-weight: 800;
}


/* -----------------------------
   Layout
----------------------------- */
.container {
  max-width: var(--container);
  margin: 16px auto;
  padding: 0 16px;
}
@media (max-width: 480px) {
  .container {
    padding: 0 12px;
    margin: 12px auto;
  }
}
.grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
}
@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 16px;
}
@media (max-width: 480px) {
  .card-pad {
    padding: 14px;
  }
}
.card-title {
  font-weight: 800;
  margin: 0 0 8px;
}
.hr {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* -----------------------------
   Left Column
----------------------------- */
.cover {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
}
@media (max-width: 480px) {
  .score {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .score-main {
    grid-column: auto !important;
  }
}
.score-main {
  grid-column: span 2;
  display: flex;
  align-items: center;
  gap: 14px;
}
.score-n {
  font-size: 34px;
  font-weight: 900;
  color: var(--mal-blue);
}
.score-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  color: #374151;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .actions {
    gap: 6px;
  }
  .btn {
    padding: 8px 10px;
    font-size: 14px;
    flex: 1 1 calc(50% - 4px);
    text-align: center;
  }
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  cursor: pointer;
}
.btn.primary {
  background: var(--mal-blue);
  color: #fff;
  border-color: transparent;
}
.btn.primary:hover {
  background: var(--mal-blue-2);
}
.btn:active {
  transform: translateY(1px);
}

.info-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}
.info-table th {
  width: 38%;
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  padding-right: 8px;
  vertical-align: top;
}
.info-table td {
  color: #111;
}

/* -----------------------------
   Right Column
----------------------------- */
.titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.title {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  word-break: break-word;
}
@media (max-width: 480px) {
  .title {
    font-size: 24px;
    line-height: 1.2;
  }
  .subtitle {
    font-size: 13px;
  }
}
.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  background: var(--chip);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  padding: 10px 12px;
  font-weight: 700;
  color: #334155;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 15px;
}
@media (max-width: 480px) {
  .tab {
    padding: 8px 10px;
    font-size: 14px;
  }
}
.tab[aria-selected="true"] {
  color: var(--mal-blue);
  border-color: var(--mal-blue);
}

.panel {
  display: none;
  padding: 16px 0;
}
.panel.active {
  display: block;
}

/* -----------------------------
   Components inside panels
----------------------------- */
.synopsis {
  white-space: pre-line;
}
.readmore {
  color: var(--mal-blue);
  font-weight: 800;
  cursor: pointer;
}

/* Character grid for both main and supporting characters */
.char-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 20px 0;
}
@media (min-width: 640px) {
  .char-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .char-grid {
    gap: 12px;
    margin: 16px 0;
  }
}

/* Main Characters grid */
#mainCharacters + .char-grid {
  grid-template-columns: 1fr;
  max-width: 100%;
}
@media (min-width: 640px) {
  #mainCharacters + .char-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

#mainCharacters + .char-grid .char {
  min-height: auto;
  align-items: flex-start;
  padding: 16px;
  position: relative;
  margin-bottom: 0;
  height: 100%;
}

#mainCharacters + .char-grid .char img {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  flex-shrink: 0;
}

/* Supporting Characters grid */
#supportCharacters + .char-grid {
  grid-template-columns: 1fr;
  max-width: 100%;
  margin: 0;
  padding: 0 8px;
}
@media (min-width: 640px) {
  #supportCharacters + .char-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

.char {
  display: flex;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: #fff;
}
.char img {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 2px solid var(--line);
  object-fit: cover;
}
.char .name {
  font-size: 1.2em;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--fg);
}
.char .role {
  font-size: 0.95em;
  color: var(--muted);
  background: var(--chip);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
}

.staff-list {
  display: grid;
  gap: 8px;
}
.staff-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.staff-role {
  color: var(--muted);
}

.episodes {
  width: 100%;
  border-collapse: collapse;
}
.episodes th,
.episodes td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.episodes th {
  background: #f8fafc;
}

.review {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
.review-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #e5e7eb;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #374151;
}
.stars {
  letter-spacing: 1px;
}

.reco-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.reco {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.reco .meta {
  padding: 8px;
}
.reco .t {
  font-weight: 800;
}

/* -----------------------------
   Footer
----------------------------- */
footer {
  margin: 40px 0 20px;
  color: #6b7280;
  font-size: 13px;
  text-align: center;
}

/* -----------------------------
   Responsive Columns
----------------------------- */
@media (max-width: 768px) {
  .grid {
    display: flex;
    flex-direction: column;
  }
  
  .grid > section {
    order: -1; /* Move main content (right column) to the top on mobile */
  }
  
  .grid > aside {
    order: 1; /* Move sidebar (left column) to the bottom on mobile */
  }
}

/* Responsive images */
@media (max-width: 768px) {
  .char img, 
  .gallery-item img,
  .cover img {
    max-width: 100%;
    height: auto;
  }
  
  /* Adjust character grid on mobile */
  .char {
    margin-bottom: 20px;
  }
  
  /* Adjust gallery grid on mobile */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}
@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.gallery-item {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.02);
}

/* Lightbox styles */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.lightbox-caption {
  position: absolute;
  bottom: 20px;
  color: white;
  text-align: center;
  width: 100%;
  padding: 10px;
  background: rgba(0, 0, 0, 0.7);
}

.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 30px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  background: none;
  border: none;
  padding: 0 10px;
  line-height: 1;
}
.close-btn:focus {
  outline: 2px solid #fff;
  border-radius: 4px;
}

.close-btn:hover {
  color: #ccc;
}
