:root {
  --bg: #0d0d0d;
  --bg-strong: #161616;
  --panel: rgba(22, 22, 22, 0.75);
  --text: #f5f5f5;
  --text-primary: #ffffff;
  --muted: #888888;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #7A00FF;
  --accent-hover: #902bf5;
  --accent-dark: #5000A8;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: 
    linear-gradient(rgba(13, 13, 13, 0.75), rgba(13, 13, 13, 0.95)),
    url('/static/img/bg.jpg') no-repeat center center fixed;
  background-size: cover;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
  display: block;
}

/* Layout */
.wrap {
  width: min(1200px, calc(100vw - 40px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-accent {
  color: var(--accent);
}

/* Search Forms */
.header-search,
.hero-search {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 4px;
  transition: border-color 0.2s, background 0.2s;
}

.header-search:focus-within,
.hero-search:focus-within {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding-left: 14px;
  color: var(--muted);
  flex-grow: 1;
}

.search-input-wrapper svg {
  width: 18px;
  height: 18px;
}

input[type="search"] {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 14px;
  width: 100%;
  outline: none;
}

input[type="search"]::placeholder {
  color: var(--muted);
}

.search-button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.search-button:hover {
  background: var(--accent-hover);
}

.search-button:active {
  transform: scale(0.98);
}

.page-shell {
  padding: 40px 0 80px;
}

/* General Forms */
input,
select,
button {
  font: inherit;
}

select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}

select:focus {
  border-color: var(--accent);
}

select option {
  background: var(--bg-strong);
  color: var(--text-primary);
}

/* Buttons */
.primary-button, .nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 14px 28px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(122, 0, 255, 0.3);
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
}

.primary-button:hover, .nav-button:hover {
  background: var(--accent-hover);
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(122, 0, 255, 0.4);
}

.nav-button.disabled {
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Hero Section */
.hero {
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 80px 20px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(26,26,26,0) 0%, rgba(13,13,13,0.8) 100%);
  border: 1px solid var(--line);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.hero > * {
  z-index: 2;
  position: relative;
  max-width: 800px;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  line-height: 1.1;
  margin: 0 0 20px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.hero-copy {
  font-size: 1.15rem;
  color: #d1d1d1;
  margin-bottom: 40px;
  max-width: 600px;
}

.hero-search {
  width: 100%;
  max-width: 500px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

/* Typography & Headers */
h1, h2, h3 {
  color: var(--text-primary);
  margin-top: 0;
}

.section-head {
  margin-bottom: 24px;
}

.section-head h2 {
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 30px;
  backdrop-filter: blur(10px);
}

/* Grids */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

/* Anime Card */
.anime-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-strong);
  border: 1px solid var(--line);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.anime-card:hover {
  transform: translateY(-8px);
  border-color: rgba(122, 0, 255, 0.5);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(122, 0, 255, 0.15);
}

.poster-wrap {
  aspect-ratio: 2 / 3;
  position: relative;
  background: #222;
  overflow: hidden;
}

.poster-wrap img,
.detail-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.anime-card:hover .poster-wrap img {
  transform: scale(1.05);
}

.poster-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent);
}

.card-body {
  padding: 16px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.card-body h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 10px;
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: auto;
}

/* Detail Page */
.detail-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

@media (max-width: 800px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

.detail-poster img {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.detail-main {
  display: flex;
  flex-direction: column;
}

.detail-main h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 8px;
}

.subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  margin: 0 0 24px;
}

.meta-row.spacious {
  gap: 16px;
  font-size: 1rem;
  margin-bottom: 24px;
}

.chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(122, 0, 255, 0.15);
  border: 1px solid rgba(122, 0, 255, 0.3);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.description {
  font-size: 1.1rem;
  line-height: 1.7;
  color: #ccc;
  margin-bottom: 40px;
  max-width: 80ch;
}

.cta-row {
  margin-top: auto;
  padding-top: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.info-list, .translation-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-list li, .translation-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-list li:last-child, .translation-list li:last-child {
  border-bottom: none;
}

.translation-list strong {
  color: var(--text-primary);
}

.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.screenshot-grid img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.video-list a {
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

.video-list a:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

/* Messages */
.message {
  padding: 16px 20px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--muted);
  margin-bottom: 20px;
}

.message.warning {
  background: rgba(255, 170, 0, 0.1);
  border-left-color: #ffaa00;
}

.message.error {
  background: rgba(255, 59, 48, 0.1);
  border-left-color: #ff3b30;
}

.message.subtle {
  border-left: none;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Watch Page */
.watch-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 30px;
}

@media (max-width: 1024px) {
  .watch-layout {
    grid-template-columns: 1fr;
  }
}

.player-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.video-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.controls-panel {
  align-self: start;
  position: sticky;
  top: 100px;
}

.watch-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 30px;
}

.watch-form label, .static-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.watch-form button {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.watch-form button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--text-primary);
}

.episode-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
}

.episode-nav .nav-button {
  flex: 1;
  padding: 12px 10px;
  font-size: 0.85rem;
  text-align: center;
}

.watch-meta {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
}

.watch-meta div {
  display: flex;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.watch-meta div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.watch-meta dt {
  color: var(--muted);
}

.watch-meta dd {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
}
