:root {
  color-scheme: light;
  --ink: #1d2a27;
  --muted: #6d7975;
  --line: #dce3df;
  --paper: #f6f7f2;
  --card: #ffffff;
  --green: #127562;
  --green-dark: #0b5648;
  --green-soft: #e6f2ed;
  --gold: #d8a44f;
  --series-3: #7886a8;
  --series-4: #a7798f;
  --series-5: #8b7656;
  --shadow: 0 18px 60px rgba(27, 54, 47, 0.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 0%, rgba(216, 164, 79, 0.12), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}
button, input { font: inherit; }
button, label[for], .drop-zone { cursor: pointer; }

.app-shell { width: min(1440px, 100%); margin: 0 auto; padding: 44px 48px 80px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, "Noto Serif TC", serif; font-size: clamp(36px, 5vw, 64px); font-weight: 500; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 20px; }
.subtitle { margin-bottom: 0; color: var(--muted); }
#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.import-button {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 190px;
  padding: 15px 20px; border-radius: 12px; background: var(--green); color: white;
  box-shadow: 0 8px 20px rgba(18, 117, 98, .18); transition: transform .18s, background .18s;
}
.import-button:hover { transform: translateY(-2px); background: var(--green-dark); }
.import-button span { font-weight: 700; }
.import-button small { margin-top: 2px; opacity: .7; }
.privacy-notice {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 13px 16px;
  border: 1px solid rgba(18, 117, 98, .22); border-radius: 12px; background: var(--green-soft);
}
.privacy-icon { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--green); color: white; font-size: 13px; font-weight: 700; }
.privacy-notice strong { display: block; margin-bottom: 2px; color: var(--green-dark); font-size: 13px; }
.privacy-notice p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.drop-zone {
  min-height: 340px; border: 1px dashed #aebbb6; border-radius: 20px; display: grid;
  place-content: center; justify-items: center; gap: 18px; text-align: center; background: rgba(255,255,255,.45);
  transition: border .18s, background .18s, transform .18s;
}
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--green); background: var(--green-soft); transform: translateY(-2px); }
.drop-zone strong, .drop-zone span { display: block; }
.drop-zone span { margin-top: 7px; color: var(--muted); font-size: 14px; }
.drop-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--green); color: white; font-size: 28px; }
.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; }
.filters, .results { background: var(--card); border: 1px solid rgba(220, 227, 223, .8); border-radius: 18px; box-shadow: var(--shadow); }
.filters { position: sticky; top: 24px; max-height: calc(100vh - 48px); padding: 24px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.filter-heading, .results-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.filter-heading { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.text-button { padding: 4px 0; border: 0; background: none; color: var(--green); font-size: 13px; font-weight: 700; }
.filter-section { border-bottom: 1px solid var(--line); }
.filter-section:last-child { border-bottom: 0; }
.filter-section summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; list-style: none; cursor: pointer; font-size: 13px; font-weight: 700; }
.filter-section summary::-webkit-details-marker { display: none; }
.filter-section summary::after { content: "⌄"; color: var(--muted); font-size: 16px; transition: transform .18s; }
.filter-section[open] summary::after { transform: rotate(180deg); }
.filter-content { padding: 0 0 20px; }
.people-filters { display: grid; gap: 7px; max-height: 224px; padding-right: 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.person-option { display: grid; grid-template-columns: 18px 9px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 34px; }
.person-option input { width: 16px; height: 16px; accent-color: var(--green); }
.person-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.dot-2 { background: var(--gold); }
.dot-3 { background: #7886a8; }
.dot-4 { background: #a7798f; }
.dot-5 { background: var(--series-5); }
.person-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.person-count { color: var(--muted); font-size: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.field-grid label { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: default; }
input[type="date"], input[type="time"], input[type="search"] { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfa; color: var(--ink); }
input[type="search"]::placeholder { color: var(--muted); }
.keyword-label { display: block; cursor: text; }
input:focus-visible, button:focus-visible, label[for]:focus-within { outline: 3px solid rgba(18,117,98,.2); outline-offset: 2px; }
.field-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.results { min-height: 500px; overflow: hidden; }
.results-header { padding: 24px 28px; border-bottom: 1px solid var(--line); }
.file-name { margin-bottom: 6px; color: var(--green); font-size: 12px; font-weight: 700; }
.result-range { margin: 3px 0 0; color: var(--muted); font-size: 13px; text-align: right; }
.results-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 11px; }
.results-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ai-summary-button,
.download-button {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0;
  border-radius: 9px; background: var(--green); color: white; font-size: 13px; font-weight: 700;
}
.ai-summary-button { border: 1px solid var(--green); background: var(--card); color: var(--green-dark); }
.ai-summary-button:hover { background: var(--green-soft); }
.download-button:hover { background: var(--green-dark); }
.ai-summary-button:disabled, .download-button:disabled { cursor: not-allowed; opacity: .45; }
.ai-status { margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.share-dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.share-dialog::backdrop { background: rgba(15, 28, 24, .52); }
.share-dialog-content { padding: 24px; }
.share-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-close { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--muted); font-size: 20px; cursor: pointer; }
.share-dialog-description { margin: 16px 0; color: var(--muted); font-size: 13px; }
.share-dialog label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.share-dialog textarea { width: 100%; min-height: 280px; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfa; color: var(--ink); font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.copy-status { min-height: 20px; margin: 8px 0 0; color: var(--green-dark); font-size: 12px; }
.share-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.platform-heading { margin: 20px 0 10px; font-size: 12px; font-weight: 700; }
.ai-platform-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
.ai-platform-link { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.ai-platform-link:hover { border-color: var(--green); background: var(--green-soft); }
.ai-platform-link strong { font-size: 13px; }
.ai-platform-link span { color: var(--muted); font-size: 11px; }
.timeline-chart { padding: 24px 28px 18px; border-bottom: 1px solid var(--line); }
.chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.chart-heading h3 { margin: 0 0 5px; font-size: 16px; }
.chart-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.metric-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.metric-switch button { padding: 7px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-switch button[aria-pressed="true"] { background: var(--card); color: var(--green-dark); box-shadow: 0 2px 8px rgba(27,54,47,.09); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; min-height: 24px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--green); }
.chart-legend .legend-2 { background: var(--gold); }
.chart-legend .legend-3 { background: var(--series-3); }
.chart-legend .legend-4 { background: var(--series-4); }
.chart-legend .legend-5 { background: var(--series-5); }
.chart-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; margin-top: 8px; padding-bottom: 3px; }
.timeline-svg { display: block; height: 280px; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 10px; }
.chart-bar { fill: var(--green); }
.chart-bar.series-2 { fill: var(--gold); }
.chart-bar.series-3 { fill: var(--series-3); }
.chart-bar.series-4 { fill: var(--series-4); }
.chart-bar.series-5 { fill: var(--series-5); }
.chart-empty { fill: var(--muted); font-size: 13px; }
.chart-note { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.message-list { padding: 0 28px 32px; }
.date-divider { display: flex; align-items: center; gap: 14px; margin: 27px 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.date-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.message { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; padding: 15px 0; border-bottom: 1px solid #eef1ef; }
.message time { padding-top: 2px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.message-body strong { display: block; margin-bottom: 5px; color: var(--green-dark); font-size: 13px; }
.message-body p { margin: 0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.message-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 18px 24px 28px; }
.message-pagination p { margin: 0; color: var(--muted); font-size: 12px; }
.empty-state { padding: 90px 24px; text-align: center; color: var(--muted); }
.empty-state span { display: block; margin-bottom: 16px; }
.secondary-button { padding: 9px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--green); font-weight: 700; }

@media (max-width: 860px) {
  .app-shell { padding: 28px 20px 60px; }
  .hero { align-items: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; overflow: visible; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-grid label { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .hero { flex-direction: column; }
  .import-button { width: 100%; }
  .drop-zone { min-height: 280px; padding: 24px; }
  .field-grid { grid-template-columns: 1fr; }
  .results-header { flex-direction: column; }
  .result-range { text-align: left; }
  .results-actions { width: 100%; align-items: flex-start; }
  .results-buttons { width: 100%; }
  .ai-summary-button, .download-button { width: 100%; justify-content: center; }
  .ai-status { text-align: left; }
  .share-dialog-content { padding: 20px; }
  .share-dialog textarea { min-height: 220px; }
  .share-dialog-actions > * { width: 100%; justify-content: center; text-align: center; }
  .timeline-chart { padding-left: 20px; padding-right: 20px; }
  .chart-heading { flex-direction: column; }
  .message-list { padding-left: 20px; padding-right: 20px; }
  .message-pagination { flex-direction: column; }
}
