/* ==========================================================================
   iOS 18 / iPadOS 18 / macOS Sequoia Human Interface Design System
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);

  /* Light Mode Palette */
  --bg-grouped: #F2F2F7;
  --bg-elevated: #FFFFFF;
  --bg-secondary: #EFEFF4;
  --bg-tertiary: #E5E5EA;
  --bg-glass: rgba(255, 255, 255, 0.74);
  --bg-glass-strong: rgba(255, 255, 255, 0.88);
  --bg-input: rgba(118, 118, 128, 0.12);
  --bg-hover: rgba(120, 120, 128, 0.08);
  --bg-active-pill: rgba(0, 122, 255, 0.12);

  --text-primary: #000000;
  --text-secondary: rgba(60, 60, 67, 0.68);
  --text-tertiary: rgba(60, 60, 67, 0.42);
  --separator: rgba(60, 60, 67, 0.13);
  --separator-strong: rgba(60, 60, 67, 0.22);

  --blue: #007AFF;
  --blue-hover: #0066D6;
  --red: #FF3B30;
  --green: #34C759;
  --orange: #FF9500;
  --indigo: #5856D6;
  --teal: #30B0C7;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.045), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-float: 0 18px 48px rgba(0, 0, 0, 0.14), 0 2px 10px rgba(0, 0, 0, 0.06);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --sidebar-w: 276px;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg-grouped: #000000;
    --bg-elevated: #1C1C1E;
    --bg-secondary: #2C2C2E;
    --bg-tertiary: #3A3A3C;
    --bg-glass: rgba(28, 28, 30, 0.76);
    --bg-glass-strong: rgba(28, 28, 30, 0.90);
    --bg-input: rgba(118, 118, 128, 0.24);
    --bg-hover: rgba(255, 255, 255, 0.07);
    --bg-active-pill: rgba(10, 132, 255, 0.20);

    --text-primary: #FFFFFF;
    --text-secondary: rgba(235, 235, 245, 0.65);
    --text-tertiary: rgba(235, 235, 245, 0.38);
    --separator: rgba(84, 84, 88, 0.55);
    --separator-strong: rgba(84, 84, 88, 0.85);

    --blue: #0A84FF;
    --blue-hover: #409CFF;
    --red: #FF453A;
    --green: #30D158;
    --orange: #FF9F0A;
    --indigo: #5E5CE6;
    --teal: #40CBE0;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.35);
    --shadow-float: 0 24px 60px rgba(0, 0, 0, 0.65);
  }
}

:root[data-theme="dark"] {
  --bg-grouped: #000000;
  --bg-elevated: #1C1C1E;
  --bg-secondary: #2C2C2E;
  --bg-tertiary: #3A3A3C;
  --bg-glass: rgba(28, 28, 30, 0.76);
  --bg-glass-strong: rgba(28, 28, 30, 0.90);
  --bg-input: rgba(118, 118, 128, 0.24);
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-active-pill: rgba(10, 132, 255, 0.20);

  --text-primary: #FFFFFF;
  --text-secondary: rgba(235, 235, 245, 0.65);
  --text-tertiary: rgba(235, 235, 245, 0.38);
  --separator: rgba(84, 84, 88, 0.55);
  --separator-strong: rgba(84, 84, 88, 0.85);

  --blue: #0A84FF;
  --blue-hover: #409CFF;
  --red: #FF453A;
  --green: #30D158;
  --orange: #FF9F0A;
  --indigo: #5E5CE6;
  --teal: #40CBE0;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 24px 60px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-grouped);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   App Shell (iPadOS SplitView + Mobile TabBar)
   ========================================================================== */

.shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 88% -10%, rgba(0, 122, 255, 0.08), transparent 60%),
    radial-gradient(700px 460px at 20% 105%, rgba(88, 86, 214, 0.07), transparent 60%),
    var(--bg-grouped);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-right: 0.5px solid var(--separator);
  z-index: 20;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 18px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--blue), var(--indigo));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 122, 255, 0.28);
  flex-shrink: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-section-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 12px 10px 6px;
  letter-spacing: 0.02em;
}

.platform-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.platform-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 13px;
  border: 0.5px solid transparent;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  overflow: hidden;
  transition: transform 0.18s var(--ease-spring), background 0.18s ease, border-color 0.18s ease;
}

.platform-pill:hover {
  background: var(--bg-hover);
}

.platform-pill:active {
  transform: scale(0.98);
}

.platform-pill.active {
  background: var(--bg-elevated);
  border-color: var(--separator);
  box-shadow: var(--shadow-xs);
}

.platform-dot-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}

.platform-meta {
  flex: 1;
  min-width: 0;
}

.platform-name {
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.platform-desc {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.status-badge.online {
  background: rgba(52, 199, 89, 0.15);
  color: var(--green);
}

.status-badge.soon {
  background: var(--bg-input);
  color: var(--text-secondary);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.16s var(--ease-spring);
}

.nav-item:hover {
  background: var(--bg-hover);
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.active {
  background: var(--bg-active-pill);
  color: var(--blue);
  font-weight: 600;
}

.nav-item .nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.speed-capsule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  border-radius: 15px;
  background: var(--bg-elevated);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-xs);
}

.speed-capsule-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.pulse-dot.active {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.22);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.72; }
}

.theme-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Main Workspace & Sticky Glass Header
   ========================================================================== */

.workspace {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  padding: 18px 28px 14px;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 0.5px solid var(--separator);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.large-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.18;
}

.subtitle-inline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.content-body {
  padding: 22px 28px 90px;
  max-width: 1440px;
  margin: 0 auto;
}

/* ==========================================================================
   iOS Controls: Search Pill, Segmented Control, Buttons
   ========================================================================== */

.ios-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 540px;
  min-width: 240px;
}

.ios-search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 0.5px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ios-search-box:focus-within {
  background: var(--bg-elevated);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.16);
}

.ios-search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}

.ios-search-box input::placeholder {
  color: var(--text-tertiary);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-input);
  gap: 2px;
}

.segmented-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8.5px;
  cursor: pointer;
  transition: background 0.18s var(--ease-spring), color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.segmented-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s var(--ease-spring), opacity 0.16s ease, background 0.18s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}

.btn-tinted {
  background: var(--bg-active-pill);
  color: var(--blue);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 0.5px solid var(--separator);
}

.btn-danger-tinted {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: var(--bg-input);
  color: var(--text-primary);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.16s var(--ease-spring), background 0.16s ease;
}

.icon-btn:hover {
  background: var(--bg-tertiary);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* ==========================================================================
   Explore Grid & Drama Poster Cards
   ========================================================================== */

.quick-parse-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 18px;
}

.drama-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--separator);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.28s var(--ease-spring), box-shadow 0.28s ease;
  display: flex;
  flex-direction: column;
}

.drama-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-float);
}

.drama-card:active {
  transform: scale(0.98);
}

.poster-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  overflow: hidden;
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s var(--ease-spring);
}

.poster-fallback {
  width: 100%;
  height: 100%;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: #fff;
  background: linear-gradient(145deg, #1c2541 0%, #3a506b 48%, #5856d6 100%);
}

.poster-fallback-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.drama-card:hover .poster-wrap img {
  transform: scale(1.04);
}

.poster-scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 55%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  pointer-events: none;
}

.poster-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.poster-quick-actions {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.poster-quick-play {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring), background 0.18s ease;
}

.poster-quick-play:hover {
  transform: scale(1.05);
  background: var(--blue);
  border-color: transparent;
}

.poster-quick-dl {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--blue);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease-spring), background 0.18s ease;
}

.poster-quick-dl:hover {
  transform: scale(1.08);
  background: #fff;
}

.drama-info {
  padding: 12px 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.drama-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drama-desc {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

/* ==========================================================================
   Download Center (Grouped Job Cards & Circular Progress Ring)
   ========================================================================== */

.job-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.job-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.job-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.job-header:hover {
  background: var(--bg-hover);
}

.job-thumb {
  width: 52px;
  height: 68px;
  border-radius: 10px;
  background: var(--bg-secondary);
  object-fit: cover;
  flex-shrink: 0;
}

.job-main {
  flex: 1;
  min-width: 0;
}

.job-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.job-title {
  font-size: 15.5px;
  font-weight: 600;
}

.job-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.job-progress-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-input);
  margin-top: 9px;
  overflow: hidden;
}

.job-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  transition: width 0.35s var(--ease-spring);
}

.job-progress-fill.done {
  background: var(--green);
}

.job-progress-fill.failed {
  background: var(--red);
}

.job-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ring-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.ring-text {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
}

.job-items-drawer {
  border-top: 0.5px solid var(--separator);
  background: var(--bg-grouped);
  padding: 8px 16px 12px;
  max-height: 360px;
  overflow-y: auto;
}

.ep-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 11px;
  font-size: 13px;
}

.ep-row + .ep-row {
  border-top: 0.5px solid var(--separator);
}

.ep-status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.ep-status-pill.completed { background: rgba(52, 199, 89, 0.14); color: var(--green); }
.ep-status-pill.downloading { background: rgba(0, 122, 255, 0.14); color: var(--blue); }
.ep-status-pill.resolving { background: rgba(88, 86, 214, 0.15); color: var(--indigo); }
.ep-status-pill.queued { background: var(--bg-input); color: var(--text-secondary); }
.ep-status-pill.paused { background: rgba(255, 149, 0, 0.15); color: var(--orange); }
.ep-status-pill.failed { background: rgba(255, 59, 48, 0.15); color: var(--red); }

/* ==========================================================================
   iOS Modal Sheet & Direct Video Preview
   ========================================================================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-panel {
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 0.5px solid var(--separator-strong);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheetUp 0.32s var(--ease-spring);
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sheet-hero {
  position: relative;
  flex-shrink: 0;
  padding: 22px 26px 18px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  overflow: hidden;
  border-bottom: 0.5px solid var(--separator);
}

.sheet-hero-bg {
  position: absolute;
  inset: -24px;
  background-size: cover;
  background-position: center;
  filter: blur(42px) saturate(170%);
  opacity: 0.24;
  pointer-events: none;
}

.sheet-hero-cover {
  position: relative;
  width: 118px;
  height: 158px;
  border-radius: 16px;
  object-fit: cover;
  background: var(--bg-secondary);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
  flex-shrink: 0;
}

.sheet-hero-info {
  position: relative;
  flex: 1;
  min-width: 0;
}

.sheet-meta-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-secondary);
}

.sheet-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.sheet-close {
  position: relative;
  flex-shrink: 0;
}

.sheet-body {
  padding: 18px 26px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: block;
}

/* Synopsis Card */
.synopsis-card {
  background: var(--bg-grouped);
  border: 0.5px solid var(--separator);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.synopsis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.synopsis-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.synopsis-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-primary);
  margin: 0;
}

.synopsis-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-link-btn {
  border: none;
  background: transparent;
  color: var(--blue);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}

/* Built-in Theater Player */
.theater-card {
  background: #0b0b0e;
  border-radius: 18px;
  overflow: hidden;
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  color: #fff;
  margin-bottom: 18px;
}

.theater-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(28, 28, 32, 0.92);
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}

.theater-video-wrap {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theater-video-wrap video {
  width: 100%;
  max-height: 430px;
  display: block;
  background: #000;
}

.theater-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(24, 24, 28, 0.95);
  border-top: 0.5px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

.theater-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.14s var(--ease-spring);
}

.theater-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.theater-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.theater-btn.active {
  background: var(--blue);
  border-color: transparent;
}

/* Redesigned Episode Picker */
.ep-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.range-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  gap: 10px;
}

.ep-tile {
  position: relative;
  padding: 10px 11px;
  border-radius: 13px;
  border: 1px solid var(--separator);
  background: var(--bg-grouped);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s var(--ease-spring);
}

.ep-tile:hover {
  border-color: var(--blue);
}

.ep-tile.selected {
  background: var(--bg-active-pill);
  border-color: var(--blue);
}

.ep-tile.playing {
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.28);
}

.ep-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.ep-play-chip {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: none;
  background: var(--bg-elevated);
  color: var(--blue);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform 0.16s var(--ease-spring), background 0.16s ease, color 0.16s ease;
  flex-shrink: 0;
}

.ep-play-chip:hover,
.ep-tile.playing .ep-play-chip {
  background: var(--blue);
  color: #fff;
  transform: scale(1.08);
}

.ep-tile-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ep-check-circle {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  border: 1.5px solid var(--separator-strong);
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  color: transparent;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.ep-tile.selected .ep-check-circle {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.sheet-footer {
  flex-shrink: 0;
  padding: 14px 24px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ==========================================================================
   iOS Settings Inset Grouped List & Library
   ========================================================================== */

.inset-group {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--separator);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.inset-group-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 14px 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.inset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  min-height: 50px;
}

.inset-row + .inset-row {
  border-top: 0.5px solid var(--separator);
}

.inset-label {
  font-size: 14.5px;
  font-weight: 500;
}

.inset-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.ios-input {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 0.5px solid var(--separator);
  background: var(--bg-grouped);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.ios-input:focus {
  border-color: var(--blue);
}

.ios-switch {
  appearance: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  position: relative;
  cursor: pointer;
  transition: background 0.22s ease;
  border: none;
  flex-shrink: 0;
}

.ios-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
  transition: transform 0.22s var(--ease-spring);
}

.ios-switch:checked {
  background: var(--green);
}

.ios-switch:checked::after {
  transform: translateX(18px);
}

/* ==========================================================================
   Empty State, Skeleton, Toast, Mobile TabBar
   ========================================================================== */

.empty-card {
  padding: 54px 24px;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  border: 0.5px solid var(--separator);
  text-align: center;
  max-width: 560px;
  margin: 24px auto;
  box-shadow: var(--shadow-card);
}

.empty-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--bg-active-pill);
  color: var(--blue);
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}

.toast-root {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-pill {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border: 0.5px solid var(--separator-strong);
  box-shadow: var(--shadow-float);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: sheetUp 0.24s var(--ease-spring);
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 860px) {
  .sidebar {
    display: none;
  }
  .topbar {
    padding: 14px 16px 12px;
  }
  .content-body {
    padding: 16px 16px 96px;
  }
  .poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
  }
  .mobile-tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    height: 60px;
    border-radius: 22px;
    background: var(--bg-glass-strong);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    border: 0.5px solid var(--separator-strong);
    box-shadow: var(--shadow-float);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 30;
  }
  .mobile-tab-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
  }
  .mobile-tab-btn.active {
    color: var(--blue);
  }
}

.aria-form { gap: 12px; flex-wrap: wrap; }
.aria-form label { display: grid; gap: 4px; font-size: 13px; }
.aria-form input { max-width: 170px; }
@media (max-width: 650px) {
  .topbar-row { flex-wrap: wrap; align-items: flex-start; }
  .ios-search-wrap { width: 100%; min-width: 0; }
  .ios-search-box { min-width: 0; flex: 1; }
  .sheet-footer { align-items: stretch; flex-direction: column; gap: 8px; }
  .sheet-footer .btn-primary { flex: 1; }
  .job-header { flex-wrap: wrap; }
  .job-actions { margin-left: auto; }
  .ep-row { flex-wrap: wrap; gap: 6px; }
}

.card-detail { font-family: inherit; text-align: left; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.online-player { position: fixed; inset: 0; margin: 0; width: 100%; height: 100%; max-width: none; max-height: none; border: 0; background: black; padding: 0; }
.online-player iframe { display: block; width: 100%; height: 100%; border: 0; }
