:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #6e746f;
  --line: #d8d4c9;
  --surface: #fffdfa;
  --surface-2: #f2eee6;
  --accent: #b9772c;
  --accent-strong: #7c3f16;
  --green: #35584a;
  --shadow: 0 22px 64px rgba(50, 42, 31, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(178, 119, 44, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(53, 88, 74, 0.14), transparent 42%),
    #f6f2ea;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(18px, 4vw, 44px);
}

.workspace {
  width: min(1440px, 100%);
  min-height: calc(100vh - clamp(36px, 8vw, 88px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(360px, 450px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.panel,
.preview-panel,
.gallery-panel {
  border: 1px solid rgba(70, 55, 36, 0.12);
  background: rgba(255, 253, 250, 0.9);
  box-shadow: var(--shadow);
}

.panel {
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

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

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.16;
  letter-spacing: 0;
}

.count-badge {
  flex: 0 0 auto;
  min-width: 72px;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  display: inline-grid;
  place-items: center;
  color: #f8efe1;
  background: var(--green);
  font-size: 15px;
  font-weight: 700;
}

.field-label,
.settings-grid span {
  display: block;
  margin-bottom: 9px;
  color: #4e514b;
  font-size: 14px;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea:focus,
input:focus {
  border-color: rgba(124, 63, 22, 0.65);
  box-shadow: 0 0 0 4px rgba(185, 119, 44, 0.14);
}

textarea {
  min-height: 300px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
}

input {
  height: 44px;
  padding: 0 13px;
}

.settings-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.button:disabled {
  cursor: progress;
  opacity: 0.66;
  transform: none;
}

.primary {
  flex: 1;
  color: #fff8eb;
  background: linear-gradient(135deg, #a35d1d, #5f3218);
  box-shadow: 0 12px 24px rgba(124, 63, 22, 0.22);
}

.secondary {
  color: var(--accent-strong);
  background: #f5eadb;
}

.status-line {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.preview-panel,
.gallery-panel {
  border-radius: 8px;
  min-width: 0;
}

.preview-panel {
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 34px);
  overflow: hidden;
}

.preview-frame {
  width: 100%;
  min-width: 0;
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(25, 21, 17, 0.22);
  background: #ede7dc;
}

.gallery-panel {
  grid-column: 1 / -1;
  padding: 22px;
}

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

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.image-card {
  min-width: 0;
  border: 1px solid rgba(70, 55, 36, 0.12);
  border-radius: 8px;
  background: #fffaf2;
  overflow: hidden;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  background: #080808;
}

.image-meta {
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.image-meta strong {
  min-width: 0;
  color: #26221b;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.image-actions {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: #fff8eb;
  background: var(--green);
  cursor: pointer;
  text-decoration: none;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:disabled {
  cursor: progress;
  opacity: 0.65;
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .preview-frame img {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .workspace {
    max-width: calc(100vw - 20px);
    overflow: hidden;
  }

  .panel,
  .preview-panel,
  .gallery-panel {
    padding: 14px;
    max-width: calc(100vw - 20px);
  }

  .panel-header,
  .actions {
    flex-direction: column;
  }

  .count-badge,
  .button {
    width: 100%;
  }

  textarea {
    min-height: 220px;
    font-size: 14px;
  }

  .preview-panel {
    display: none;
  }

  .preview-frame img {
    height: 100%;
    width: calc(100vw - 48px);
    max-width: 100%;
  }

  .gallery-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .image-card img {
    aspect-ratio: 3 / 2;
  }
}
