:root {
  color-scheme: light;
  --blue: #1a73e8;
  --blue-soft: #eaf2ff;
  --green: #188038;
  --red: #d93025;
  --ink: #1f2328;
  --muted: #667085;
  --line: #e4e8ef;
  --soft: #f6f8fb;
  --panel: #fff;
  --shadow: 0 18px 45px rgba(31, 35, 40, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #fff;
}

button, input, textarea { font: inherit; }

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #c9d3e2;
  box-shadow: 0 4px 14px rgba(31, 35, 40, .08);
}

input, textarea {
  outline: 0;
}

.hidden { display: none !important; }

.app-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 68px;
  padding: 10px 0;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand-mark {
  border: 0;
  padding: 0;
  min-height: auto;
  background: transparent;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark span {
  color: var(--blue);
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.nav-item {
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.nav-item.active {
  color: #174ea6;
  background: var(--blue-soft);
  border-color: #d4e4ff;
}

.user-box {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-box input {
  width: 136px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
}

.user-pill,
.user-limit {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.view {
  display: none;
  padding-top: 24px;
}

.view.active {
  display: block;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 24px;
  align-items: end;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fff 0, #f9fbff 100%);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hero-panel h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.02;
}

.hero-panel p:not(.eyebrow) {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-stat {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.hero-stat strong,
.hero-stat span {
  display: block;
}

.hero-stat strong {
  margin-bottom: 8px;
  font-size: 18px;
}

.hero-stat span {
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 35, 40, .05);
}

.search-panel {
  display: grid;
  gap: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  color: var(--muted);
  background: var(--soft);
}

.tab.active {
  color: #174ea6;
  background: var(--blue-soft);
  border-color: #d4e4ff;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-row input,
.multi-box textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
}

.multi-box {
  display: grid;
  gap: 10px;
}

.multi-box textarea {
  min-height: 130px;
  padding: 14px;
  resize: vertical;
  line-height: 1.45;
}

.multi-box button {
  justify-self: end;
}

.primary,
.search-row button,
.multi-box button {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.secondary {
  background: #fff;
}

.result-panel {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 26px;
}

.poster img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.details {
  min-width: 0;
}

.catalog-tabs,
.controls,
.destination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.catalog-tabs {
  margin-bottom: 10px;
}

.active-choice,
.choice.selected {
  color: #174ea6;
  background: var(--blue-soft);
  border-color: #d4e4ff;
}

#title {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.08;
}

#description {
  color: var(--muted);
  line-height: 1.55;
}

.controls {
  margin: 18px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.work-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr);
  gap: 18px;
}

.work-card,
.dash-block {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.section-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.section-head h3,
.dash-block h3,
.panel-head h2 {
  margin: 0;
}

.section-head span,
.panel-head p,
.status-line,
.path {
  color: var(--muted);
}

.section-head span {
  font-size: 13px;
}

.episode-list,
.quality-list,
.fs-list {
  max-height: 390px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.season {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.season:first-child {
  border-top: 0;
}

.season-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.episode,
.quality,
.fs-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  text-align: left;
}

.episode span,
.quality span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quality.selected {
  color: #174ea6;
  background: var(--blue-soft);
}

.destination-head {
  margin-top: 18px;
}

.path {
  min-height: 34px;
  display: flex;
  align-items: center;
  margin: 8px 0 12px;
  font-size: 13px;
  word-break: break-word;
}

.download-action {
  width: 100%;
}

.terminal {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid #262b33;
  border-radius: 8px;
  background: #1f2328;
}

.terminal > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: #f6f8fa;
  border-bottom: 1px solid #3b424d;
}

.terminal span {
  color: #b8c0cc;
  font-size: 13px;
}

pre {
  margin: 0;
  max-height: 300px;
  overflow: auto;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--soft);
  white-space: pre-wrap;
}

.terminal pre {
  max-height: 250px;
  color: #e8edf5;
  background: #1f2328;
  border: 0;
}

.job-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.job-summary div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.job-summary strong,
.job-summary span {
  display: block;
}

.job-summary strong {
  font-size: 26px;
}

.job-summary span {
  color: var(--muted);
}

.job-list,
.compact-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.job-row {
  display: grid;
  grid-template-columns: 104px 120px minmax(0, 1fr) minmax(120px, 220px) 54px;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 0 14px;
  text-align: left;
  border-radius: 8px;
  background: #fff;
}

.compact-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  text-align: left;
}

.job-row span,
.compact-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-status {
  justify-self: start;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--soft);
}

.job-status.running,
.job-status.queued {
  color: #174ea6;
  background: var(--blue-soft);
}

.job-status.done {
  color: var(--green);
  background: #e9f5ee;
}

.job-status.error {
  color: var(--red);
  background: #fdeceb;
}

.mini-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8edf4;
}

.mini-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.job-detail {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.detail-head h3,
.detail-head p {
  margin: 0;
}

.detail-head strong {
  font-size: 24px;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8edf4;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.file-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.file-wait {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

.file-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d4e4ff;
  border-radius: 8px;
  color: #174ea6;
  background: var(--blue-soft);
  text-decoration: none;
}

.password-grid {
  display: grid;
  gap: 9px;
}

.password-grid input,
.modal-panel input,
.user-row input[type="number"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.users {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 90px auto auto 96px auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.admin-user-meta {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--soft);
}

.user-row:first-child {
  border-top: 0;
}

.user-row input[type="number"] {
  width: 96px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 35, 40, .54);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(31, 35, 40, .28);
}

.compact-modal {
  width: min(560px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.modal-head h2 {
  margin: 0;
}

.modal-panel input {
  width: 100%;
  margin-bottom: 10px;
}

.destination-choice {
  display: grid;
  gap: 10px;
  margin: 8px 0 12px;
}

.destination-choice .choice {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px 14px;
  text-align: left;
}

.destination-choice strong,
.destination-choice span {
  display: block;
}

.destination-choice span {
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 980px) {
  .topbar,
  .hero-panel,
  .result-panel,
  .work-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .main-nav {
    justify-content: flex-start;
    overflow: auto;
  }

  .user-box {
    justify-content: flex-start;
  }

  .poster {
    width: min(230px, 100%);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 10px;
  }

  .hero-panel,
  .panel {
    padding: 16px;
  }

  .search-row,
  .job-row,
  .job-summary,
  .compact-row,
  .user-row {
    grid-template-columns: 1fr;
  }

  .search-row button,
  .multi-box button {
    width: 100%;
  }
}
