:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef2f3;
  --ink: #172126;
  --muted: #66747b;
  --line: #dce3e6;
  --primary: #245d62;
  --primary-hover: #194b50;
  --primary-soft: #e1eeee;
  --shadow: 0 12px 32px rgba(22, 38, 43, .08);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1518;
  --surface: #172024;
  --surface-soft: #202b30;
  --ink: #f3f6f7;
  --muted: #a2b0b6;
  --line: #2f3d42;
  --primary: #7eb7b9;
  --primary-hover: #a1cdce;
  --primary-soft: #20383b;
  --shadow: 0 18px 38px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.55;
}
body.modal-open { overflow: hidden; }
a { color: inherit; }
button, input { font: inherit; }
button, a { touch-action: manipulation; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 4000; left: 12px; top: 12px; transform: translateY(-160%); padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); }
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.header-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: .01em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; }
.brand-mark svg { width: 23px; height: 23px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.button, .icon-button, .toolbar-button, .filter-chip, .text-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; font-weight: 700; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.button-secondary:hover { background: var(--surface-soft); }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.icon-button:hover { background: var(--surface-soft); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.intro { padding: 54px 0 28px; }
.intro-inner { display: flex; justify-content: space-between; align-items: end; gap: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 13px; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(32px, 5vw, 54px); line-height: 1.15; letter-spacing: -.035em; }
.intro p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 16px; }

.collection { padding: 10px 0 70px; }
.controls { position: sticky; z-index: 50; top: 70px; display: grid; grid-template-columns: minmax(240px, 360px) 1fr; align-items: start; gap: 16px; padding: 16px 0; background: var(--bg); }
.search-field { min-height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.search-field svg { flex: none; color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.search-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.category-filter { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px; overflow: visible; padding-bottom: 2px; }
.filter-chip { flex: none; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); white-space: nowrap; font-weight: 650; }
.filter-chip:hover, .filter-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.filter-chip span { margin-left: 4px; opacity: .72; }
.result-row { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 14px; }
.text-button { padding: 6px 0; background: transparent; color: var(--primary); font-weight: 700; }

.proposal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.proposal-card { overflow: hidden; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 1px rgba(0,0,0,.02); }
.proposal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-cover { position: relative; overflow: hidden; aspect-ratio: 1.42 / 1; background: var(--surface-soft); }
.card-cover img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: top center; transition: transform .25s ease; }
.proposal-card:hover .card-cover img { transform: scale(1.02); }
.card-number, .card-category { position: absolute; top: 12px; padding: 6px 10px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 800; backdrop-filter: blur(10px); }
.card-number { left: 12px; background: rgba(17, 28, 32, .82); }
.card-category { right: 12px; max-width: calc(100% - 76px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: color-mix(in srgb, var(--card-accent) 82%, #172126); }
.card-body { display: flex; flex: 1; flex-direction: column; padding: 18px; }
.card-body h3 { margin: 0; min-height: 3.1em; font-size: 18px; line-height: 1.55; letter-spacing: -.01em; }
.card-meta { display: flex; gap: 14px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-actions { display: grid; grid-template-columns: 1fr 48px; gap: 9px; margin-top: 18px; }
.card-download { padding-inline: 0; }
.card-download span { display: none; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 0 0 18px; color: var(--ink); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 14px; }
.footer-inner a { color: var(--primary); font-weight: 700; text-decoration: none; }

.modal { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(7, 12, 14, .78); backdrop-filter: blur(5px); }
.modal-panel { position: relative; width: min(1460px, 96vw); height: min(940px, 94dvh); overflow: hidden; display: grid; grid-template-rows: auto auto minmax(0,1fr); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; background: var(--surface); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-heading { min-width: 0; }
.modal-heading span { display: block; color: var(--primary); font-size: 12px; font-weight: 800; }
.modal-heading h2 { overflow: hidden; margin: 2px 0 0; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
.close-button { flex: none; }
.pdf-toolbar { min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.toolbar-button { min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); }
.toolbar-button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.toolbar-button:disabled { cursor: not-allowed; opacity: .38; }
.toolbar-text { padding-inline: 13px; font-weight: 700; }
.toolbar-divider { width: 1px; height: 28px; background: var(--line); }
.page-control { height: 44px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); }
.page-control input { width: 54px; border: 0; outline: 0; background: transparent; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.zoom-label { min-width: 76px; color: var(--muted); text-align: center; font-size: 13px; white-space: nowrap; }
.toolbar-download { margin-left: auto; text-decoration: none; font-weight: 700; }
.pdf-stage { position: relative; min-height: 0; overflow: auto; overscroll-behavior: contain; background: #495055; }
.canvas-wrap { min-width: min-content; min-height: 100%; display: flex; align-items: flex-start; justify-content: center; padding: 24px; }
#pdf-canvas { display: block; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.pdf-loading, .pdf-error { position: absolute; z-index: 3; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; background: #495055; color: #fff; text-align: center; }
.pdf-loading[hidden], .pdf-error[hidden] { display: none; }
.pdf-loading-progress { min-height: 1.5em; opacity: .75; font-size: 13px; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.28); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.pdf-error p { margin: 0; opacity: .75; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; z-index: 2000; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 11px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 14px; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, white); outline-offset: 2px; }

@media (max-width: 920px) {
  .proposal-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .controls { grid-template-columns: 1fr; }
  .category-filter { justify-content: flex-start; }
  .pdf-toolbar { overflow-x: auto; }
}

@media (max-width: 640px) {
  .container { width: min(100% - 28px, 1180px); }
  .site-header .container { width: calc(100% - 20px); }
  .header-inner { min-height: 62px; }
  .brand span:last-child { font-size: 14px; }
  .brand-mark { width: 34px; height: 34px; }
  .header-link { width: 44px; padding: 0; }
  .header-link span, .header-link:not(:has(span)) { font-size: 0; }
  .header-link { font-size: 0; }
  .header-link svg { width: 20px; height: 20px; }
  .intro { padding: 36px 0 20px; }
  .intro p:last-child { font-size: 14px; }
  .controls { top: 62px; }
  .proposal-grid { grid-template-columns: 1fr; gap: 16px; }
  .card-cover { aspect-ratio: 1.6 / 1; }
  .card-body h3 { min-height: auto; }
  .footer-inner { min-height: 70px; }
  .modal { padding: 0; }
  .modal-panel { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .modal-header { min-height: 62px; padding-left: 14px; }
  .modal-heading h2 { font-size: 15px; }
  .pdf-toolbar { min-height: 58px; padding-inline: 8px; }
  .toolbar-divider, .zoom-label, .toolbar-text, .toolbar-download span { display: none; }
  .toolbar-download { margin-left: 0; }
  .canvas-wrap { padding: 12px; }
}

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