:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #20242b;
  --muted: #68707c;
  --line: #dfe3e8;
  --accent: #1267d8;
  --accent-dark: #0f56b5;
  --success: #106b3f;
  --success-bg: #e7f6ef;
  --error: #b42318;
  --error-bg: #fde9e7;
  --orange: #ff9800;
}

* {
  box-sizing: border-box;
}

.system-galaxy-canvas {
  display: none !important;
  position: fixed !important;
  width: 0 !important;
  height: 0 !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-left: 60px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 60px;
  padding: 18px 10px;
  border-right: 0;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
}

.app-nav .icon-button:last-of-type {
  margin-top: auto;
  margin-bottom: 58px;
}

.brand {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
  border: 2px solid var(--orange);
  border-radius: 50%;
  color: var(--orange);
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #616772;
  font-size: 18px;
  text-decoration: none;
}

.icon-button:hover,
.icon-button.active {
  background: #fff3dc;
  color: var(--orange);
}

.app-nav .icon-button,
.app-nav .dark-mode-toggle {
  border: 0 !important;
}

.shell {
  position: absolute !important;
  top: 24px !important;
  right: 40px !important;
  left: 160px !important;
  width: auto;
  margin: 0 !important;
  padding-top: 0 !important;
  transform: none !important;
}

.page-head,
.toolbar,
.section-head,
.actions,
.backup-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
  min-height: 0;
  padding-top: 0;
}

.page-head [data-unified-switcher].is-inline {
  grid-column: 1;
  grid-row: 1;
  margin-left: 0 !important;
  align-self: center;
}

.page-head > div:not([data-unified-switcher]) {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  justify-self: center;
  text-align: center;
}

.page-head > .settings-tabs {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
}

.toolbar {
  margin-bottom: 14px;
}

.toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

.tabs,
.settings-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  height: 42px;
  min-width: 360px;
}

.page-head > div:not([data-unified-switcher]) > .eyebrow {
  display: none !important;
}

.view-head {
  align-items: flex-end;
}

.view-head .eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
  letter-spacing: 0;
}

.tab,
.settings-tab {
  min-width: 104px;
  height: 32px;
  background: transparent;
  color: #4b5563;
}

.tab:hover,
.settings-tab:hover {
  background: #eef2f7;
  color: #111827;
}

.tab.active,
.settings-tab.active {
  background: var(--accent);
  color: #fff;
}

.tab-panel,
.settings-view {
  display: none;
}

.settings-view[hidden] {
  display: none !important;
}

.tab-panel.active,
.settings-view.active {
  display: block;
}

.view-head {
  margin-bottom: 10px;
  padding-top: 0;
}

.panel,
.sync-panel,
.stats,
.backup-panel,
.table-wrap {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 14px;
}

.sync-panel {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr auto;
  gap: 12px 14px;
  align-items: end;
  padding: 14px;
}

.sync-panel-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.sync-panel-head h3 {
  margin: 0;
  font-size: 16px;
}

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

.field {
  margin-bottom: 16px;
}

.sync-panel .field,
.field-grid .field {
  margin-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 18px;
  align-items: end;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 650;
}

input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 15px;
}

select,
textarea {
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
}

select {
  height: 40px;
}

textarea {
  min-height: 96px;
  padding-top: 10px;
  resize: vertical;
  line-height: 1.45;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  font-weight: 650;
}

.switch input {
  width: 18px;
  height: 18px;
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.link-button:hover {
  background: var(--accent-dark);
}

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

button.secondary {
  min-width: 92px;
  background: #eef2f7;
  color: #374151;
}

button.secondary:hover {
  background: #e2e8f0;
}

button.copied {
  background: var(--success-bg);
  color: var(--success);
}

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

button.danger:hover {
  background: var(--error-bg);
}

.hint,
.status {
  color: var(--muted);
  font-size: 14px;
}

.hint {
  margin: 8px 0 0;
}

.inline-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.inline-status {
  margin: 0;
  text-align: right;
}

.status {
  margin-bottom: 14px;
}

.status[data-tone="success"],
.hint[data-tone="success"] {
  color: var(--success);
}

.status[data-tone="error"],
.hint[data-tone="error"] {
  color: var(--error);
}

.hint[data-tone="warning"] {
  color: #a16207;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.status-panel {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-panel div {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.status-panel div:last-child {
  border-right: 0;
}

.status-panel span,
.feed-card small,
.log-item small {
  color: var(--muted);
  font-size: 13px;
}

.stats div {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.stats div:last-child {
  border-right: 0;
}

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

.stats strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.backup-panel {
  padding: 16px 18px;
}

.backup-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
}

.inner-table {
  margin-top: 14px;
  margin-bottom: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

th {
  background: #f0f3f7;
  color: #3a414b;
  font-weight: 650;
}

tr:last-child td {
  border-bottom: 0;
}

[data-panel="subscriptions"] td:first-child,
[data-panel="subscriptions"] th:first-child {
  width: 70px;
}

[data-panel="subscriptions"] td:nth-child(2),
[data-panel="subscriptions"] th:nth-child(2) {
  width: 20%;
}

[data-panel="subscriptions"] td:nth-child(3),
[data-panel="subscriptions"] th:nth-child(3) {
  width: 92px;
}

[data-panel="subscriptions"] td:nth-child(4),
[data-panel="subscriptions"] th:nth-child(4) {
  width: 132px;
}

[data-panel="queue"] th:first-child {
  width: 170px;
}

[data-panel="queue"] th:nth-child(2) {
  width: 150px;
}

[data-panel="queue"] th:nth-child(3) {
  width: 90px;
}

[data-panel="queue"] th:nth-child(5) {
  width: 120px;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

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

a:hover {
  text-decoration: underline;
}

.avatar {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  background: #eef2f7;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-removed {
  background: var(--error-bg);
  color: var(--error);
}

.badge-blocked {
  background: var(--error-bg);
  color: var(--error);
}

.inline-link {
  min-height: 0;
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.inline-link:hover {
  text-decoration: underline;
}

.is-removed td,
.is-blocked td {
  color: var(--muted);
}

.result-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px 16px;
  align-items: center;
}

.result-grid span {
  color: var(--muted);
  font-size: 14px;
}

.result-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.result-exists {
  color: #7c3aed;
}

.result-failed,
.result-error {
  color: var(--error);
}

.result-retry_pending,
.result-retry_wait {
  color: #b45309;
}

.settings-grid,
.add-grid,
.queue-grid {
  display: grid;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}

.settings-grid {
  grid-template-columns: minmax(220px, 320px) 200px;
}

.add-grid {
  grid-template-columns: 140px 1fr 220px 100px;
}

.platform-add-grid {
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 260px) 100px;
}

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

.section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-panel {
  border-color: rgba(59, 130, 246, 0.35);
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-color: rgba(180, 35, 24, 0.22);
}

.auth-copy {
  display: grid;
  gap: 5px;
}

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

.auth-copy strong {
  font-size: 20px;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-panel.success {
  border-color: rgba(16, 107, 63, 0.22);
}

.auth-panel.warning {
  border-color: rgba(161, 98, 7, 0.28);
}

.auth-panel.error {
  border-color: rgba(180, 35, 24, 0.38);
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 750;
}

.advanced-stack {
  display: grid;
  gap: 22px;
  margin-top: 18px;
}

.advanced-stack > section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.compact-actions {
  margin-top: 14px;
}

.compact-log {
  max-height: 260px;
  overflow: auto;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f7;
}

.feed-list,
.log-list,
.pending-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.feed-card,
.log-item,
.pending-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.feed-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 76px 86px 168px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}

.log-item {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.pending-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.pending-card > div:first-child {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.pending-card strong,
.pending-card small,
.pending-card a,
.pending-card p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.pending-card small {
  color: var(--muted);
  font-size: 13px;
}

.pending-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.feed-avatar {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef2f7;
  object-fit: cover;
}

.feed-card header,
.feed-actions,
.feed-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feed-card header {
  min-width: 0;
}

.feed-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.feed-card h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-main h3,
.feed-main small,
.feed-main p,
.feed-technical span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-main p {
  margin: 0;
  font-size: 13px;
}

.feed-technical {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.feed-technical summary {
  width: max-content;
  cursor: pointer;
  user-select: none;
}

.feed-technical span {
  display: block;
  max-width: 100%;
  margin-top: 4px;
}

.feed-meta {
  align-items: flex-end;
  flex-direction: column;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.feed-meta strong {
  color: var(--text);
  font-size: 14px;
}

.feed-switch {
  justify-content: center;
}

.feed-actions {
  justify-content: flex-end;
}

.feed-actions button {
  min-width: 76px;
}

.badge.douyin {
  background: #111827;
  color: #fff;
}

.badge.bilibili {
  background: #dff5ff;
  color: #0369a1;
}

.badge.blocked {
  background: var(--error-bg);
  color: var(--error);
}

.feed-card.is-blocked {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff8f7;
}

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

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

.warning {
  color: #a16207;
}

.retry-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.login-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.login-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.login-dialog-card {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.login-dialog-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

@media (max-width: 860px) {
  body {
    padding-left: 0;
    padding-top: 58px;
  }

  .app-nav {
    inset: 0 0 auto 0;
    flex-direction: row;
    width: 100%;
    height: 58px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-nav .icon-button:first-of-type,
  .app-nav .icon-button:last-of-type {
    margin: 0;
  }

  .shell {
    position: static;
    width: min(100vw - 20px, 1120px);
    margin: 20px auto;
  }

  .page-head,
  .toolbar,
  .section-head,
  .sync-panel-head,
  .section-actions,
  .backup-panel,
  .feed-card header,
  .feed-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-head {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .page-head [data-unified-switcher].is-inline,
  .page-head > div:not([data-unified-switcher]),
  .page-head > .settings-tabs {
    grid-column: 1;
    grid-row: auto;
  }

  .tabs,
  .tab,
  .settings-tabs,
  .settings-tab,
  .toolbar button,
  .input-row,
  .sync-panel,
  .field-grid,
  .stats,
  .settings-grid,
  .add-grid,
  .platform-add-grid,
  .queue-grid,
  .status-panel {
    width: 100%;
  }

  .tabs,
  .settings-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .input-row,
  .sync-panel,
  .field-grid,
  .stats,
  .settings-grid,
  .add-grid,
  .queue-grid,
  .status-panel {
    grid-template-columns: 1fr;
  }

  .stats div,
  .status-panel div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats div:last-child,
  .status-panel div:last-child {
    border-bottom: 0;
  }

  .sync-panel-head .inline-status {
    text-align: left;
  }

  .feed-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .pending-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .feed-meta,
  .feed-switch,
  .feed-actions {
    grid-column: 2;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .feed-meta,
  .feed-actions {
    flex-direction: row;
  }
}
