:root {
  color-scheme: light;
  --ink: #171514;
  --muted: #6d6762;
  --paper: #faf7f2;
  --panel: #fffdf8;
  --line: #dfd6ca;
  --accent: #e33b2f;
  --accent-dark: #b7241b;
  --mint: #d7f4de;
  --shadow: 0 20px 70px rgba(45, 28, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(227, 59, 47, 0.12), transparent 36%),
    radial-gradient(circle at 88% 8%, rgba(215, 244, 222, 0.95), transparent 28%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    sans-serif;
}

button,
textarea,
a {
  font: inherit;
}

.app {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 32px;
}

.panel {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 auto 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 24px;
  font-weight: 800;
}

.brand-mark {
  width: 18px;
  height: 28px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 9px 7px 0 var(--mint);
  transform: rotate(-8deg);
}

.search {
  display: grid;
  gap: 10px;
}

.search label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(227, 59, 47, 0.14);
}

button,
.image-actions a {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button {
  width: 100%;
}

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

.notice {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.result {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.result-header,
.message,
.empty {
  grid-column: 1 / -1;
}

.result-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 6px;
}

.result-header h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.result-header span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

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

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #ece3d8;
}

.image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.image-actions span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-actions a {
  display: inline-flex;
  min-width: 82px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: var(--ink);
}

.message,
.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px 18px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.62);
  text-align: center;
}

.message.error {
  border-color: rgba(227, 59, 47, 0.45);
  color: var(--accent-dark);
  background: rgba(227, 59, 47, 0.08);
}

.empty-icon {
  width: 58px;
  height: 74px;
  margin: 0 auto 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 60%, rgba(227, 59, 47, 0.24) 60%),
    #fffdf8;
}

@media (max-width: 820px) {
  .result {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .panel {
    padding: 14px;
  }

  .brand {
    font-size: 21px;
  }

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

  .result-header {
    display: block;
  }

  .result-header span {
    display: block;
    margin-top: 6px;
  }

  .image-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .image-actions a {
    width: 100%;
    min-width: 0;
  }
}
