:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-2: #0b5d58;
  --accent-soft: #eef8f6;
  --warn: #b45309;
  --warn-soft: #fff8ec;
  --error: #b42318;
  --error-soft: #fef3f2;
  --ok: #067647;
  --radius: 8px;
  --radius-sm: 6px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  min-height: 38px;
}

button:hover {
  background: var(--accent-2);
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.secondary:hover {
  background: var(--accent-soft);
}

button.small {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  outline: none;
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

textarea {
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar {
  max-width: 1420px;
  margin: 0 auto;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px) minmax(240px, 320px);
  gap: 16px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand .sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.worker-box {
  display: grid;
  gap: 6px;
}

.worker-box label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.status {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.status.ok {
  color: var(--ok);
  border-color: #b7e4cd;
  background: #f0fdf4;
}

.status.warn {
  color: var(--warn);
  border-color: #f3d9a8;
  background: var(--warn-soft);
}

.status.danger {
  color: var(--error);
  border-color: #f5c2bd;
  background: var(--error-soft);
}

.main {
  max-width: 1420px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 22px 28px;
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.col {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.panel h2 {
  margin: 0;
  padding: 14px 14px 0;
  font-size: 15px;
  line-height: 1.3;
}

.panel h2 .tag {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.panel .body,
.controls,
.parse-box {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.meta {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 54px;
  background: #fbfcfd;
  min-width: 0;
}

.meta b {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.meta span {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 14px;
}

.tabs button {
  white-space: nowrap;
  padding: 7px 11px;
  min-height: 34px;
  background: #fff;
  color: var(--accent);
  border-color: var(--line);
}

.tabs button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 130px auto;
  gap: 8px;
  padding: 0 14px 12px;
  align-items: center;
}

.toolbar .search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  grid-column: 1 / -1;
}

.toolbar .page-box {
  display: grid;
  grid-template-columns: 84px auto;
  gap: 6px;
  align-items: center;
  justify-self: start;
}

.toolbar .page-box input {
  padding: 7px 8px;
  min-height: 34px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  padding: 0 14px 12px;
  overflow-wrap: anywhere;
}

.hint.flush {
  padding: 0;
}

.danger {
  color: var(--error);
}

.warn {
  color: var(--warn);
}

.ok {
  color: var(--ok);
}

.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
  background: #fbfcfd;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.notice.danger {
  border-color: #f5c2bd;
  background: var(--error-soft);
  color: var(--error);
}

.notice.warn {
  border-color: #f3d9a8;
  background: var(--warn-soft);
  color: var(--warn);
}

.notice.ok {
  border-color: #b7e4cd;
  background: #f0fdf4;
  color: var(--ok);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
  padding: 0 14px 14px;
  min-height: 120px;
}

.card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-height: 0;
}

.card:hover {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(15, 118, 110, .12);
}

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

.thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #e7ebf0;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #e7ebf0;
}

.thumb-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  background: #e7ebf0;
}

.thumb:not(.broken) .thumb-fallback {
  display: none;
}

.thumb.broken .thumb-fallback {
  display: grid;
}

.thumb.broken img {
  visibility: hidden;
}

.card-body {
  display: grid;
  gap: 4px;
  align-content: start;
  min-width: 0;
}

.card-title {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: #fbfcfd;
}

.sentinel {
  height: 1px;
}

.load-more {
  display: grid;
  justify-content: center;
  padding: 0 14px 14px;
}

.load-more button {
  min-width: 220px;
}

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

.detail-head h2 {
  padding: 0;
  font-size: 17px;
}

.detail-head .sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(120px, 168px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.detail-poster {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #e7ebf0;
  aspect-ratio: 3 / 4;
}

.detail-poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.stream {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
  overflow-wrap: anywhere;
  min-width: 0;
}

.stream-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.stream strong {
  color: var(--ok);
  font-size: 13px;
}

.tracks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
  max-height: 208px;
  overflow: auto;
  padding: 1px;
}

.tracks button {
  min-width: 68px;
  padding: 7px 9px;
  min-height: 34px;
  background: #fff;
  color: var(--accent);
  border-color: var(--line);
}

.tracks button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tracks button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.manual {
  margin-top: 10px;
  grid-template-columns: 96px auto;
  justify-content: start;
}

video {
  width: 100%;
  max-height: 460px;
  background: #111827;
  border-radius: var(--radius);
}

.stream-url {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 42px;
}

.stream-url.warn {
  border-color: #f3d9a8;
  background: var(--warn-soft);
  color: var(--warn);
}

.stream-url.danger {
  border-color: #f5c2bd;
  background: var(--error-soft);
  color: var(--error);
}

.invite {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.invite-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #e7ebf0;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: none;
}

.invite-name {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.invite-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.invite-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfd;
  padding: 9px 10px;
}

.invite-code-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--accent);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.invite-reward {
  border: 1px solid #b7e4cd;
  border-radius: var(--radius-sm);
  background: #f0fdf4;
  color: var(--ok);
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.downloads a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  font-size: 13px;
  min-height: 36px;
}

.downloads a:hover {
  background: var(--accent-2);
}

.downloads a.secondary {
  background: #fff;
  color: var(--accent);
}

.invite-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

details.raw {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfd;
  padding: 8px 10px;
}

details.raw summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

details.raw pre {
  margin: 8px 0 0;
  max-height: 260px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.copied {
  background: var(--ok) !important;
  border-color: var(--ok) !important;
  color: #fff !important;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }

  .toolbar .page-box {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 980px) {
  .topbar,
  .main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar,
  .main {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }
}

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

  .toolbar .page-box {
    grid-column: auto;
  }

  .detail-body {
    grid-template-columns: 1fr;
  }

  .detail-poster {
    max-width: 190px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .brand h1 {
    font-size: 19px;
  }
}

/* 邀请结果里的剧集卡片 */
.invite-drama {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}
.invite-drama-pic {
  width: 72px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  background: #eef1f5;
  flex: 0 0 auto;
}
.invite-drama-body { min-width: 0; display: grid; gap: 6px; }
.invite-drama-name { font-weight: 600; overflow-wrap: anywhere; }
.invite-drama-sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

/* 邀请面板通栏 */
#invitePanel { grid-column: 1 / -1; }
.main { align-items: start; }
#invitePanel .row { grid-template-columns: minmax(0, 1fr) auto; }
#invitePanel .invite { padding: 0 14px 14px; }
