:root {
  color-scheme: light;
  --background: #f8f4ef;
  --card: #fffdfc;
  --text: #2b2523;
  --muted: #756b67;
  --accent: #a85f62;
  --primary: #713a43;
  --primary-hover: #5f3038;
  --line: rgba(43, 37, 35, 0.13);
  --soft-rose: #f1e2df;
  --soft-tan: #eee6de;
  --danger: #a43c46;
  --shadow: 0 18px 48px rgba(79, 49, 46, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--background);
  font-family: "PingFang HK", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.55;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
label:has(input:focus-visible),
textarea:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(168, 95, 98, 0.35);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin-top: 0;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 10px max(18px, env(safe-area-inset-left)) 10px max(18px, env(safe-area-inset-right));
  border-bottom: 1px solid rgba(43, 37, 35, 0.08);
  background: rgba(248, 244, 239, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-link {
  min-height: 44px;
  padding: 10px 4px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-button {
  max-width: min(42vw, 180px);
  overflow: hidden;
  border: 0;
  background: transparent;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  padding: 52px 18px 42px;
}

.hero-copy {
  max-width: 760px;
  margin: 0 auto;
}

.kicker,
.step-label {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  font-family: Georgia, "Noto Serif TC", serif;
  font-weight: 500;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 700px;
  margin-bottom: 18px;
  font-size: clamp(38px, 11vw, 64px);
  line-height: 1.12;
}

.hero-description {
  max-width: 590px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 16px;
}

.hero-note,
.generation-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.secondary-button,
.back-button,
.text-button {
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 20px rgba(113, 58, 67, 0.17);
  font-weight: 750;
}

.primary-button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.secondary-button {
  padding: 11px 16px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--card);
  font-weight: 700;
}

.text-button,
.back-button {
  padding: 8px 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 750;
}

.full-width {
  width: 100%;
  margin-top: 20px;
}

.hero-button {
  width: 100%;
}

.studio {
  padding: 54px 12px 72px;
  background: #f2ebe5;
}

.section-heading {
  max-width: 620px;
  margin: 0 auto 28px;
  padding: 0 8px;
  text-align: center;
}

.section-heading h2 {
  margin-bottom: 10px;
  font-size: clamp(32px, 9vw, 48px);
}

.section-heading > p:last-child,
.panel-heading > p:last-child,
.subheading p,
.result-copy > p {
  color: var(--muted);
}

.stepper {
  display: grid;
  max-width: 680px;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 0 auto 14px;
  padding: 0;
  color: #9b918d;
  font-size: 12px;
  list-style: none;
}

.step {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}

.step span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.step.is-active {
  color: var(--primary);
  font-weight: 800;
}

.step.is-complete span {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.studio-card {
  width: min(100%, 760px);
  min-height: 560px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel {
  display: none;
  padding: 24px 18px 28px;
}

.panel.is-active {
  display: block;
}

.panel-heading h3,
.result-copy h3,
.waiting-view h3 {
  margin-bottom: 12px;
  font-size: clamp(29px, 8vw, 40px);
  line-height: 1.15;
}

.primary-upload {
  display: flex;
  min-height: 108px;
  align-items: center;
  gap: 15px;
  padding: 18px;
  border: 1.5px dashed rgba(168, 95, 98, 0.55);
  border-radius: 18px;
  background: #fbf5f2;
  cursor: pointer;
}

.primary-upload.is-dragging {
  border-style: solid;
  background: var(--soft-rose);
}

.primary-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.primary-upload strong,
.primary-upload small {
  display: block;
}

.primary-upload small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.upload-icon {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 26px;
}

.field-error {
  min-height: 20px;
  margin: 7px 0 5px;
  color: var(--danger);
  font-size: 13px;
}

.upload-guidance {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.selected-design,
.selected-hand {
  display: block;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.selected-design[hidden],
.selected-hand[hidden],
.waiting-view[hidden],
.result-view[hidden],
.toast[hidden] {
  display: none;
}

.selected-design img,
.selected-hand img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 11px;
}

.selected-design > div,
.selected-hand-actions {
  margin-top: 12px;
}

.selected-design .text-button {
  display: block;
  min-height: 36px;
}

.saved-section {
  margin-top: 24px;
}

.subheading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.subheading h4,
.subheading p {
  margin-bottom: 0;
}

.subheading h4 {
  font-size: 15px;
}

.subheading p {
  font-size: 12px;
}

.back-button {
  margin: -8px 0 14px;
}

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

.saved-hand-card {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--text);
  background: #fff;
}

.saved-hand-card.is-selected {
  border-color: var(--accent);
}

.saved-hand-select {
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.saved-hand-select img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.saved-hand-select span {
  display: block;
  padding: 7px 3px;
  font-size: 10px;
}

.saved-hand-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}

.saved-hand-actions button {
  min-width: 0;
  min-height: 38px;
  padding: 6px 2px;
  border: 0;
  color: var(--primary);
  background: #fff;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.saved-hand-actions button + button {
  border-left: 1px solid var(--line);
}

.default-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: rgba(113, 58, 67, 0.9);
  font-size: 9px;
  font-weight: 800;
}

.empty-state {
  margin: 0 0 16px;
  padding: 16px;
  border-radius: 14px;
  color: var(--muted);
  background: #f8f5f2;
  font-size: 13px;
  text-align: center;
}

.selected-hand-actions p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.privacy-note {
  margin-top: 18px;
  padding: 15px;
  border-radius: 15px;
  color: var(--muted);
  background: #f6f1ec;
  font-size: 12px;
}

.privacy-note strong {
  color: var(--text);
}

.privacy-note p {
  margin: 5px 0 0;
}

.waiting-view {
  display: grid;
  min-height: 500px;
  place-items: center;
  align-content: center;
  padding: 44px 12px;
  text-align: center;
}

.waiting-view p {
  max-width: 390px;
  color: var(--muted);
}

.waiting-orbit {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 24px;
  border: 1px solid rgba(168, 95, 98, 0.2);
  border-radius: 50%;
}

.waiting-orbit::before,
.waiting-orbit span {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.waiting-orbit::before {
  inset: 13px;
  background: var(--soft-rose);
}

.waiting-orbit span {
  top: 4px;
  left: 31px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  transform-origin: 5px 32px;
  animation: orbit 1.8s linear infinite;
}

@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}

.result-view {
  display: block;
}

.result-stage {
  overflow: visible;
}

.result-stage img {
  width: 100%;
  height: auto;
}

.result-copy {
  margin-top: 24px;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.retry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 8px;
}

.form-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 12px;
}

.feedback-form {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

fieldset {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

legend,
.feedback-form > label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 750;
}

.rating {
  display: flex;
  gap: 5px;
}

.rating button {
  min-width: 42px;
  min-height: 44px;
  padding: 0;
  border: 0;
  color: #d8cfcb;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}

.rating button.is-active {
  color: #c98568;
}

textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #fff;
}

.feedback-submit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

footer {
  padding: 34px 18px calc(34px + env(safe-area-inset-bottom));
  text-align: center;
}

footer strong {
  font-family: Georgia, serif;
  font-size: 20px;
}

footer p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

body.modal-open {
  overflow: hidden;
}

.crop-modal[hidden],
.auth-modal[hidden] {
  display: none;
}

.crop-modal,
.auth-modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(43, 37, 35, 0.68);
  backdrop-filter: blur(8px);
}

.crop-dialog,
.auth-dialog {
  width: min(100%, 520px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 20px;
  border-radius: 22px;
  background: var(--card);
}

.crop-header,
.auth-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.crop-header h2,
.auth-header h2 {
  margin-bottom: 0;
  font-size: 26px;
}

.auth-dialog {
  width: min(100%, 440px);
}

.auth-dialog > p {
  color: var(--muted);
  font-size: 14px;
}

.google-login-container {
  display: grid;
  min-height: 52px;
  place-items: center;
  margin-top: 20px;
  overflow: hidden;
}

#auth-status.is-error {
  color: var(--danger);
}

.crop-help {
  color: var(--muted);
  font-size: 13px;
}

.crop-preview {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 0 auto;
  border-radius: 14px;
  background: #282322;
  touch-action: none;
}

.crop-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.crop-controls .secondary-button {
  width: 48px;
  padding: 8px;
  font-size: 20px;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 440px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  background: rgba(43, 37, 35, 0.92);
  box-shadow: var(--shadow);
  font-size: 13px;
  text-align: center;
}

@media (min-width: 700px) {
  .site-header {
    padding-right: 32px;
    padding-left: 32px;
  }

  .hero {
    padding: 80px clamp(32px, 7vw, 104px);
  }

  .hero-button {
    width: auto;
  }

  .studio {
    padding: 76px 24px 96px;
  }

  .panel {
    padding: 38px 44px 44px;
  }

  .result-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
