:root {
  --bg: #fbfaf8; --surface: #ffffff; --fill: #f4f2ef; --line: #e9e6e2; --line-strong: #d3cfd8;
  --ink: #24222e; --body: #3f3d4a; --muted: #6b6878;
  --brand: #6158ca; --brand-ink: #5047b8; --link: #0b6cbf;
  --warn: #8a5300; --warn-bg: #fbf0dc; --warn-line: #e3b866;
  --gz: #1f1d2b; --gz-ink: #ffffff; --hl: #fff0a0;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --r: 8px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--body); font-family: var(--font); line-height: 1.7; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; margin-top: 1.5em; }
h3 { font-size: 18px; font-weight: 500; }
h4 { font-size: 16px; font-weight: 500; margin-top: 1em; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.container { min-height: 60vh; padding-bottom: 48px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
input[type=search], input[type=text], input[type=date], select {
  border: 1px solid var(--line-strong); border-radius: var(--r); padding: 8px 12px; background: var(--surface); color: var(--ink);
}
button[type=submit], .btn { background: var(--brand); color: #fff; border: 0; border-radius: var(--r); padding: 8px 16px; font-weight: 500; }
button[type=submit]:hover { background: var(--brand-ink); }

/* header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { font-size: 20px; font-weight: 700; color: var(--brand-ink); }
.brand-sub { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.site-nav { display: flex; gap: 18px; }
.site-nav a { color: var(--ink); font-weight: 500; padding: 4px 2px; border-bottom: 2px solid transparent; }
.site-nav a.active { border-bottom-color: var(--brand); color: var(--brand-ink); }
.header-search { margin-left: auto; display: flex; gap: 6px; }
.header-search input { width: 220px; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px; padding: 24px 0 40px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.api-log summary { cursor: pointer; }
.api-log ul { padding-left: 1.2em; }

/* home */
.hero { padding: 56px 0 32px; max-width: 760px; }
.hero h1 { font-size: 40px; }
.hero .lead { font-size: 18px; }
.hero-search { display: flex; gap: 8px; margin: 20px 0 8px; }
.hero-search input { flex: 1; font-size: 18px; padding: 12px 16px; }
.hero-search button { font-size: 18px; padding: 12px 20px; }
.hint { font-size: 14px; color: var(--muted); }
.schedule { margin-top: 24px; }
.day-title { font-size: 16px; font-weight: 500; color: var(--muted); margin: 24px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.empty { color: var(--muted); padding: 12px 0; }
.upcoming-day { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-bottom: 8px; }
.upcoming-day .date { color: var(--muted); font-size: 14px; min-width: 150px; }
.chip { display: inline-block; background: var(--fill); border-radius: 999px; padding: 2px 12px; font-size: 14px; color: var(--ink); }
.more { margin-top: 16px; }

/* meet list */
.meet-list { list-style: none; margin: 0; padding: 0; }
.meet-row { border-bottom: 1px solid var(--line); }
.meet-link { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: start; padding: 10px 4px; color: inherit; }
.meet-link:hover { background: var(--fill); text-decoration: none; }
.meet-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.meet-kind { display: block; font-size: 14px; color: var(--muted); }
.meet-title { display: block; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { display: inline-block; font-size: 13px; font-weight: 700; line-height: 1.5; padding: 0 8px; border-radius: 4px; white-space: nowrap; vertical-align: middle; }
.badge-gazette { background: var(--gz); color: var(--gz-ink); }
.badge-ai { background: var(--warn); color: #fff; }
.badge-processing { background: repeating-linear-gradient(135deg, var(--warn-bg), var(--warn-bg) 4px, #fff 4px, #fff 8px); color: var(--warn); border: 1px solid var(--warn-line); }
.badge-scheduled { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }
.badge-novideo { background: var(--fill); color: var(--muted); }
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.type-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-check { background: var(--fill); border-radius: 999px; padding: 2px 10px; font-size: 14px; }
.pager { display: flex; gap: 16px; align-items: center; margin: 12px 0; }
.legend { font-size: 14px; margin-top: 24px; }

/* meet page */
.meet-head { margin: 24px 0 16px; }
.meet-head .meet-kind { font-size: 15px; }
.meet-meta { color: var(--muted); }
.meet-subject, .meet-docs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 14px; margin-bottom: 8px; }
.meet-subject summary, .meet-docs summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.meet-docs ul { padding-left: 1.2em; margin: 4px 0 8px; }
.view-switch { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.view-switch a { padding: 8px 4px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.view-switch a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.transcript-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.toc { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; font-size: 14px; }
.toc h3 { font-size: 14px; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li.toc-unit { margin-top: 8px; border-left: 2px solid var(--brand); padding-left: 8px; }
.toc li.toc-unit > a, .toc li.toc-unit > span { color: var(--ink); font-weight: 500; }
.toc li.toc-item { padding: 2px 0 2px 10px; font-size: 13px; }
.toc li.toc-item.kind-vote a { color: var(--warn); }
.toc li.toc-item.kind-procedure a, .toc li.toc-item.kind-attachment a, .toc li.toc-item.kind-group a { color: var(--muted); }
.toc li.toc-item.elsewhere a { font-style: italic; }
.toc .off { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc .toc-tag { color: var(--muted); font-size: 11px; margin-left: 4px; }
.toc a { color: var(--body); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transcript-note { font-size: 14px; color: var(--muted); }
.section-title { font-size: 16px; color: var(--ink); margin: 28px 0 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.seg-title { font-size: 14px; color: var(--muted); margin: 20px 0 0; font-weight: 500; }
.seg-title.kind-vote { color: var(--warn); }
.seg-title.kind-case { color: var(--brand-ink); }
.block { padding: 8px 0 8px; scroll-margin-top: 12px; }
.block:target { background: var(--hl); border-radius: var(--r); padding: 8px; }
.block .speaker { font-weight: 700; color: var(--ink); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-top: 10px; }
.block .speaker a { color: var(--ink); }
.block .speaker .title { font-weight: 400; font-size: 14px; color: var(--muted); }
.block .speaker .unknown { color: var(--warn); }
.role-主席 .speaker, .block .speaker.role-主席 { color: var(--brand-ink); }
.block .text { white-space: pre-wrap; color: var(--body); }
.kind-主席程序 .text { color: var(--muted); font-size: 15px; }
.kind-附件 .text, .kind-議事錄 .text, .kind-宣讀表決 .text { color: var(--muted); font-size: 14px; max-height: 12em; overflow: auto; background: var(--fill); padding: 8px; border-radius: var(--r); white-space: pre-wrap; }
.block-tools { display: flex; gap: 6px; opacity: 0; transition: opacity .15s; font-size: 13px; }
.block:hover .block-tools, .block:focus-within .block-tools, .block:target .block-tools { opacity: 1; }
.block-tools button, .speaker .play { background: transparent; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--body); padding: 1px 8px; font-size: 13px; }
.block-tools button:hover, .speaker .play:hover { border-color: var(--brand); color: var(--brand-ink); }
.sentences .sentence { cursor: pointer; border-radius: 3px; }
.sentences .sentence:hover { background: var(--fill); }
.sentences .sentence.playing { background: var(--hl); }
.video-panel { position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.video-panel video { width: 100%; background: #14102e; border-radius: 4px; aspect-ratio: 16/9; }
.video-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 14px; margin-top: 8px; }
.clip-tool { font-size: 14px; margin-top: 8px; }
.clip-tool summary { cursor: pointer; }
.no-transcript { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; grid-template-columns: 1fr 380px; gap: 24px; }
.no-transcript .video-panel { position: static; }

/* search */
.search-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.search-form input[type=search] { flex: 1; min-width: 240px; }
.search-form.inline { margin: 16px 0; }
.result-count { color: var(--muted); }
.result-group { margin-top: 20px; }
.result-group h3 { font-size: 16px; }
.hit-list { list-style: none; margin: 0; padding: 0; }
.hit { padding: 8px 0 8px 12px; border-left: 3px solid var(--line); margin-bottom: 8px; }
.hit-speaker { font-weight: 700; color: var(--ink); }
.hit-text { margin: 2px 0; }
.hit-text em { background: var(--hl); font-style: normal; font-weight: 700; }
.hit-link { font-size: 14px; }

/* legislators */
.party-group h2 { margin-top: 1.2em; }
.legislator-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.legislator-grid a { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; color: var(--ink); text-align: center; }
.legislator-grid a:hover { border-color: var(--brand); text-decoration: none; }
.legislator-grid img, .legislator-grid .no-photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--fill); }
.legislator-grid .name { font-weight: 700; }
.legislator-grid .area { font-size: 13px; }
.legislator-grid li.left a { opacity: .6; }
.person-head { display: flex; gap: 20px; align-items: flex-start; margin: 24px 0; }
.person-photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.person-stats { color: var(--ink); }

/* prose */
.prose { max-width: 760px; }
.info-table { border-collapse: collapse; margin-bottom: 1em; }
.info-table th, .info-table td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.info-table th { white-space: nowrap; background: var(--fill); }

@media (max-width: 1200px) {
  .transcript-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .video-panel { position: fixed; right: 12px; bottom: 12px; width: 320px; z-index: 10; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
  .no-transcript { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .transcript-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: 14em; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; }
  .video-panel { width: calc(100% - 24px); }
  .hero h1 { font-size: 28px; }
  .header-search { margin-left: 0; width: 100%; }
  .header-search input { flex: 1; }
  .meet-link { grid-template-columns: 48px 1fr; }
  .meet-link .badge { grid-column: 2; justify-self: start; }
  .person-head { flex-direction: column; }
}

.doc-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; font-size: 14px; margin-bottom: 8px; }
.doc-nav a { display: inline-block; min-width: 28px; text-align: center; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 6px; color: var(--body); }
.doc-nav a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
details.text.long summary { cursor: pointer; color: var(--muted); }
