:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --text: #1b2524;
  --text-2: #4c5a58;
  --muted: #6d7b79;
  --border: #d9e1df;
  --brand: #0b5d57;
  --brand-2: #0e7a72;
  --brand-ink: #ffffff;
  --link: #075e8c;
  --open: #157f3b;
  --open-bg: #e3f4e8;
  --upcoming: #8a6100;
  --upcoming-bg: #fdf1d3;
  --closed: #4a4f55;
  --closed-bg: #e9ebed;
  --unknown: #5d6670;
  --unknown-bg: #eef0f2;
  --new: #c4231d;
  --hot: #b33a00;
  --hot-bg: #ffe9dc;
  --shadow: 0 1px 2px rgba(16, 40, 38, .06), 0 4px 16px rgba(16, 40, 38, .06);
  --radius: 12px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1716;
    --surface: #172221;
    --surface-2: #1d2b2a;
    --text: #e6eeec;
    --text-2: #b7c5c2;
    --muted: #8fa09d;
    --border: #2b3b39;
    --brand: #34a99f;
    --brand-2: #4cc2b7;
    --brand-ink: #062320;
    --link: #7cc4ef;
    --open: #6fd394;
    --open-bg: #173826;
    --upcoming: #f1c45c;
    --upcoming-bg: #3a2f12;
    --closed: #b9c0c7;
    --closed-bg: #2a3036;
    --unknown: #b5bec8;
    --unknown-bg: #262d33;
    --new: #ff7a72;
    --hot: #ff9b62;
    --hot-bg: #3c2416;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
}
a { color: var(--link); }
h1, h2, h3 { line-height: 1.35; margin: 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }

/* Header */
.site-header { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-header { background: #0c3532; } }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; padding-bottom: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; color: rgba(255, 255, 255, .18); flex: none; }
.brand h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: .02em; }
.tagline { margin: 0; font-size: .9rem; opacity: .85; }
.clock { display: flex; gap: 20px; margin: 0; font-variant-numeric: tabular-nums; }
.clock div { display: flex; flex-direction: column; }
.clock dt { font-size: .78rem; opacity: .8; }
.clock dd { margin: 0; font-size: 1rem; font-weight: 600; }

/* Notice & filters */
.notice {
  margin: 20px 0 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-2); font-size: .9rem; border-left: 4px solid var(--brand);
}
.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 12px; box-shadow: var(--shadow);
}
.filter-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.filter-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .9rem; cursor: pointer; min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.chip .count { opacity: .75; margin-left: 4px; font-variant-numeric: tabular-nums; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.select-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; min-width: 0; }
select {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); min-height: 40px; width: 100%;
}
.btn-reset {
  font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 8px; padding: 8px 16px; min-height: 40px; cursor: pointer;
}
.summary-bar { margin: 16px 2px 10px; color: var(--text-2); font-size: .92rem; }
.summary-bar strong { color: var(--text); }

/* Cards */
.cards { display: grid; gap: 14px; margin-bottom: 32px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card.is-closed { opacity: .92; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 700; border-radius: 6px; padding: 2px 8px; line-height: 1.6; }
.st-open { background: var(--open-bg); color: var(--open); }
.st-upcoming { background: var(--upcoming-bg); color: var(--upcoming); }
.st-closed { background: var(--closed-bg); color: var(--closed); }
.st-unknown { background: var(--unknown-bg); color: var(--unknown); }
.b-new { background: var(--new); color: #fff; letter-spacing: .05em; }
.b-hot { background: var(--hot-bg); color: var(--hot); }
.b-dead { background: var(--closed-bg); color: var(--closed); font-weight: 600; }
.card h2 { font-size: 1.08rem; font-weight: 700; margin: 2px 0 2px; word-break: break-word; }
.agency { color: var(--text-2); font-size: .92rem; margin: 0 0 10px; }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; margin: 0 0 10px; }
.meta div { min-width: 0; }
.meta dt { font-size: .78rem; color: var(--muted); }
.meta dd { margin: 0; font-size: .94rem; word-break: break-word; }
.meta .unknown { color: var(--muted); }
.brief { margin: 0 0 12px; color: var(--text-2); font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.card-views { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost, .btn-primary {
  font: inherit; font-size: .92rem; border-radius: 8px; padding: 7px 14px; min-height: 40px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn-ghost { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); font-weight: 600; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost[aria-expanded="true"] { background: var(--surface-2); }

.detail { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); display: grid; gap: 12px; }
.detail h3 { font-size: .9rem; color: var(--muted); margin-bottom: 2px; }
.detail p, .detail ul { margin: 0; }
.detail ul { padding-left: 1.2em; }
.detail .content { white-space: pre-line; font-size: .93rem; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; max-height: 360px; overflow: auto; }
.detail .small { font-size: .82rem; color: var(--muted); }
.warn { color: var(--hot); font-weight: 600; }

.state-msg { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 20px 0 96px; font-size: .88rem; color: var(--text-2); }
.site-footer p { margin: 0 0 8px; }
.views { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Chat */
.chat-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 30; display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 999px; padding: 12px 18px;
  font: inherit; font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); cursor: pointer;
}
.chat-fab svg { width: 22px; height: 22px; }
.chat {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 32px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); display: flex; flex-direction: column; overflow: hidden;
}
.chat[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 12px 14px; background: var(--brand); color: #fff; }
.chat-head h2 { font-size: 1rem; }
.chat-note { margin: 2px 0 0; font-size: .8rem; opacity: .9; }
.chat-note span { font-weight: 700; margin-left: 4px; }
.icon-btn { background: transparent; border: 0; color: inherit; font-size: 1.1rem; cursor: pointer; min-width: 36px; min-height: 36px; border-radius: 8px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: .93rem; white-space: pre-wrap; word-break: break-word; }
.msg.bot { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.msg.user { background: var(--brand); color: var(--brand-ink); align-self: flex-end; }
.msg.sys { background: var(--hot-bg); color: var(--hot); align-self: stretch; max-width: 100%; }
.examples { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; white-space: normal; }
.examples button { text-align: left; font: inherit; font-size: .88rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form textarea { flex: 1; font: inherit; font-size: .93rem; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--surface); color: var(--text); min-width: 0; }
.chat-form button:disabled, .chat-form textarea:disabled { opacity: .55; cursor: not-allowed; }
.chat-foot { margin: 0; padding: 0 12px 10px; font-size: .75rem; color: var(--muted); background: var(--surface); }

@media (max-width: 640px) {
  .brand h1 { font-size: 1.15rem; }
  .clock { width: 100%; justify-content: space-between; gap: 12px; }
  .clock dd { font-size: .92rem; }
  .meta { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .actions { width: 100%; }
  .actions > * { flex: 1; justify-content: center; }
  .chat { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; }
  .chat-fab span { display: none; }
  .chat-fab { padding: 14px; }
}
