: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 { font: inherit; }
button { touch-action: manipulation; }
.wrap { width: min(1180px, 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: 58px 38px; display: grid; grid-template-columns: 1fr auto; gap: 30px; align-items: end; }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: .82rem; font-weight: 900; letter-spacing: .14em; }
.hero h1 { max-width: 760px; margin: 0; font-size: clamp(2.15rem, 5.7vw, 4.65rem); line-height: 1.08; letter-spacing: -.045em; }
.hero h1 span { color: var(--teal); }
.hero-text { margin: 20px 0 0; max-width: 650px; color: var(--muted); line-height: 1.8; }
.summary { min-width: 225px; padding: 21px; border: 1px solid var(--line); border-radius: 22px; background: var(--cream); box-shadow: var(--shadow); }
.summary div { display: flex; align-items: baseline; gap: 8px; }
.summary strong { color: var(--teal-dark); font-size: 2.6rem; line-height: 1; }
.summary span { font-weight: 900; }

.library { padding-bottom: 36px; }
.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; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.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; }
.tab span { display: inline-grid; place-items: center; min-width: 25px; height: 25px; margin-left: 5px; padding-inline: 6px; border-radius: 999px; background: #eef6f4; color: var(--teal-dark); font-size: .78rem; }
.tab.active span { background: rgba(255,255,255,.18); color: #fff; }
.button.ghost { border-color: transparent; background: transparent; }
.button:focus-visible, .tab:focus-visible, input:focus-visible, .select-card:focus-visible { outline: 3px solid rgba(22, 123, 117, .3); outline-offset: 2px; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 24px; background: var(--paper); border-inline: 1px solid var(--line); }
.search-box { flex: 1 1 360px; max-width: 620px; display: flex; align-items: flex-start; gap: 9px; 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: 14px; }
.search-box textarea { width: 100%; min-height: 56px; padding: 10px 0; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--ink); line-height: 1.55; }
.selection-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.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(3, 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; overflow: hidden; background: #eee8df; }
.thumb img { width: 100%; height: 100%; display: block; object-fit: contain; }
.select-card { position: absolute; top: 12px; right: 12px; z-index: 1; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.95); 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: 15px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-title { min-width: 0; }
.card h3 { overflow: hidden; margin: 0; font-size: 1.12rem; text-overflow: ellipsis; white-space: nowrap; }
.card small { display: block; margin-top: 4px; color: var(--muted); }
.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; align-items: center; justify-content: center; gap: 16px; padding: 26px 0 4px; color: var(--muted); }
.pagination .button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.pagination span { min-width: 260px; text-align: center; font-size: .92rem; }

.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; }

.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; gap: 10px; }
.line-contact { flex: 0 0 auto; 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 { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border-radius: 9px; background: #287be0; color: #fff; font-size: .9rem; font-weight: 900; text-decoration: none; box-shadow: 0 5px 14px rgba(40, 79, 67, .1); }
.facebook-contact:hover { background: #1f68c2; }

footer { padding: 30px 0 34px; border-top: 1px solid var(--line); color: var(--muted); }
footer strong { color: var(--ink); }
footer small { display: block; margin-top: 8px; line-height: 1.7; }
.footer-inner { display: grid; gap: 20px; }
.usage-disclosure { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.65); }
.usage-disclosure summary { padding: 14px 16px; color: var(--ink); font-weight: 900; cursor: pointer; }
.usage-disclosure summary:hover { color: var(--teal-dark); }
.usage-content { padding: 0 16px 14px; border-top: 1px solid var(--line); }
.usage-content p { margin: 12px 0 0; line-height: 1.75; }
.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: 840px) {
  .hero { grid-template-columns: 1fr; padding-top: 42px; }
  .summary { min-width: 0; max-width: 360px; }
  .library-heading, .controls { align-items: stretch; flex-direction: column; }
  .search-box { max-width: none; flex-basis: auto; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .wrap { width: min(100% - 24px, 1180px); }
  .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; }
  .tabs, .selection-actions { display: grid; grid-template-columns: 1fr; }
  .tab, .selection-actions .button { width: 100%; }
  .result-row { padding-inline: 16px; flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  .pagination { flex-wrap: wrap; gap: 10px; }
  .pagination span { order: -1; width: 100%; min-width: 0; }
  .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 { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
