:root {
  --bg: #f4f7f5;
  --bg-elevated: #ffffff;
  --ink: #12241c;
  --ink-soft: #4a6358;
  --muted: #6b8176;
  --line: #d7e3dc;
  --brand: #0f6b4c;
  --brand-deep: #0b3d2e;
  --brand-soft: #e6f4ee;
  --accent: #c9a227;
  --danger: #b42318;
  --shadow: 0 12px 40px rgba(11, 61, 46, 0.08);
  --radius: 18px;
  --sidebar-w: 360px;
  --topbar-h: 68px;
  --font: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9f0e5 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #fff4d6 0%, transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

body {
  min-height: 100dvh;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(15, 107, 76, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand-text span {
  color: var(--ink-soft);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box input {
  width: min(320px, 42vw);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.icon-btn,
.btn {
  border: 0;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.icon-btn {
  padding: 10px 14px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 600;
}

.icon-btn:hover,
.btn:hover {
  transform: translateY(-1px);
}

.btn {
  padding: 10px 16px;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: #fff;
}

.btn.ghost {
  background: #fff;
  color: var(--brand-deep);
  border: 1px solid var(--line);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  gap: 20px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.player-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-shell {
  position: relative;
  background: #06150f;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
}

.player-host,
.player-host iframe,
.player-host video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

.player-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #d5e8de;
  font-size: 1rem;
}

.subtitle-layer {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: clamp(0.95rem, 1.8vw, 1.25rem);
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.meta-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 8px;
}

.ep-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 700;
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

#video-title {
  margin: 0 0 14px;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.4;
  font-weight: 700;
}

.meta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
  background: #f8fbf9;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 12px);
  align-self: start;
  max-height: calc(100dvh - var(--topbar-h) - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.sidebar-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.episode-list {
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ep-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  width: 100%;
}

.ep-item:hover {
  background: #f3faf6;
}

.ep-item.active {
  background: var(--brand-soft);
  border-color: #b7ddcb;
}

.ep-thumb {
  width: 72px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #dfeae4;
}

.ep-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ep-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand);
}

.ep-title {
  font-size: 0.88rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ep-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.footer {
  padding: 8px 20px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 21, 15, 0.45);
  z-index: 45;
}

.mobile-only {
  display: none;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(400px, 92vw);
    max-height: none;
    border-radius: 0;
    z-index: 50;
    transform: translateX(105%);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .brand-text span {
    max-width: 36vw;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 10px 12px;
  }

  .search-box input {
    width: 38vw;
    padding: 9px 12px;
  }

  .meta-card {
    padding: 14px;
  }

  .meta-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}
