:root {
  --ink: #26343a;
  --muted: #6b777a;
  --line: #e6ddd0;
  --paper: #fffefa;
  --teal: #167b75;
  --teal-dark: #0f615d;
  --orange: #e77d3f;
  --cream: #fff4df;
  --shadow: 0 14px 34px rgba(58, 48, 36, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: #faf7f1;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}
button, input, textarea, select { font: inherit; }
button, select { touch-action: manipulation; }
.wrap { width: min(1220px, calc(100% - 36px)); margin-inline: auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 254, 250, .95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { color: var(--ink); text-decoration: none; font-weight: 900; display: inline-flex; align-items: center; gap: 12px; }
.brand-logo { display: block; width: auto; height: 54px; object-fit: contain; }
.header-link { color: var(--teal-dark); font-weight: 800; text-underline-offset: 4px; }

.hero { padding-block: 54px 38px; }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: .82rem; font-weight: 900; letter-spacing: .14em; }
.hero h1 { max-width: 820px; margin: 0; font-size: clamp(2.15rem, 5.5vw, 4.55rem); line-height: 1.08; letter-spacing: -.045em; }
.hero h1 span { color: var(--teal); }
.hero-text { margin: 20px 0 0; max-width: 760px; color: var(--muted); line-height: 1.8; }
.contact-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 760px; margin-top: 22px; padding: 14px 16px; border: 1px solid #cfe3dd; border-radius: 16px; background: #edf8f5; }
.contact-card .eyebrow { margin-bottom: 3px; font-size: .68rem; }
.contact-card h2 { margin: 0; font-size: 1rem; line-height: 1.4; }
.contact-card p:last-child { margin: 3px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.contact-actions { flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.line-contact { display: inline-flex; padding: 6px; border-radius: 9px; background: #fff; box-shadow: 0 5px 14px rgba(40, 79, 67, .1); }
.line-contact img { display: block; width: auto; height: 32px; }
.facebook-contact { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 13px; border-radius: 9px; background: #1877f2; color: #fff; font-size: .86rem; font-weight: 900; text-decoration: none; box-shadow: 0 5px 14px rgba(24, 119, 242, .18); }
.facebook-contact:hover { background: #0f65d6; }

.library { padding-bottom: 40px; }
.library-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px 22px 0 0; }
.library h2 { margin: 0; font-size: 1.55rem; }
.tab, .button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--teal-dark);
  padding: 10px 15px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.tab:hover, .button:hover { transform: translateY(-1px); border-color: #b8c9c5; }
.tab.active, .button.primary { border-color: var(--teal); background: var(--teal); color: #fff; }
.button.ghost { border-color: transparent; background: transparent; }
.button:disabled { cursor: wait; opacity: .7; transform: none; }
.button:focus-visible, .tab:focus-visible, textarea:focus-visible, select:focus-visible, .select-card:focus-visible, .download-one:focus-visible { outline: 3px solid rgba(22, 123, 117, .3); outline-offset: 2px; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; background: var(--paper); border-inline: 1px solid var(--line); }
.search-area { flex: 1 1 auto; width: min(760px, 100%); }
.search-box { width: 100%; display: flex; align-items: flex-start; gap: 9px; min-height: 72px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); }
.search-box:focus-within { border-color: var(--teal); }
.search-box > span { margin-top: 21px; font-size: 1.2rem; }
.search-box textarea { width: 100%; min-height: 68px; padding: 10px 0; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--ink); line-height: 1.55; }
.search-note { margin: 8px 4px 0; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.selection-actions { display: grid; gap: 7px; }
.selection-actions .button { white-space: nowrap; }
.result-row { min-height: 45px; display: flex; justify-content: space-between; gap: 12px; padding: 12px 24px; background: #f4efe6; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; padding-top: 18px; }
.card { position: relative; overflow: hidden; border: 2px solid transparent; border-radius: 18px; background: #fff; box-shadow: var(--shadow); transition: border-color .16s ease, transform .16s ease; }
.card:hover { transform: translateY(-2px); }
.card.selected { border-color: var(--teal); }
.thumb { aspect-ratio: 1 / 1; overflow: hidden; background: #eee8df; }
.thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.select-card { position: absolute; top: 12px; right: 12px; z-index: 1; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.96); box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer; }
.select-card::after { content: ""; width: 15px; height: 15px; border: 2px solid #80908e; border-radius: 4px; }
.card.selected .select-card { background: var(--teal); }
.card.selected .select-card::after { width: 7px; height: 12px; margin-top: -3px; border: solid #fff; border-width: 0 3px 3px 0; border-radius: 0; transform: rotate(45deg); }
.card-body { padding: 14px; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-top: 0; }
.card-title { min-width: 0; }
.card h3 { overflow: hidden; margin: 0; font-size: 1.15rem; text-overflow: ellipsis; white-space: nowrap; }
.card small { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.download-one { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--teal-dark); font-size: 1.2rem; font-weight: 900; cursor: pointer; }
.download-one:hover { border-color: var(--teal); background: #edf7f5; }
.empty { padding: 38px; margin-top: 18px; text-align: center; border: 1px dashed #c8bdaf; border-radius: 18px; color: var(--muted); background: rgba(255,255,255,.55); }
.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 9px; padding-top: 24px; }
.page-numbers { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 7px; }
.page-button { min-width: 82px; padding-inline: 12px; }
.page-button.active { border-color: var(--teal); background: var(--teal); color: #fff; }
.page-nav { min-width: 86px; }
.page-ellipsis { min-width: 24px; color: var(--muted); text-align: center; }
.pagination .button:disabled { cursor: not-allowed; opacity: .45; }

.download-bar { position: sticky; bottom: 0; z-index: 9; padding: 11px 0; background: rgba(38, 52, 58, .96); color: #fff; box-shadow: 0 -8px 25px rgba(0,0,0,.14); }
.download-bar-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.download-bar strong, .download-bar small { display: block; }
.download-bar small { margin-top: 3px; color: #cfdbdc; }
.download-bar .primary { border-color: #fff; }

footer { padding: 30px 0 34px; border-top: 1px solid var(--line); color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 28px; }
footer strong { color: var(--ink); }
footer small { display: block; max-width: 680px; margin-top: 8px; line-height: 1.7; }
.usage-disclosure { margin-top: 20px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.62); }
.usage-disclosure summary { padding: 13px 16px; color: var(--teal-dark); font-weight: 900; cursor: pointer; }
.usage-disclosure summary:hover { background: rgba(22, 123, 117, .06); }
.usage-disclosure summary:focus-visible { outline: 3px solid rgba(22, 123, 117, .3); outline-offset: 2px; }
.usage-content { padding: 0 16px 14px; border-top: 1px solid var(--line); }
.usage-content p { margin: 12px 0 0; line-height: 1.8; }
.prompt-disclosure { position: relative; margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.62); }
.prompt-disclosure summary { padding: 13px 16px; color: var(--teal-dark); font-weight: 900; cursor: pointer; }
.prompt-disclosure summary:hover { background: rgba(22, 123, 117, .06); }
.prompt-disclosure summary:focus-visible { outline: 3px solid rgba(22, 123, 117, .3); outline-offset: 2px; }
.prompt-copy { display: none; position: absolute; top: 54px; right: 14px; z-index: 2; width: 38px; height: 38px; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--teal-dark); box-shadow: 0 3px 10px rgba(18, 65, 62, .12); cursor: pointer; }
.prompt-disclosure[open] .prompt-copy { display: inline-flex; }
.prompt-copy:hover { background: var(--cream); transform: translateY(-1px); }
.prompt-copy:focus-visible { outline: 3px solid rgba(22, 123, 117, .3); outline-offset: 2px; }
.prompt-copy svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.prompt-copy .check-icon { display: none; }
.prompt-copy.copied { color: #18794e; background: #edf9f2; }
.prompt-copy.copied .copy-icon { display: none; }
.prompt-copy.copied .check-icon { display: block; }
.prompt-content { max-height: 60vh; overflow: auto; margin: 0; padding: 14px 58px 14px 16px; border-top: 1px solid var(--line); background: #fff; color: var(--ink); font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif; font-size: .82rem; line-height: 1.42; white-space: pre-wrap; word-break: break-word; tab-size: 2; }
.toast { position: fixed; left: 50%; bottom: 100px; z-index: 20; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .controls { align-items: stretch; flex-direction: column; }
  .selection-actions { display: flex; flex-wrap: wrap; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 840px) {
  .hero { padding-top: 42px; }
  .library-heading { align-items: stretch; flex-direction: column; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-inner { flex-direction: column; gap: 8px; }
}
@media (max-width: 560px) {
  .wrap { width: min(100% - 24px, 1220px); }
  .brand { gap: 8px; }
  .brand-logo { height: 46px; }
  .brand > span:last-child { font-size: .9rem; }
  .header-link { display: none; }
  .hero { padding-block: 34px 26px; }
  .hero h1 { font-size: clamp(2.05rem, 11vw, 3rem); }
  .library-heading, .controls { padding-inline: 16px; }
  .tab { width: 100%; }
  .result-row { padding-inline: 16px; flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  .download-bar-inner { align-items: stretch; flex-direction: column; }
  .download-bar .button { width: 100%; }
  .contact-card { align-items: flex-start; flex-direction: column; gap: 11px; padding: 13px 14px; }
  .contact-actions { width: 100%; }
  .pagination { align-items: stretch; }
  .page-numbers { order: -1; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
