:root {
  --ink: #26372f;
  --ink-soft: #66736d;
  --paper: #f8f6ef;
  --white: #fffdf8;
  --green: #1f6b4f;
  --green-dark: #15513b;
  --mint: #dcecdf;
  --lime: #d6e66a;
  --coral: #ef775f;
  --line: #d9ddd4;
  --shadow: 0 16px 45px rgba(43, 61, 52, 0.1);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.65;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.paper-texture {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .32;
  background-image: radial-gradient(rgba(38,55,47,.12) .65px, transparent .65px);
  background-size: 9px 9px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

.topbar {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: 19px; line-height: 1.2; letter-spacing: .04em; }
.brand small { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 50% 50% 46% 54%; transform: rotate(-5deg);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 19px;
  background: var(--green); box-shadow: inset -5px -6px 0 rgba(0,0,0,.09);
}
.brand-mark.small { width: 36px; height: 36px; font-size: 15px; flex: 0 0 auto; }
.icon-button, .close-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.62); cursor: pointer;
  border-radius: 99px; padding: 10px 17px; display: flex; gap: 8px; align-items: center;
}
.icon-button:hover { background: #fff; border-color: var(--green); }

main { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.hero {
  position: relative; min-height: 350px; border-radius: 38px; overflow: hidden;
  padding: 58px 64px; display: flex; align-items: center;
  background: var(--green); color: #fff; box-shadow: var(--shadow);
}
.hero::before {
  content: ""; position: absolute; width: 510px; height: 510px; border-radius: 50%;
  right: -120px; top: -190px; border: 95px solid rgba(214,230,106,.18);
}
.hero::after {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  right: 250px; bottom: -125px; border: 34px solid rgba(255,255,255,.08);
}
.hero-copy { max-width: 700px; position: relative; z-index: 1; }
.eyebrow, .step-label { margin: 0 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: var(--lime); }
h1, h2, h3, p { text-wrap: pretty; }
h1 { font-size: clamp(38px, 5.4vw, 68px); line-height: 1.2; letter-spacing: -.035em; margin: 0; }
h1 em { color: var(--lime); font-style: normal; }
.hero-note { margin: 22px 0 0; color: rgba(255,255,255,.78); max-width: 560px; font-size: 16px; }
.hero-sticker {
  position: absolute; z-index: 1; right: 70px; bottom: 48px; width: 150px; height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--green-dark); background: var(--lime); border-radius: 50%; transform: rotate(8deg);
  box-shadow: 8px 10px 0 rgba(15,57,42,.25);
}
.hero-sticker span { font-size: 11px; letter-spacing: .2em; }
.hero-sticker strong { font-size: 28px; line-height: 1.05; text-align: center; }
.hero-sticker i { position: absolute; right: 17px; top: 21px; font-style: normal; }

.composer {
  position: relative; z-index: 2; width: calc(100% - 88px); margin: -34px auto 24px;
  padding: 34px 38px; background: var(--white); border: 1px solid rgba(38,55,47,.1);
  border-radius: 28px; box-shadow: var(--shadow);
}
.composer-heading, .section-heading, .dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.step-label { color: var(--coral); }
h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.025em; line-height: 1.3; }
.ai-status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.ai-status i { width: 8px; height: 8px; border-radius: 50%; background: #aab2ad; }
.ai-status.connected { color: var(--green); }
.ai-status.connected i { background: #3fba79; box-shadow: 0 0 0 4px rgba(63,186,121,.14); }

.prompt-box { position: relative; display: block; margin-top: 25px; }
.prompt-box textarea {
  width: 100%; min-height: 128px; resize: vertical; display: block;
  border: 2px solid #cfd7cf; border-radius: 18px; padding: 20px 22px 42px;
  color: var(--ink); background: #fff; font-size: 18px; line-height: 1.65; outline: none;
  transition: border .2s, box-shadow .2s;
}
.prompt-box textarea:focus { border-color: var(--green); box-shadow: 0 0 0 5px rgba(31,107,79,.09); }
.prompt-box textarea::placeholder { color: #9aa49e; }
.prompt-hint { position: absolute; bottom: 13px; left: 23px; color: #9aa49e; font-size: 12px; pointer-events: none; }
.quick-tags { margin: 14px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.quick-tags button, .category-tabs button {
  border: 1px solid var(--line); background: #f4f5f0; border-radius: 99px; padding: 7px 13px; cursor: pointer; font-size: 13px;
}
.quick-tags button:hover, .category-tabs button:hover, .category-tabs button.active { background: var(--mint); border-color: #a9c7b2; color: var(--green-dark); }
.composer-actions { display: flex; gap: 12px; margin-top: 24px; }
.primary-button, .secondary-button, .copy-button, .use-button {
  border: 0; border-radius: 13px; min-height: 48px; padding: 0 20px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .18s, background .18s;
}
.primary-button { background: var(--green); color: #fff; box-shadow: 0 7px 16px rgba(31,107,79,.18); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .58; cursor: wait; transform: none; }
.primary-button.compact { min-width: 150px; }
.secondary-button { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.secondary-button:hover { background: #f3f5ef; }

.profile-panel { margin: 0 auto 76px; width: calc(100% - 88px); border-bottom: 1px solid var(--line); }
.profile-toggle { width: 100%; border: 0; background: transparent; padding: 18px 4px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; text-align: left; }
.profile-toggle > span:first-child { display: flex; align-items: center; gap: 14px; }
.profile-toggle b { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #eadfc8; font-size: 12px; }
.profile-toggle strong, .profile-toggle small { display: block; }
.profile-toggle small { color: var(--ink-soft); margin-top: 2px; }
.toggle-chevron { font-size: 25px; transition: transform .2s; }
.profile-toggle[aria-expanded="true"] .toggle-chevron { transform: rotate(180deg); }
.profile-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 4px 0 24px; }
.profile-fields label, .full-field { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.profile-fields input, .profile-fields select, .full-field input {
  width: 100%; margin-top: 7px; height: 48px; border: 1px solid #cfd5cf; border-radius: 11px; background: #fff; padding: 0 13px; color: var(--ink); outline: none;
}
.profile-fields input:focus, .profile-fields select:focus, .full-field input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(31,107,79,.08); }

.results-section, .template-library { margin-bottom: 90px; scroll-margin-top: 24px; }
.section-heading { align-items: end; margin-bottom: 26px; }
.section-heading > p { max-width: 330px; text-align: right; color: var(--ink-soft); font-size: 13px; margin: 0 0 3px; }
.empty-state { min-height: 310px; border: 1px dashed #bbc6bd; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; background: rgba(255,255,255,.42); }
.empty-state h3 { margin: 14px 0 5px; font-size: 19px; }
.empty-state p { max-width: 470px; margin: 0; color: var(--ink-soft); }
.empty-illustration { width: 74px; height: 74px; display: grid; place-items: center; background: var(--mint); border-radius: 45% 55% 55% 45%; font-size: 34px; transform: rotate(-7deg); }
.result-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.result-list:empty { display: none; }
.message-card {
  --card-accent: var(--green); background: var(--white); border: 1px solid rgba(38,55,47,.11); border-top: 5px solid var(--card-accent);
  border-radius: 20px; overflow: hidden; box-shadow: 0 10px 25px rgba(43,61,52,.08); display: flex; flex-direction: column;
}
.message-card.ai-card { --card-accent: var(--coral); grid-column: 1 / -1; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 20px 14px; background: color-mix(in srgb, var(--card-accent) 9%, white); }
.card-title { display: flex; gap: 11px; align-items: center; min-width: 0; }
.card-icon { width: 35px; height: 35px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center; background: #fff; font-size: 18px; }
.card-title strong, .card-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title small { color: var(--ink-soft); font-size: 11px; margin-top: -1px; }
.copy-button { min-height: 38px; padding: 0 13px; background: #fff; border: 1px solid rgba(38,55,47,.12); font-size: 13px; white-space: nowrap; }
.copy-button:hover { background: var(--ink); color: white; }
.message-editor { width: 100%; min-height: 250px; resize: vertical; border: 0; outline: 0; padding: 22px 22px 10px; background: transparent; color: #34433c; font-size: 16px; line-height: 1.9; overflow: hidden; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 20px 17px; color: #99a39d; font-size: 11px; }
.card-footer button { border: 0; background: transparent; color: var(--green); font-weight: 700; cursor: pointer; padding: 5px; }

.template-library { padding-top: 6px; }
.library-heading { align-items: end; }
.search-box { width: min(280px, 100%); display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--ink); padding: 8px 2px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; }
.category-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.library-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.library-card { border: 1px solid var(--line); background: rgba(255,255,255,.62); border-radius: 16px; padding: 18px; min-height: 165px; display: flex; flex-direction: column; }
.library-card:hover { background: #fff; box-shadow: 0 8px 25px rgba(43,61,52,.07); }
.library-card-head { display: flex; align-items: center; gap: 10px; }
.library-card-head span { font-size: 21px; }
.library-card h3 { font-size: 16px; margin: 0; }
.library-card p { font-size: 13px; color: var(--ink-soft); margin: 13px 0 18px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.use-button { min-height: 37px; margin-top: auto; align-self: flex-start; background: var(--mint); color: var(--green-dark); font-size: 12px; padding: 0 13px; }
.no-results { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--ink-soft); }

footer { width: min(1160px, calc(100% - 40px)); margin: 0 auto; border-top: 1px solid var(--line); padding: 30px 0 45px; display: flex; gap: 12px; align-items: center; }
footer p { margin: 0; line-height: 1.45; }
footer small { color: var(--ink-soft); }

.settings-dialog { width: min(590px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 24px; color: var(--ink); box-shadow: 0 30px 100px rgba(20,43,32,.35); }
.settings-dialog::backdrop { background: rgba(20,35,28,.58); backdrop-filter: blur(4px); }
.dialog-shell { padding: 30px; }
.close-button { width: 39px; height: 39px; padding: 0; justify-content: center; font-size: 25px; }
.dialog-intro { color: var(--ink-soft); font-size: 14px; margin: 18px 0 20px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 67px; }
.password-field button { position: absolute; right: 7px; bottom: 7px; height: 34px; border: 0; background: #eef1ec; border-radius: 8px; font-size: 12px; cursor: pointer; }
.check-field { display: flex; gap: 11px; align-items: flex-start; margin-top: 17px; cursor: pointer; }
.check-field input { margin-top: 5px; accent-color: var(--green); }
.check-field strong, .check-field small { display: block; }
.check-field small { color: var(--ink-soft); }
.privacy-note { display: flex; gap: 12px; margin: 20px 0; padding: 14px; background: #f2eee4; border-radius: 13px; font-size: 12px; }
.privacy-note p { margin: 0; }
.dialog-actions { display: flex; justify-content: space-between; gap: 12px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #1f3128; color: white; border-radius: 99px; padding: 11px 18px; font-size: 13px; transition: .22s ease; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .hero { padding: 50px 38px; min-height: 340px; }
  .hero-sticker { width: 110px; height: 110px; right: 32px; bottom: 34px; }
  .hero-sticker strong { font-size: 21px; }
  .composer, .profile-panel { width: calc(100% - 36px); }
  .profile-fields { grid-template-columns: repeat(2, 1fr); }
  .library-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .topbar, main, footer { width: min(100% - 24px, 1160px); }
  .topbar { padding-top: 16px; }
  .desktop-label { display: none; }
  .icon-button { width: 42px; height: 42px; justify-content: center; padding: 0; }
  .hero { border-radius: 27px; min-height: 410px; padding: 42px 24px 130px; align-items: flex-start; }
  h1 { font-size: 39px; }
  .hero-note { font-size: 14px; }
  .hero-sticker { left: 25px; right: auto; bottom: 25px; width: 94px; height: 94px; }
  .hero-sticker strong { font-size: 18px; }
  .composer { width: calc(100% - 16px); margin-top: -14px; padding: 26px 18px; border-radius: 22px; }
  .composer-heading { display: block; }
  .ai-status { margin-top: 10px; }
  .prompt-box textarea { min-height: 155px; font-size: 16px; padding: 16px 16px 47px; }
  .prompt-hint { left: 17px; right: 17px; line-height: 1.35; }
  .composer-actions { flex-direction: column; }
  .primary-button, .secondary-button { width: 100%; }
  .profile-panel { width: calc(100% - 22px); margin-bottom: 58px; }
  .profile-toggle small { font-size: 11px; }
  .profile-fields { grid-template-columns: 1fr; }
  .section-heading { display: block; }
  .section-heading > p { text-align: left; margin-top: 8px; }
  .result-list { grid-template-columns: 1fr; }
  .message-card.ai-card { grid-column: auto; }
  .message-editor { min-height: 285px; padding: 19px 17px 8px; }
  .card-top { padding: 15px 15px 12px; }
  .card-title small { max-width: 125px; }
  .card-footer { padding-inline: 16px; }
  .library-heading { display: block; }
  .search-box { margin-top: 18px; width: 100%; }
  .library-grid { grid-template-columns: 1fr; }
  .template-library, .results-section { margin-bottom: 68px; }
  .dialog-shell { padding: 24px 20px; }
  .dialog-actions { flex-direction: column-reverse; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
