:root {
  color-scheme: light;
  --ink: #171b1d;
  --muted: #657072;
  --paper: #faf8f2;
  --surface: #ffffff;
  --line: #ded9cc;
  --accent: #f04452;
  --accent-deep: #b91f34;
  --green: #247a5a;
  --green-soft: #d9efe5;
  --gold: #f4c95d;
  --shadow: 0 22px 60px rgba(26, 29, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(135deg, rgba(240, 68, 82, 0.1), transparent 32%),
    linear-gradient(225deg, rgba(36, 122, 90, 0.12), transparent 34%),
    var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(23, 27, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 27, 29, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(240, 68, 82, 0.22);
}

.api-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9a442;
}

.status-ok {
  background: #27a96f;
}

.status-error {
  background: #d93544;
}

.extractor {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: 22px;
  min-height: 360px;
  align-items: stretch;
}

.intro,
.input-panel,
.result-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.intro {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 34px;
  color: #fff;
  background:
    linear-gradient(150deg, rgba(23, 27, 29, 0.94), rgba(23, 27, 29, 0.58)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 18px),
    linear-gradient(135deg, #21433b, #172528);
}

.eyebrow {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 520px;
  font-size: 64px;
  line-height: 0.98;
}

h2 {
  font-size: 24px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
}

.support-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.support-list span {
  padding: 8px 12px;
  color: #11201d;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  font-size: 13px;
}

.input-panel {
  padding: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.input-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.url-input {
  flex: 1;
  min-height: 180px;
  width: 100%;
  resize: vertical;
  padding: 18px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.7;
  outline: none;
}

.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 68, 82, 0.15);
}

.input-actions,
.tool-row,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.loading-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  overflow: hidden;
  background: rgba(240, 68, 82, 0.12);
}

.loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  animation: loading-slide 1.1s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(260%);
  }
}

.icon-button,
.ghost-button,
.primary-button,
.text-button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--line);
}

.icon-button {
  width: 44px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  font-size: 18px;
}

.ghost-button {
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
}

.icon-button:hover,
.ghost-button:hover,
.history-item:hover {
  border-color: rgba(240, 68, 82, 0.5);
  transform: translateY(-1px);
}

.primary-button {
  min-width: 116px;
  padding: 0 22px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(240, 68, 82, 0.22);
}

.primary-button:hover {
  background: #d93445;
}

.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.text-button {
  min-height: 34px;
  padding: 0;
  color: var(--accent-deep);
  background: transparent;
  border: 0;
}

.image-action-button {
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  margin-top: 22px;
  align-items: start;
}

.result-panel,
.history-panel {
  padding: 24px;
}

.empty-state {
  min-height: 330px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 22px;
}

.hidden {
  display: none !important;
}

.result-card {
  display: grid;
  gap: 20px;
}

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

.result-meta span {
  padding: 7px 10px;
  color: #744a08;
  background: #fff4cc;
  border-radius: 999px;
  font-size: 13px;
}

.author-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.author-row img,
.avatar-fallback {
  width: 46px;
  height: 46px;
  border-radius: 50%;
}

.author-row img {
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 700;
}

.author-row strong,
.author-row span {
  display: block;
}

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

.tool-row {
  flex-wrap: wrap;
}

.content-block {
  display: grid;
  gap: 12px;
}

.content-block pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 18px;
  line-height: 1.8;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.tag-list span {
  padding: 7px 10px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 13px;
}

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

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

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.image-card {
  margin: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-card img {
  width: 100%;
  aspect-ratio: 1 / 1.25;
  display: block;
  object-fit: cover;
  background: #eee8dd;
}

.image-card figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.image-card a {
  color: var(--accent-deep);
  text-decoration: none;
}

.image-card button {
  color: var(--accent-deep);
}

.is-mini-program .topbar {
  padding-top: 6px;
}

.no-images,
.history-empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

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

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  width: 100%;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

.history-item strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.45;
}

.history-item span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120px);
  width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  color: #fff;
  text-align: center;
  background: var(--ink);
  border-radius: 8px;
  transition: transform 180ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: var(--green);
}

.toast.error {
  background: var(--accent-deep);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 20px, 1160px);
    padding-top: 10px;
  }

  .extractor,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px 0;
    background: rgba(250, 248, 242, 0.86);
    backdrop-filter: blur(12px);
  }

  .intro {
    min-height: 260px;
    padding: 26px;
  }

  h1 {
    font-size: 40px;
  }

  .input-panel,
  .result-panel,
  .history-panel {
    padding: 18px;
  }

  .input-actions {
    display: grid;
    grid-template-columns: 44px 1fr 1fr;
  }

  .input-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
