:root {
  /* 暖白線稿系：呼應 77.mom.ai logo（細黑線條），暖白護眼＋白卡片有層次，灰玫瑰只當一點體溫 */
  --paper: #faf8f4;       /* 頁面底：極淡暖白（暖但幾乎不帶粉，不刺眼） */
  --surface: #ffffff;     /* 面板白（浮在暖底上帶層次） */
  --surface-2: #f4f1ec;   /* 輸入框／極淺分區底 */
  --ink: #1f1b1a;         /* 近黑墨色：文字與線稿結構主色 */
  --ink-soft: #635b57;    /* 次要文字 */
  --muted: #9c948f;       /* 輔助說明 */
  --line: #ebe6df;        /* hairline 分隔線 */
  --line-strong: #1f1b1a; /* 選取／當前態邊框＝墨黑（像線稿） */
  --accent: #b76e79;      /* 霧感灰玫瑰（暖色錨點，克制使用） */
  --accent-deep: #9a5462; /* 深一階：小字用，確保對比 */
  --accent-soft: #f6e9ec; /* 選取底 */
  --accent-tint: #fbf4f5; /* hover 極淺 */
  --shadow: 0 1px 2px rgba(31, 27, 26, 0.04), 0 10px 30px rgba(31, 27, 26, 0.05);
  --shadow-sm: 0 1px 3px rgba(31, 27, 26, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0;
}

/* ===== Header：logo + 文字鎖定組，底線收邊 ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 22px;
  max-width: 900px;
  margin-bottom: 34px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.app-logo {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.app-header__text {
  min-width: 0;
}

.eyebrow,
.section-kicker,
.step-nav__kicker {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.22;
  letter-spacing: 0;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.85rem, 3.8vw, 3rem);
  max-width: 12em;
}

h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.9rem);
}

.app-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

/* 區塊標題：主標（大）＋副標（小字解釋） */
.section-sub {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  font-weight: 400;
}

/* ===== 三欄版面 ===== */
.tool-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.tool-layout.nav-collapsed {
  grid-template-columns: 58px minmax(0, 1fr) 460px;
}

/* ===== 左欄：可點步驟 ===== */
.step-nav {
  position: sticky;
  top: 24px;
}

.step-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.step-nav__kicker {
  margin: 0;
}

.step-nav__toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  transition: border-color 160ms ease, color 160ms ease;
}

.step-nav__toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.step-nav__list {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.step-nav__item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 11px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: transparent;
  text-align: left;
  color: var(--ink-soft);
  transition: background 160ms ease, border-color 160ms ease;
}

.step-nav__item:hover {
  background: var(--surface-2);
}

.step-nav__item.is-active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.step-nav__num {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.step-nav__item.is-active .step-nav__num {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
  color: #ffffff;
}

.step-nav__item.is-complete .step-nav__num {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.step-nav__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.step-nav__text strong {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
}

.step-nav__summary {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 收合狀態：左欄只剩數字圓點，仍可點跳轉 */
.tool-layout.nav-collapsed .step-nav__kicker,
.tool-layout.nav-collapsed .step-nav__text {
  display: none;
}

.tool-layout.nav-collapsed .step-nav__head {
  justify-content: center;
}

.tool-layout.nav-collapsed .step-nav__item {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 10px 6px;
}

/* ===== 中欄：表單 ===== */
.form-panel {
  min-width: 0;
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-section[hidden] {
  display: none;
}

.section-heading {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

.style-grid {
  /* 自適應：窄欄時 2 張一排（圖夠大好判斷風格），版面變寬會自動塞回 3 張 */
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.choice-card,
.style-card,
.pill-choice {
  position: relative;
  display: grid;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.choice-card,
.style-card {
  overflow: hidden;
}

.choice-card {
  padding: 16px;
}

.choice-card:hover,
.style-card:hover,
.pill-choice:hover {
  border-color: var(--ink-soft);
  background: var(--surface-2);
}

.choice-card:has(input:checked),
.style-card:has(input:checked),
.pill-choice:has(input:checked) {
  border-color: var(--line-strong);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.choice-card input,
.style-card input,
.pill-choice input {
  position: absolute;
  inset: 0;
  z-index: 2; /* 疊在輪播圖之上，確保整張卡可點選 */
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-card__content,
.style-card__content {
  display: grid;
  gap: 5px;
}

.choice-card__title,
.style-card__title {
  font-weight: 700;
  color: var(--ink);
}

.choice-card__desc,
.style-card__desc {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* 卡片預覽圖：3 張疊放、淡入淡出輪播 */
.style-card__media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.style-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 450ms ease;
}

.style-card__img.is-active {
  opacity: 1;
}

.style-card__content {
  padding: 13px;
}

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

.field,
.field-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field span,
.field-group legend {
  color: var(--ink);
  font-weight: 700;
}

.field b {
  margin-left: 4px;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 700;
}

.field b.opt {
  color: var(--muted);
  font-weight: 500;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.field textarea {
  resize: vertical;
}

.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.field select:focus {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.field input:focus,
.field textarea:focus,
.button:focus-visible,
.step-nav__item:focus-visible,
.step-nav__toggle:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.field input.is-invalid,
.field textarea.is-invalid {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-error {
  min-height: 1.25em;
  color: var(--accent-deep);
  font-size: 0.9rem;
  font-style: normal;
}

.field-group {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

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

.pill-grid--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pill-choice {
  place-items: center;
  padding: 11px 10px;
  text-align: center;
  font-weight: 700;
  color: var(--ink);
}

/* ===== 右欄：即時 prompt ===== */
.preview-panel {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.preview-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.preview-meta {
  font-size: 0.78rem;
  color: var(--accent-deep);
  background: var(--accent-soft);
  padding: 4px 11px;
  border-radius: 999px;
}

.preview-meta:empty {
  display: none;
}

.preview-output {
  width: 100%;
  min-height: 440px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.8;
  resize: vertical;
  white-space: pre-wrap;
  outline: none;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.copy-status {
  min-height: 1.5em;
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 0.88rem;
}

/* ===== 步驟切換按鈕 ===== */
.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 20px;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button--primary {
  background: var(--ink);
  color: #ffffff;
}

.button--primary:hover {
  background: #000000;
}

.button--ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button--ghost:hover {
  border-color: var(--ink);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.button[hidden] {
  display: none;
}

/* ===== 響應式 ===== */
@media (max-width: 1080px) {
  .tool-layout,
  .tool-layout.nav-collapsed {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .preview-panel {
    position: static;
    grid-column: 1 / -1;
  }

  .preview-output {
    min-height: 240px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 24px 0;
  }

  .app-header {
    gap: 16px;
    margin-bottom: 26px;
    padding-bottom: 22px;
  }

  .app-logo {
    width: 60px;
    height: 60px;
  }

  .tool-layout,
  .tool-layout.nav-collapsed {
    grid-template-columns: 1fr;
  }

  .step-nav {
    position: static;
  }

  .step-nav__toggle {
    display: none;
  }

  .step-nav__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .step-nav__item {
    grid-template-columns: 1fr;
    gap: 6px;
    justify-items: center;
    text-align: center;
    padding: 10px 6px;
  }

  .step-nav__summary {
    display: none;
  }

  .choice-grid,
  .style-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: min(100% - 20px, 440px);
    padding: 18px 0;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-panel {
    padding: 18px;
  }

  .field-grid,
  .pill-grid,
  .pill-grid--compact {
    grid-template-columns: 1fr;
  }

  .nav-row,
  .copy-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ===== Footer：導流 + 隨喜贊助 ===== */
.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.app-footer__link {
  color: var(--ink-soft);
  font-weight: 700;
  text-decoration: none;
}

.app-footer__link:hover {
  color: var(--accent-deep);
  text-decoration: underline;
}

.app-footer__link--support {
  color: var(--accent-deep);
}

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