:root {
  --bg: #101112;
  --surface: #191a1d;
  --surface-2: #22242a;
  --text: #f6f1e8;
  --muted: #aaa6a0;
  --line: rgba(246, 241, 232, 0.13);
  --accent: #36c2a1;
  --accent-2: #f05263;
  --gold: #d7a54a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 18, 0.88);
  backdrop-filter: blur(18px);
}

.brand,
.nav-links,
.hero-actions,
.catalog-controls,
.filter-actions,
.pagination,
.footer {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent-2);
  color: white;
  font-size: 0.9rem;
  letter-spacing: 0;
}

.nav-links {
  gap: 18px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.nav-links a:hover {
  color: var(--text);
}

.auth-nav {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.nav-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.nav-button:hover {
  color: var(--text);
}

.hero {
  position: relative;
  display: flex;
  align-items: end;
  min-height: 620px;
  overflow: hidden;
  padding: 120px clamp(18px, 5vw, 72px) 74px;
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(16, 17, 18, 0.94) 0%, rgba(16, 17, 18, 0.62) 48%, rgba(16, 17, 18, 0.18) 100%),
    linear-gradient(180deg, rgba(16, 17, 18, 0.15), rgba(16, 17, 18, 1)),
    var(--hero-image, url("https://images.unsplash.com/photo-1524626674718-f4b54a5c806e?auto=format&fit=crop&w=1800&q=80"));
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.hero-content {
  position: relative;
  width: min(720px, 100%);
}

.kicker,
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 6.2rem);
  line-height: 0.95;
}

.hero p {
  max-width: 620px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.hero-actions {
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.catalog-hero {
  position: relative;
  overflow: hidden;
  padding: 92px clamp(18px, 5vw, 72px) 52px;
}

.catalog-hero::after {
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  content: "";
}

.catalog-hero-content {
  position: relative;
  width: min(820px, 100%);
}

.catalog-hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  line-height: 0.95;
}

.catalog-hero p {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.65;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 850;
}

.button-primary {
  background: var(--accent-2);
  color: white;
}

.button-secondary {
  border-color: var(--line);
  background: rgba(246, 241, 232, 0.06);
  color: var(--text);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.trust-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.trust-strip article {
  padding: 22px clamp(18px, 4vw, 58px);
  background: #141518;
}

.trust-strip span,
.control-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.trust-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 1.18rem;
}

.catalog-section,
.integration-section {
  padding: 54px clamp(18px, 4vw, 58px);
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.catalog-controls {
  gap: 10px;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(120px, 0.48fr) minmax(160px, 0.68fr) minmax(140px, 0.56fr) minmax(170px, 0.72fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(54, 194, 161, 0.09), transparent 42%),
    rgba(25, 26, 29, 0.82);
}

.filter-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.filter-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-actions {
  gap: 8px;
  justify-content: flex-end;
}

input,
select {
  width: min(360px, 46vw);
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #111214;
  color: var(--text);
  outline: none;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 13px) 19px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
}

input:focus,
select:focus {
  border-color: rgba(54, 194, 161, 0.5);
  box-shadow: 0 0 0 3px rgba(54, 194, 161, 0.14);
}

.filter-field input,
.filter-field select {
  width: 100%;
}

.state-banner {
  display: none;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(25, 26, 29, 0.88);
  color: var(--muted);
}

.state-banner.is-visible {
  display: block;
}

.drama-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}

.drama-card {
  min-width: 0;
  border-radius: 8px;
  cursor: pointer;
}

.poster-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.poster-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease, filter 180ms ease;
}

.poster-frame.has-broken-image img {
  display: none;
}

.drama-card:hover img,
.drama-card:focus-visible img {
  transform: scale(1.04);
  filter: saturate(1.08);
}

.poster-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
  background:
    linear-gradient(160deg, rgba(44, 198, 176, 0.18), transparent 45%),
    var(--surface-2);
}

.poster-frame img + .poster-fallback {
  display: none;
}

.poster-frame.has-broken-image .poster-fallback {
  display: grid;
}

.card-body {
  padding-top: 12px;
}

.card-title {
  min-height: 46px;
  margin: 0 0 9px;
  font-size: 1rem;
  line-height: 1.3;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.card-meta span,
.drawer-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.card-description {
  display: -webkit-box;
  min-height: 63px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.rating-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 10px;
}

.rating-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  border: 1px solid rgba(215, 165, 74, 0.34);
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(215, 165, 74, 0.1);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 850;
}

a.rating-chip:hover,
a.rating-chip:focus-visible {
  border-color: rgba(215, 165, 74, 0.68);
  background: rgba(215, 165, 74, 0.16);
}

.rating-chip strong {
  color: var(--gold);
  font-weight: 950;
}

.rating-source,
.rating-votes {
  color: var(--muted);
}

.drawer-meta .rating-strip {
  width: 100%;
  margin: 2px 0 0;
}

.dorama-actions,
.player-list-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dorama-actions {
  margin-top: 10px;
}

.player-list-actions {
  margin: 0 0 16px;
}

.dorama-list-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(246, 241, 232, 0.06);
  color: var(--text);
  font-weight: 900;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.dorama-list-btn:hover,
.dorama-list-btn:focus-visible {
  border-color: rgba(54, 194, 161, 0.54);
  transform: translateY(-1px);
}

.dorama-list-btn.is-active {
  border-color: rgba(240, 82, 99, 0.76);
  background: rgba(240, 82, 99, 0.18);
  color: white;
}

.dorama-actions.is-loading,
.player-list-actions.is-loading {
  opacity: 0.72;
}

.pagination {
  justify-content: center;
  gap: 14px;
  margin-top: 32px;
}

.pagination span {
  min-width: 130px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.integration-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
}

.integration-grid h3 {
  margin: 0 0 10px;
}

.integration-grid p,
.text-page p,
.text-page li {
  color: var(--muted);
  line-height: 1.65;
}

.footer {
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding: 24px clamp(18px, 4vw, 58px);
  color: var(--muted);
}

.footer a:hover {
  color: var(--text);
}

.details-drawer {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
}

.details-drawer.is-open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  width: min(620px, 100%);
  height: 100%;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #121316;
  box-shadow: var(--shadow);
}

.drawer-close {
  position: absolute;
  z-index: 3;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.54);
  color: var(--text);
  font-size: 1.6rem;
}

.drawer-media {
  min-height: 330px;
  background:
    linear-gradient(180deg, rgba(18, 19, 22, 0.08), #121316 100%),
    var(--drawer-image, linear-gradient(135deg, #25262a, #5b2936 58%, #163d37));
  background-size: cover;
  background-position: center;
}

.drawer-copy {
  padding: 26px;
}

.drawer-copy h2 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 5vw, 3rem);
}

.drawer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.watch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.translation-lock,
.tracker-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(54, 194, 161, 0.36);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(54, 194, 161, 0.12);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 850;
}

.tracker-pill {
  border-color: var(--line);
  background: rgba(246, 241, 232, 0.07);
  color: var(--muted);
}

.tracker-pill.is-active {
  border-color: rgba(54, 194, 161, 0.42);
  color: var(--accent);
}

.player-shell {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050506;
}

.player-shell iframe {
  display: none;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-shell iframe.is-visible {
  display: block;
}

.player-placeholder {
  display: none;
  place-items: center;
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(54, 194, 161, 0.42);
  padding: 20px;
  background: rgba(54, 194, 161, 0.08);
  color: var(--text);
  text-align: center;
  font-weight: 850;
}

.player-placeholder.is-visible {
  display: grid;
}

.episode-toolbar {
  display: none;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
}

.episode-toolbar.is-visible {
  display: flex;
}

.episode-toolbar select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111214;
  color: var(--text);
  font: inherit;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.episode-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 241, 232, 0.06);
  color: var(--text);
  font-weight: 850;
}

.episode-button:hover,
.episode-button:focus-visible {
  border-color: rgba(54, 194, 161, 0.5);
}

.episode-button.is-active {
  border-color: rgba(54, 194, 161, 0.74);
  background: rgba(54, 194, 161, 0.16);
}

.text-page {
  width: min(920px, calc(100% - 36px));
  margin: 0 auto;
  padding: 64px 0;
}

.text-page h1 {
  margin: 0 0 18px;
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 1;
}

.text-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
}

.auth-page,
.profile-page {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0;
}

.auth-page {
  display: grid;
  min-height: calc(100vh - 160px);
  place-items: center;
}

.auth-panel,
.profile-hero,
.profile-edit-panel,
.profile-dorama-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.auth-panel {
  width: min(460px, 100%);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-panel h1,
.profile-main-info h1,
.profile-form h2 {
  margin: 0;
}

.auth-form,
.profile-form {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.auth-form input,
.profile-form input {
  width: 100%;
}

.auth-error {
  min-height: 22px;
  margin: 4px 0 0;
  color: #ffb0b8;
  font-weight: 800;
}

.auth-switch {
  margin: 18px 0 0;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  font-weight: 850;
}

.profile-page {
  display: grid;
  gap: 18px;
}

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
}

.profile-main-info {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 16px;
}

.profile-main-info p {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.profile-avatar-placeholder {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--gold));
  color: white;
  font-size: 2rem;
  font-weight: 900;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-edit-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  padding: 22px;
}

.profile-edit-panel[hidden] {
  display: none;
}

.profile-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

.profile-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(246, 241, 232, 0.06);
  color: var(--text);
  font-weight: 850;
  white-space: nowrap;
}

.profile-tab.is-active {
  border-color: rgba(54, 194, 161, 0.64);
  background: rgba(54, 194, 161, 0.16);
}

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

.profile-dorama-card {
  min-width: 0;
  padding: 12px;
}

.profile-dorama-link {
  display: grid;
  gap: 8px;
}

.profile-poster-frame {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.profile-poster-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-dorama-card h3 {
  min-height: 42px;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.28;
}

.profile-dorama-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.profile-card-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.profile-status-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(246, 241, 232, 0.06);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 850;
}

.profile-status-chip:hover,
.profile-status-chip:focus-visible {
  border-color: rgba(240, 82, 99, 0.7);
}

.profile-loading,
.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(246, 241, 232, 0.05);
  color: var(--muted);
  font-weight: 850;
}

.app-toast {
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(18, 19, 22, 0.96);
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 820px) {
  .site-header,
  .section-header,
  .catalog-controls,
  .filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .auth-nav {
    width: 100%;
    justify-content: space-between;
  }

  .hero {
    min-height: 540px;
  }

  .trust-strip,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  input,
  select {
    width: 100%;
  }

  .drama-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .profile-hero,
  .profile-main-info,
  .profile-edit-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .profile-hero,
  .profile-main-info {
    flex-direction: column;
  }

  .profile-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .drama-grid,
  .profile-dorama-grid {
    grid-template-columns: 1fr;
  }
}
