:root {
  color-scheme: light;
  --red: #a60012;
  --red-dark: #76000d;
  --ink: #17212b;
  --muted: #61707d;
  --line: #dce2e7;
  --paper: #ffffff;
  --canvas: #f3f5f7;
  --safe: #0f766e;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app-shell { width: min(860px, 100%); margin: 0 auto; min-height: 100vh; padding: 20px 18px 64px; }
.login-view { width: min(420px, 100%); margin: 9vh auto 0; text-align: center; }
.brand-mark { width: 78px; height: 78px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 22px; background: var(--red); color: white; font-size: 22px; font-weight: 800; box-shadow: 0 14px 35px #a6001230; }
h1 { margin: 0; letter-spacing: -.02em; }
.login-view > p { color: var(--muted); margin: 8px 0 26px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: 0 8px 28px #17212b0a; }
.form-stack { display: grid; gap: 15px; text-align: left; }
label { display: grid; gap: 7px; color: #46525d; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd4dc; border-radius: 11px; padding: 12px 13px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px #a6001215; }
textarea { min-height: 94px; resize: vertical; }
.primary { border: 0; color: white; background: var(--red); border-radius: 11px; padding: 12px 18px; font-weight: 800; }
.primary:hover { background: var(--red-dark); }
.secondary { border: 1px solid var(--red); color: var(--red); background: white; border-radius: 10px; padding: 9px 13px; font-weight: 700; }
.message { min-height: 21px; color: var(--red); font-size: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 5px 0 14px; }
.eyebrow { display: block; color: var(--red); font-size: 10px; font-weight: 900; letter-spacing: .16em; margin-bottom: 3px; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 9px 12px; color: var(--muted); }
.user-row { display: flex; justify-content: space-between; align-items: center; color: var(--muted); margin-bottom: 16px; font-size: 14px; }
.password-panel { margin-bottom: 16px; border-color: #f2bd44; }
.password-panel h2 { margin: 0 0 4px; font-size: 18px; }
.badge { border-radius: 999px; padding: 4px 9px; background: #dcfce7; color: #166534; font-size: 12px; font-weight: 800; }
.badge.offline { background: #ffedd5; color: #9a3412; }
.selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.search-label { margin-top: 15px; }
.search-box { display: flex; gap: 8px; }
.search-box input { flex: 1; }
.search-box button { flex: 0 0 auto; }
.search-panel > .secondary { margin-top: 12px; }
.subtle { color: var(--muted); font-size: 12px; margin-top: 8px; }
.empty-state { text-align: center; color: var(--muted); padding: 70px 24px; }
.empty-state h2 { color: var(--ink); margin: 7px 0; font-size: 20px; }
.empty-icon { font-size: 46px; color: #aeb8c0; }
.guidance-card { margin-top: 18px; padding: 20px; color: white; border-radius: 18px; background: linear-gradient(140deg, #212d38, #314452); }
.guidance-card h2 { margin: 0 0 8px; font-size: 20px; }
.guidance-card p { color: #e4ebef; line-height: 1.65; }
.guidance-card ol { padding-left: 22px; line-height: 1.7; }
.safety { border-left: 3px solid #ffcf5c; padding: 9px 12px; background: #ffffff12; border-radius: 6px; }
.section-title { font-size: 15px; margin: 24px 3px 10px; color: #46525d; }
.result-card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 16px; margin: 10px 0; }
.result-card h3 { margin: 0 0 7px; font-size: 17px; }
.result-card p { margin: 7px 0; color: #46525d; line-height: 1.65; }
.detail-section { margin: 13px 0; padding: 12px 14px; border-radius: 11px; background: #f6f8fa; }
.detail-section h4 { margin: 0 0 7px; color: var(--red-dark); font-size: 14px; }
.detail-list { margin: 0; padding-left: 22px; color: #34424e; line-height: 1.7; }
.detail-list li + li { margin-top: 5px; }
.keyword-highlight { background: #ffe066; color: #2a2200; padding: .05em .2em; border-radius: .22em; box-shadow: inset 0 -1px 0 #e6bd18; }
.source-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.source-meta span { background: #eef2f5; border-radius: 999px; padding: 4px 8px; }
.page-button { border: 0; border-radius: 9px; padding: 8px 11px; background: #eef2f5; color: var(--ink); font-weight: 700; }
.modal { position: fixed; inset: 0; z-index: 10; background: #081018ed; padding: 58px 12px 20px; overflow: auto; }
.modal img { display: block; width: min(1100px, 100%); margin: 0 auto; background: white; }
.modal-close { position: fixed; top: 12px; right: 14px; border: 0; border-radius: 9px; padding: 9px 13px; background: white; color: var(--ink); font-weight: 800; }
.modal-loading { color: white; text-align: center; padding: 60px; }
.viewer-shell { width: min(1280px, 100%); margin: 0 auto; padding: 16px; }
.viewer-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.viewer-bar h1 { font-size: 19px; }
.viewer-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.match-panel { margin-bottom: 14px; }
.match-panel h2 { margin: 0 0 7px; font-size: 17px; }
.page-text { max-height: 270px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: #f6f8fa; border-radius: 10px; padding: 13px; line-height: 1.65; color: #34424e; font-family: inherit; font-size: 14px; }
.pdf-frame { width: 100%; height: calc(100vh - 370px); min-height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #dfe4e8; }
@media (max-width: 620px) {
  .page-text { max-height: 230px; }
  .pdf-frame { height: 68vh; min-height: 480px; }
}
.admin-shell { width: min(1100px, 100%); margin: 0 auto; padding: 22px 18px 60px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.full-span { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; }
.stack { display: grid; gap: 10px; }
.admin-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-nav a { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: white; color: var(--red-dark); text-decoration: none; font-weight: 700; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 8px; }
.admin-dialog { width: min(580px, calc(100% - 28px)); max-height: 85vh; overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 24px; color: var(--ink); }
.admin-dialog::backdrop { background: #17212b99; }
.admin-dialog h2 { margin: 0 0 16px; }
.admin-dialog li { margin: 9px 0; overflow-wrap: anywhere; }
.admin-dialog .admin-actions { justify-content: flex-end; margin-top: 22px; }
.document-title { min-width: 180px; max-width: 470px; overflow-wrap: anywhere; }
.document-title a { color: var(--red-dark); }
.danger { color: var(--red-dark); background: #fff0f0; }
button:disabled { opacity: .5; cursor: wait; }
#recyclePanel details { margin-top: 16px; }
#recyclePanel summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.small { font-size: 12px; }
@media (max-width: 620px) {
  .selectors, .admin-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .search-box { display: grid; }
  .app-shell { padding-inline: 13px; }
  .panel { padding: 16px; }
}
