:root {
  --bg: #f4efe7;
  --panel: rgba(255, 251, 245, 0.92);
  --panel-strong: #fffdf8;
  --line: rgba(125, 92, 58, 0.18);
  --text: #2a2118;
  --muted: #716256;
  --accent: #c24f2d;
  --accent-strong: #8f3219;
  --accent-soft: rgba(194, 79, 45, 0.12);
  --shadow: 0 18px 50px rgba(72, 42, 20, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(210, 133, 86, 0.22), transparent 32%),
    radial-gradient(circle at top right, rgba(130, 168, 153, 0.2), transparent 28%),
    linear-gradient(180deg, #f8f1e6 0%, #f1e7d8 100%);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.control-panel,
.preview-panel {
  min-height: 0;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-header,
.control-card,
.preview-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-header {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.panel-header h1,
.section-title-row h2 {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
}

.panel-header h1 {
  font-size: 32px;
  line-height: 1.1;
}

.panel-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.control-card {
  padding: 20px;
}

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

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

.upload-zone {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1.5px dashed rgba(194, 79, 45, 0.35);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 248, 240, 0.92), rgba(255, 242, 229, 0.86));
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.is-ready {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(194, 79, 45, 0.12);
}

.upload-zone.is-busy {
  opacity: 0.7;
  pointer-events: none;
}

.upload-title {
  font-size: 18px;
  font-weight: 700;
}

.upload-copy {
  color: var(--muted);
  line-height: 1.6;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.meta-label {
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid rgba(125, 92, 58, 0.2);
  border-radius: 14px;
  background: var(--panel-strong);
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(194, 79, 45, 0.12);
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

button {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  color: #fff8f4;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: transform 160ms ease, opacity 160ms ease;
}

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

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button-secondary,
.button-tertiary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(125, 92, 58, 0.16);
}

.button-tertiary {
  padding: 8px 12px;
  font-size: 12px;
}

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

.meta-card,
.link-card {
  padding: 14px;
  border: 1px solid rgba(125, 92, 58, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.meta-card strong,
.link-card a {
  display: block;
  margin-top: 8px;
  word-break: break-all;
}

.link-card {
  margin-top: 14px;
}

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

.preview-panel {
  display: flex;
}

.preview-card {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.stage-frame {
  position: relative;
  flex: 1;
  min-height: 520px;
  padding: 20px;
  border-radius: 28px;
  border: 1px solid rgba(125, 92, 58, 0.14);
  background:
    linear-gradient(135deg, rgba(255, 249, 241, 0.94), rgba(247, 239, 227, 0.88)),
    repeating-linear-gradient(
      45deg,
      rgba(194, 79, 45, 0.03) 0,
      rgba(194, 79, 45, 0.03) 12px,
      rgba(255, 255, 255, 0) 12px,
      rgba(255, 255, 255, 0) 24px
    );
  overflow: auto;
}

.stage-empty #preview-canvas {
  display: none;
}

#preview-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(44, 28, 16, 0.12);
  background: #fff;
}

.stage-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.stage-ready .stage-placeholder {
  display: none;
}

.stage-placeholder p {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  color: var(--muted);
  line-height: 1.7;
}

.result-item {
  padding: 14px;
  border: 1px solid rgba(125, 92, 58, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.result-item strong {
  display: block;
  margin-bottom: 8px;
}

.result-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.raw-response {
  margin: 0;
  padding: 16px;
  max-height: 280px;
  overflow: auto;
  border-radius: 18px;
  background: #2c241d;
  color: #f8f3ec;
  font-size: 12px;
  line-height: 1.7;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 560px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
    gap: 14px;
  }

  .panel-header h1 {
    font-size: 28px;
  }

  .field-grid,
  .meta-grid,
  .button-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .stage-frame {
    min-height: 420px;
    padding: 14px;
  }
}
