/* ==========================================================================
   FusionShort — design tokens + shared shell
   Values extracted from https://m.fusionshort.com/ (entry.CjyCjAlX.css)
   ========================================================================== */

:root {
  /* surface */
  --bg-primary: #140127;
  --bg-secondary: #1f0b36;
  --bg-elevated: #2b173f;
  --bg-card: #261139;
  --bg-card-hover: #33204a;
  --border: #2b1640;
  --media-bg: #000;
  --surface-glass: hsla(0, 0%, 100%, .1);

  /* accent */
  --accent: #ab81fd;
  --accent-light: #be7be4;
  --accent-dark: #7131df;
  --accent-soft: rgba(171, 129, 253, .18);
  --accent-gradient: linear-gradient(312deg, #be7be4, #ab81fd 50%, #7131df);
  --ranking-gradient: linear-gradient(90deg, #fa2b7f, #7d39ba 50%, #0743f0);

  /* text */
  --text-primary: #fff;
  --text-on-dark: #fff;
  --text-secondary: #b1b1b1;
  --text-muted: #8a8a8a;
  --text-inverse: #150041;
  --error: #e95549;

  /* geometry */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-full: 999px;
  --app-max-width: 750px;
  --app-header-height: calc(52px + env(safe-area-inset-top));
  --app-footer-height: 52px;
  --app-bottom-nav-height: 58px;
  --progress-track: hsla(0, 0%, 100%, .2);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text-primary);
  background: var(--bg-primary);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

img {
  max-width: 100%;
  border: 0;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

/* --- shell ---------------------------------------------------------------- */

.app-shell,
.secondary-shell,
.watch-shell {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: calc(100dvh - var(--app-header-height));
  margin: 0 auto;
  background: var(--bg-primary);
}

.app-shell {
  padding-bottom: calc(var(--app-footer-height) + var(--app-bottom-nav-height) + env(safe-area-inset-bottom));
}

.app-content {
  min-height: calc(100dvh - var(--app-header-height) - var(--app-footer-height) - var(--app-bottom-nav-height) - env(safe-area-inset-bottom));
}

.secondary-shell {
  min-height: calc(100dvh - var(--app-header-height) - var(--app-footer-height) - env(safe-area-inset-bottom));
}

.text-ellipsis-2 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  max-height: 2lh;
}

/* --- secondary header (watch / profile / settings) ------------------------ */

.secondary-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  width: 100%;
  max-width: var(--app-max-width);
  min-height: var(--app-header-height);
  align-items: end;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 8px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 1, 39, .94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.secondary-header button,
.secondary-header__spacer {
  display: grid;
  width: 44px;
  height: 52px;
  place-items: center;
  color: var(--text-on-dark);
  background: transparent;
  font-size: 26px;
}

.secondary-header strong {
  align-self: center;
  text-align: center;
  font-size: 15px;
}

/* --- footer --------------------------------------------------------------- */

.app-footer {
  position: fixed;
  z-index: 19;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: 100%;
  max-width: var(--app-max-width);
  min-height: calc(var(--app-footer-height) + env(safe-area-inset-bottom));
  place-items: center;
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: rgba(20, 1, 39, .96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: clamp(10px, 3vw, 12px);
  line-height: 1.5;
  text-align: center;
}

.app-footer--with-navigation {
  bottom: calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom));
  min-height: var(--app-footer-height);
  padding-bottom: 8px;
}

.app-footer p {
  margin: 0;
}

/* --- bottom nav ----------------------------------------------------------- */

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: 100%;
  max-width: var(--app-max-width);
  min-height: calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: rgba(20, 1, 39, .96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.bottom-nav__link {
  display: grid;
  min-height: var(--app-bottom-nav-height);
  place-items: center;
  align-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 13px;
}

.bottom-nav__link svg {
  font-size: 22px;
}

.bottom-nav__link--active {
  color: var(--text-on-dark);
  font-weight: 700;
}

/* --- cover image (with graceful fallback) --------------------------------- */

.cover-image,
.cover-image img,
.cover-image__fallback {
  width: 100%;
  height: 100%;
}

.cover-image {
  position: relative;
  overflow: hidden;
}

.cover-image img {
  display: block;
  object-fit: cover;
}

.cover-image__fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(190, 123, 228, .3), transparent 55%), var(--bg-card);
}

/* --- drama card ----------------------------------------------------------- */

.drama-card {
  display: block;
  min-width: 0;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

.drama-card__cover {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.drama-card__ranking,
.drama-card__tag,
.drama-card__views {
  position: absolute;
  padding: 2px 5px;
  color: var(--text-on-dark);
  border-radius: var(--radius-sm);
  font-size: 10px;
}

.drama-card__tag {
  top: 6px;
  right: 6px;
  background: var(--accent);
}

.drama-card__ranking {
  top: 6px;
  left: 6px;
  background: var(--ranking-gradient);
}

.drama-card__views {
  right: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, .65);
}

.drama-card__views svg {
  font-size: 11px;
}

.drama-card__title {
  min-height: 34px;
  margin-top: 6px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

/* --- loading -------------------------------------------------------------- */

.loading-indicator {
  display: grid;
  min-height: 64px;
  place-items: center;
}

.loading-indicator--fullscreen {
  min-height: calc(100dvh - var(--app-header-height));
}

.loading-indicator__ring {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(1turn);
  }
}

/* --- icon helper ---------------------------------------------------------- */

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -.125em;
  fill: currentColor;
}
