:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #242424;
  --muted: #6b7280;
  --line: #dfe4ea;
  --green: #12c66a;
  --green-dark: #0d9f55;
  --amber: #9a6a12;
  --red: #c2413f;
  --green-soft: #e8fff3;
  --shadow: 0 18px 48px rgba(20, 31, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 8%, rgba(18, 198, 106, 0.09), transparent 24%),
    radial-gradient(circle at 12% 0%, rgba(18, 198, 106, 0.07), transparent 28%),
    linear-gradient(180deg, #fbfbf9 0%, var(--bg) 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 54px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(223, 228, 234, 0.72);
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.auth-card {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(20, 31, 48, 0.06);
}

.user-line {
  min-height: 0;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.auth-actions,
.download-row,
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.secondary,
.ghost,
.chip {
  min-height: 36px;
  padding: 0 14px;
  color: var(--text);
  background: #f1f2ee;
  border: 1px solid var(--line);
}

.ghost {
  color: var(--red);
  background: #fff7f6;
}

.login-panel,
.query-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  grid-template-columns: 80px minmax(160px, 220px) 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
}

.panel-title {
  align-self: center;
  color: #111827;
  font-size: 16px;
  font-weight: 700;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid #d7d8d1;
  border-radius: 8px;
  color: var(--text);
  background: #fcfcfd;
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 16px 18px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(18, 198, 106, 0.15);
}

.login-panel button,
.query-row button {
  min-height: 46px;
  padding: 0 26px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 22px rgba(18, 198, 106, 0.24);
}

.login-panel button:hover,
.query-row button:hover {
  background: var(--green-dark);
}

.query-panel {
  padding: 16px;
}

.query-row {
  display: grid;
  grid-template-columns: 1fr 124px;
  gap: 14px;
  align-items: stretch;
  margin-top: 10px;
}

.message {
  min-height: 24px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

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

.message.ok {
  color: var(--green-dark);
}

.result-panel {
  overflow: hidden;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.result-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

#platformBadge {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px solid #bfeccc;
  font-size: 13px;
  font-weight: 700;
}

.result-body {
  display: grid;
  grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
  gap: 22px;
  padding: 20px;
}

.media-frame {
  overflow: hidden;
  border-radius: 8px;
  background: #111318;
  aspect-ratio: 9 / 12;
  max-height: 650px;
}

.media-frame.wide {
  aspect-ratio: 16 / 10;
  background: #f0f0ec;
}

.media-frame video,
.media-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-block {
  min-width: 0;
}

.source-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 116px;
  margin-top: 12px;
  overflow: auto;
  padding: 2px;
}

.source-switcher button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #f5f5f1;
}

.source-switcher button.active {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.meta {
  min-width: 0;
}

.carousel {
  min-width: 0;
}

.carousel-stage {
  overflow: hidden;
  border-radius: 8px;
  background: #f0f0ec;
  aspect-ratio: 4 / 5;
}

.carousel-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.carousel-controls {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.carousel-controls button {
  width: 42px;
  height: 38px;
  color: #fff;
  background: var(--green);
  font-size: 24px;
  line-height: 1;
}

.carousel-controls span {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.thumb-row button {
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f0f0ec;
  aspect-ratio: 1;
}

.thumb-row button.active {
  border-color: var(--green);
}

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

.author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.author img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #eceee8;
}

.author strong {
  display: block;
  font-size: 17px;
}

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

.title {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: 0;
}

.desc {
  margin: 0 0 16px;
  color: #4b5563;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stats {
  margin-bottom: 18px;
  color: var(--muted);
}

.stats span {
  padding: 6px 10px;
  border-radius: 8px;
  background: #f4f7fb;
}

.download-row {
  margin-bottom: 12px;
}

.download-row a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  text-decoration: none;
  font-weight: 700;
}

.source-link {
  color: var(--green-dark);
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-size: 14px;
}

.empty-media {
  display: grid;
  place-items: center;
  min-height: 260px;
  border-radius: 8px;
  color: var(--muted);
  background: #f1f2ee;
}

.raw-json {
  border-top: 1px solid var(--line);
  padding: 14px 20px 18px;
}

.raw-json summary {
  cursor: pointer;
  color: var(--muted);
}

pre {
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #1f2521;
  color: #dce9dd;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .topbar,
  .result-body {
    grid-template-columns: 1fr;
    display: grid;
  }

  .auth-card,
  .query-row,
  .login-panel {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .auth-card {
    align-items: flex-start;
  }

  h1 {
    font-size: 26px;
  }

  .result-body {
    padding: 16px;
  }
}
