:root {
  --ink: #10231f;
  --moss: #1f6b57;
  --moss-deep: #0f3f34;
  --line: rgba(16, 35, 31, 0.14);
  --glow: rgba(31, 107, 87, 0.28);
  --font-display: "Noto Serif TC", "Songti TC", serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --tap: 48px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1000px 640px at 85% -8%, rgba(215, 196, 164, 0.22), transparent 60%),
    radial-gradient(820px 560px at -12% 18%, rgba(31, 107, 87, 0.10), transparent 55%),
    #f9fafb;
  padding-bottom: env(safe-area-inset-bottom);
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(16, 35, 31, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 35, 31, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 18%, black, transparent 75%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-10px, 8px, 0); }
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: calc(0.85rem + env(safe-area-inset-top)) 1rem 0.85rem;
  background: rgba(238, 245, 241, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
}
nav { display: flex; gap: 0.85rem; }
nav a {
  color: var(--moss-deep);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.2rem;
}

main {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 1.5rem));
  margin: 0 auto 3rem;
}

.hero {
  min-height: min(68vh, 560px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 0 2rem;
  animation: rise 0.85s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.brand-hero {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 12vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--moss-deep);
}
.hero h1 {
  margin: 0;
  max-width: 12em;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  font-weight: 600;
  line-height: 1.25;
}
.lede {
  margin: 0.9rem 0 1.4rem;
  max-width: 22em;
  font-size: 1.02rem;
  line-height: 1.55;
  color: rgba(16, 35, 31, 0.78);
}
.cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  max-width: 420px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 16px;
  min-height: var(--tap);
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--moss);
  color: #fff;
  box-shadow: 0 10px 28px var(--glow);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.66);
  border-color: var(--line);
  color: var(--ink);
}
.btn.full { width: 100%; }
.file-btn { cursor: pointer; }

.panel {
  margin-top: 1.1rem;
  padding: 1.35rem 0 0.4rem;
  border-top: 1px solid var(--line);
  animation: rise 0.95s ease both;
  animation-delay: 0.12s;
}
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
}
.sub {
  margin: 0.45rem 0 1.1rem;
  color: rgba(16, 35, 31, 0.72);
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 0.7rem;
  max-width: 640px;
}
label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--moss-deep);
}

/* 16px+ prevents iOS auto-zoom on focus */
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: var(--tap);
  padding: 0.95rem 1rem;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
textarea {
  resize: vertical;
  min-height: 180px;
}
input:focus, textarea:focus {
  outline: 2px solid rgba(31, 107, 87, 0.35);
  border-color: transparent;
}

.divider {
  display: grid;
  place-items: center;
  margin: 1.35rem 0 1rem;
  max-width: 640px;
  color: rgba(16, 35, 31, 0.5);
  font-size: 0.88rem;
  font-weight: 600;
}
.divider::before {
  content: "";
  grid-area: 1 / 1;
  width: 100%;
  border-top: 1px solid var(--line);
}
.divider span {
  grid-area: 1 / 1;
  padding: 0 0.7rem;
  background: #f1f5f0;
}

.upload-actions {
  display: grid;
  gap: 0.7rem;
}

.preview {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.55);
}
.preview-list {
  display: grid;
  gap: 0.65rem;
}
.preview-card {
  display: grid;
  gap: 0.35rem;
}
.preview-card img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}
.preview-card span {
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  color: rgba(16, 35, 31, 0.68);
}
.hint {
  margin: 0;
  font-size: 0.86rem;
  color: rgba(16, 35, 31, 0.58);
  line-height: 1.45;
}

.status {
  margin: 0;
  font-size: 0.95rem;
  color: var(--moss-deep);
  line-height: 1.45;
}
.status.error { color: #8a2f2f; }

.results { margin-top: 1rem; display: grid; gap: 0.85rem; }
.result {
  padding: 1rem;
  border: 1px solid rgba(16, 35, 31, 0.06);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(16, 35, 31, 0.05);
  animation: rise 0.4s ease both;
}
.card-head {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 0.85rem;
  align-items: start;
}
.card-copy { min-width: 0; }
.thumb {
  display: block;
  width: 86px;
  height: 86px;
  object-fit: cover;
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}
.thumb-stack {
  position: relative;
  width: 86px;
}
.page-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  background: rgba(15, 63, 52, 0.88);
  color: #f7fff9;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}
.shot-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.55rem;
  margin: 0.75rem 0 0.35rem;
}
.shot-gallery a {
  display: block;
}
.shot-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.combine-option {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.35rem 0 0.15rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.combine-option span {
  flex: 1;
  line-height: 1.35;
}
.combine-option input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  min-height: 1.25rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  flex: none;
  accent-color: #1f6b57;
  cursor: pointer;
  pointer-events: auto;
}
.thumb.placeholder {
  display: grid;
  place-items: center;
  color: rgba(15, 63, 52, 0.64);
  background:
    radial-gradient(circle at 30% 20%, rgba(31, 107, 87, 0.16), transparent 34%),
    #eef8f2;
  font-size: 0.8rem;
  font-weight: 700;
}
.result h3 {
  margin: 0 0 0.38rem;
  font-size: 1.05rem;
  line-height: 1.28;
  font-weight: 800;
}
.result p {
  margin: 0;
  color: #6b7280;
  line-height: 1.45;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.highlights {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  color: rgba(16, 35, 31, 0.82);
  line-height: 1.55;
  font-size: 0.92rem;
}
.highlights li + li { margin-top: 0.25rem; }
.raw-details {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
  background: rgba(255, 255, 255, 0.48);
}
.raw-details summary {
  cursor: pointer;
  color: var(--moss-deep);
  font-weight: 700;
}
.raw-details pre {
  margin: 0.65rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: rgba(16, 35, 31, 0.78);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
}
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.45rem;
}
.action-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}
.image-btn {
  border: 1px solid rgba(31, 107, 87, 0.18);
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  background: rgba(31, 107, 87, 0.06);
  color: var(--moss-deep);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}
.ai-btn {
  border: 1px solid rgba(31, 107, 87, 0.22);
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  background: #e8f5ee;
  color: var(--moss-deep);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.ai-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.delete-btn {
  border: 1px solid rgba(138, 47, 47, 0.25);
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  background: rgba(138, 47, 47, 0.06);
  color: #8a2f2f;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.delete-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  margin: 0.2rem 0 0.5rem;
}
.tags span {
  border: 0;
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  background: #e8f5ee;
  color: var(--moss-deep);
  font-size: 0.74rem;
  font-weight: 700;
}
.meta {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: rgba(16, 35, 31, 0.55);
}

footer {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.35rem;
  padding: 1.2rem 1rem calc(1.4rem + env(safe-area-inset-bottom));
  color: rgba(16, 35, 31, 0.55);
  font-size: 0.82rem;
  line-height: 1.4;
}

@media (min-width: 720px) {
  .cta-row { display: flex; }
  .upload-actions {
    grid-template-columns: 1fr 1fr;
  }
  footer {
    display: flex;
    justify-content: space-between;
    padding-inline: clamp(1.25rem, 4vw, 3rem);
  }
  .top { padding-inline: clamp(1.25rem, 4vw, 3rem); }
}
