:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #65736b;
  --line: #dce4df;
  --accent: #16775b;
  --accent-strong: #0e5c45;
  --warn: #9b5a12;
  --danger: #b23838;
  --soft: #e9f2ed;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.panel,
.player-panel,
.detail-grid > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
}

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

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.topbar p,
.watch-top p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  margin-top: 14px;
  padding: 18px;
}

.catalog-form,
.single-vod-form,
.collect-form {
  display: grid;
  gap: 12px;
  align-items: end;
}

.catalog-form {
  grid-template-columns: repeat(5, minmax(118px, 1fr));
}

.single-vod-form {
  margin-top: 12px;
  grid-template-columns: minmax(220px, 1.8fr) minmax(160px, 1fr) minmax(120px, 0.7fr) auto;
}

.collect-form {
  grid-template-columns: minmax(260px, 1.8fr) minmax(280px, 1fr) auto minmax(120px, 0.5fr) auto;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfb;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(22, 119, 91, 0.18);
  border-color: var(--accent);
}

.form-help {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mode-row label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  cursor: pointer;
  color: var(--muted);
}

.mode-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-row label:has(input:checked) {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-strong);
  font-weight: 650;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--muted);
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.small-button,
.danger-button,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button {
  height: 42px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.small-button,
.back-link {
  background: #fbfcfb;
  color: var(--ink);
}

.danger-button {
  background: #fff7f7;
  color: var(--danger);
  border-color: #efc6c6;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stats div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(430px, 0.85fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

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

.section-head.compact {
  margin-bottom: 12px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.video-list,
.play-id-list {
  display: grid;
  gap: 10px;
}

.video-card,
.play-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfb;
}

.vod-card {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfb;
}

.vod-cover {
  width: 128px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef2ef;
}

.vod-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.vod-info {
  min-width: 0;
}

.vod-line,
.vod-desc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.vod-desc {
  color: #46544d;
}

.vod-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.episode-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.episode-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.episode-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.episode-name strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 13px;
}

.episode-name span {
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.episode-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.muted-button {
  color: var(--muted);
}

.card-title-row,
.meta-row,
.quality-row,
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-title-row {
  justify-content: space-between;
}

.meta-row {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.quality-row {
  margin-top: 10px;
}

code,
.url-line {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.url-line {
  display: block;
  margin-top: 10px;
  color: #3f4d46;
}

.type-tag,
.pill,
.mode-ok,
.mode-warn {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  text-decoration: none;
}

.type-tag {
  background: #edf0ee;
  color: #4c5a53;
}

.pill {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.pill.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--soft);
}

.mode-ok {
  background: var(--soft);
  color: var(--accent-strong);
}

.mode-warn {
  background: #fff2df;
  color: var(--warn);
}

.card-actions {
  align-content: start;
  justify-content: flex-end;
  width: 210px;
}

.empty,
.notice {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  background: #fbfcfb;
}

.watch-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.watch-top {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.player-panel {
  padding: 14px;
}

.player-panel video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #07110d;
}

.player-panel .notice {
  margin-bottom: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.detail-grid > div {
  padding: 14px;
}

.detail-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .catalog-form,
  .single-vod-form,
  .collect-form,
  .content-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    width: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app-shell,
  .watch-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar,
  .watch-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .mode-row,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .video-card,
  .play-card,
  .vod-card,
  .episode-row {
    grid-template-columns: 1fr;
  }

  .vod-cover {
    width: 100%;
    max-width: 180px;
  }

  .episode-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 420px) {
  .stats {
    grid-template-columns: 1fr;
  }
}
