/* ============================================================
   三塊地官司 — 杜叔叔庭審準備中心 樣式
   淡色 / 圖形優先 / 中文為主 / 杜叔叔讀得懂
   ============================================================ */
:root {
  --bg: #faf8f3;
  --card: #fff;
  --border: #e6e0d0;
  --accent: #8a6d3b;
  --accent-soft: #f5ecd9;
  --accent-deep: #6e562d;
  --text: #2a2418;
  --text-soft: #5a4f35;
  --muted: #8a7c5a;
  --vatar: #c25450;
  --vatar-bg: #f8d7d5;
  --narea: #6b8e23;
  --narea-bg: #e7efd1;
  --rongzhen: #d8a657;
  --rongzhen-bg: #fcebc6;
  --completed: #6b8e23;
  --warning: #d8a657;
  --danger: #c25450;
  --info: #5a8aa8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Microsoft JhengHei", "PingFang TC", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

/* 凍結整個 header + nav 區（包裝成一個 sticky 群） */
.site-top {
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(138, 109, 59, 0.15);
}

/* ---------- Header ---------- */
header.site-header {
  background: linear-gradient(135deg, var(--accent-soft) 0%, #f9f4e6 100%);
  border-bottom: 3px solid var(--accent);
  padding: 18px 5%;
}
.site-header h1 {
  font-size: 24px;
  color: var(--accent-deep);
  margin-bottom: 4px;
}
.site-header .case-info {
  font-size: 13px;
  color: var(--text-soft);
}
.site-header .case-info strong { color: var(--accent-deep); }

/* ---------- Nav Tabs ---------- */
nav.tabs {
  display: flex;
  gap: 4px;
  padding: 0 5%;
  background: white;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
nav.tabs a {
  padding: 14px 18px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
}
nav.tabs a:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
nav.tabs a.active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Main Content ---------- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 5%;
}

.page { display: none; }
.page.active { display: block; }

main h1 {
  font-size: 28px;
  color: var(--accent-deep);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 10px;
  margin: 20px 0 24px;
}
main h2 {
  font-size: 21px;
  color: var(--accent-deep);
  margin: 28px 0 14px;
  padding: 8px 14px;
  background: var(--accent-soft);
  border-left: 5px solid var(--accent);
  border-radius: 0 8px 8px 0;
  scroll-margin-top: 160px;
}
main h3 {
  font-size: 18px;
  color: var(--text);
  margin: 22px 0 10px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  scroll-margin-top: 160px;
}
main h4 {
  font-size: 16px;
  color: var(--accent-deep);
  margin: 16px 0 8px;
  scroll-margin-top: 160px;
}
main p { margin: 10px 0; }
main ul, main ol { margin: 10px 0 10px 28px; }
main li { margin: 4px 0; }
main blockquote {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 12px 18px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-soft);
}
main code {
  background: #fff7e0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: Consolas, monospace;
  font-size: 13px;
  color: var(--accent-deep);
}
main strong { color: var(--accent-deep); }

/* ---------- Tables ---------- */
main table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
main th {
  background: var(--accent);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}
main td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: top;
}
main tr:nth-child(even) td { background: #fbfaf5; }
main tr:hover td { background: var(--accent-soft); }

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.info-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.info-card.vatar { border-left: 4px solid var(--vatar); }
.info-card.narea { border-left: 4px solid var(--narea); }
.info-card.rongzhen { border-left: 4px solid var(--rongzhen); }

/* ---------- Floating Source Button ---------- */
.source-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--accent);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(138,109,59,0.3);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  border: none;
  transition: transform 0.2s, background 0.2s;
}
.source-fab:hover { background: var(--accent-deep); transform: translateY(-2px); }

.top-fab {
  position: fixed;
  right: 24px;
  bottom: 144px;
  background: var(--info);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(90,138,168,0.35);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  border: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s, transform 0.25s, background 0.2s;
  pointer-events: none;
}
.top-fab.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.top-fab:hover { background: #406a86; }

.msg-fab {
  position: fixed;
  right: 24px;
  bottom: 84px;
  background: var(--vatar);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(194,84,80,0.35);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  border: none;
}
.msg-fab:hover { background: #a83a36; transform: translateY(-2px); }

.msg-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
  align-items: center;
  justify-content: center;
}
.msg-modal.open { display: flex; }
.msg-modal-content {
  background: white;
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 90%;
  position: relative;
}
.msg-modal-content h2 {
  color: var(--accent-deep);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}
.msg-modal-content label {
  display: block;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 600;
  margin: 12px 0 4px;
}
.msg-modal-content select,
.msg-modal-content input,
.msg-modal-content textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.msg-modal-content textarea { resize: vertical; }
.msg-send-btn {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.msg-send-btn:hover { background: var(--accent-deep); }
.msg-modal-content .close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
}
.msg-result { margin-top: 12px; font-size: 13px; }

/* 圖示框（每頁開頭 SVG 容器） */
.diagram-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px 12px;
  margin: 18px 0 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.diagram-box h2 {
  font-size: 16px !important;
  color: var(--accent-deep);
  background: none !important;
  border: none !important;
  padding: 0 !important;
  margin-bottom: 12px !important;
}

.header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.header-right { text-align: right; min-width: 200px; }
.live-clock { font-size: 14px; color: var(--accent-deep); font-weight: 600; font-family: Consolas, monospace; }
.live-weather { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

@media (max-width: 768px) {
  .header-row { flex-direction: column; }
  .header-right { text-align: left; }
}

/* ---------- Source Panel (slide-out) — 法庭文書式排版 ---------- */
.source-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 60%;
  max-width: 820px;
  height: 100vh;
  background: #f3eedd;
  padding: 0;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  z-index: 70;
  box-shadow: -8px 0 24px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
}
.source-panel.open { transform: translateX(0); }
.source-toolbar {
  background: #2a2418;
  color: #f0e5c0;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.source-toolbar h2 {
  color: #f0e5c0;
  font-size: 16px;
  margin: 0;
  flex-shrink: 0;
}
.source-toolbar select {
  flex: 1;
  padding: 8px 10px;
  background: #4a4030;
  color: #f0e5c0;
  border: 1px solid #6a5d40;
  border-radius: 6px;
  font-size: 13px;
}
.source-toolbar .close-btn {
  background: #c25450;
  border: 2px solid white;
  color: white;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.source-toolbar .close-btn:hover {
  background: #a83a36;
  transform: scale(1.08);
}
/* 桌面/手機通用 — 大紅關閉鈕貼右上更穩 */
@media (max-width: 768px) {
  .source-toolbar { padding: 10px 12px; gap: 8px; }
  .source-toolbar h2 { font-size: 14px; }
  .source-toolbar .close-btn { width: 48px; height: 48px; font-size: 24px; }
}
/* Google Docs / Word 樣式 ===================================== */
.source-paper {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  background: #e8e8e8;
}
.source-paper-inner {
  max-width: 816px;          /* Letter 紙寬度 8.5 inch ≈ 816px */
  margin: 0 auto;
  background: white;
  padding: 96px 96px;        /* 1 inch margin 四邊·像 Word 預設 */
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.12);
  font-family: "Calibri", "PingFang TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  font-size: 16px;           /* Word 11pt ≈ 14px·提一級到 16 給 Thomas 看得清 */
  line-height: 1.6;
  color: #202124;
}
/* Google Docs / Word 標題樣式·藍色 */
.source-paper-inner h1 {
  font-size: 28px;
  font-weight: 400;
  color: #1967d2;
  margin: 0 0 24px;
  padding: 0;
  border: none;
  background: none;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  line-height: 1.3;
}
.source-paper-inner h2 {
  font-size: 22px;
  font-weight: 400;
  color: #1967d2;
  margin: 28px 0 14px;
  padding: 0;
  border: none;
  background: none;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.3;
}
.source-paper-inner h3 {
  font-size: 18px;
  font-weight: 600;
  color: #202124;
  margin: 22px 0 10px;
  padding: 0;
  border: none;
  line-height: 1.3;
}
.source-paper-inner h4 {
  font-size: 16px;
  font-weight: 600;
  color: #5f6368;
  margin: 18px 0 8px;
  line-height: 1.3;
}
.source-paper-inner p {
  margin: 0 0 14px;
  text-indent: 0;
}
.source-paper-inner blockquote {
  margin: 14px 0;
  padding: 12px 18px;
  border-left: 4px solid #1967d2;
  background: #f8f9fa;
  color: #3c4043;
  font-style: italic;
}
.source-paper-inner ol,
.source-paper-inner ul {
  margin: 12px 0 16px 36px;
  padding: 0;
}
.source-paper-inner ol li,
.source-paper-inner ul li {
  margin: 6px 0;
  line-height: 1.6;
}
.source-paper-inner ol {
  list-style: decimal;
  counter-reset: none;
}
.source-paper-inner ol > li {
  padding-left: 8px;
  position: static;
}
.source-paper-inner ol > li::before {
  content: none;
}
.source-paper-inner table {
  border-collapse: collapse;
  width: 100%;
  margin: 18px 0;
  font-size: 14px;
  border-radius: 0;
  box-shadow: none;
}
.source-paper-inner th {
  background: #f8f9fa;
  color: #202124;
  padding: 10px 14px;
  border: 1px solid #dadce0;
  text-align: left;
  font-weight: 600;
}
.source-paper-inner td {
  padding: 10px 14px;
  border: 1px solid #dadce0;
  background: white;
  vertical-align: top;
}
.source-paper-inner tr:nth-child(even) td { background: #fafbfc; }
.source-paper-inner tr:hover td { background: #f1f3f4; }
.source-paper-inner strong {
  font-weight: 600;
  color: #202124;
}
.source-paper-inner em {
  font-style: italic;
  color: #5f6368;
}
.source-paper-inner code {
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 14px;
  background: #f1f3f4;
  color: #c5221f;
  padding: 2px 6px;
  border-radius: 3px;
}
.source-paper-inner pre {
  background: #f8f9fa;
  color: #202124;
  padding: 14px 18px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0;
  border: 1px solid #dadce0;
}
.source-paper-inner hr {
  margin: 28px 0;
  border: none;
  border-top: 1px solid #dadce0;
}
.source-paper-inner a {
  color: #1967d2;
  text-decoration: underline;
}
/* 文檔標頭 — 像 Word 案號横排 */
.source-paper-header {
  font-size: 12px;
  color: #5f6368;
  margin: -50px -40px 32px;
  padding: 10px 0;
  border-bottom: 1px solid #dadce0;
  letter-spacing: normal;
  text-align: center;
  font-family: inherit;
}

@media (max-width: 768px) {
  .source-paper { padding: 8px 0; }
  .source-paper-inner { padding: 40px 24px; font-size: 15px; }
  .source-paper-header { margin: -20px -8px 20px; }
}

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  padding-left: 32px;
  margin: 20px 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.timeline-item {
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 22px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid white;
}
.timeline-item.critical { border-left: 4px solid var(--danger); }
.timeline-item.critical::before { background: var(--danger); }
.timeline-item.important { border-left: 4px solid var(--warning); }
.timeline-item.important::before { background: var(--warning); }

/* ---------- Footer ---------- */
footer.site-footer {
  background: #2a2418;
  color: #d4c9a8;
  text-align: center;
  padding: 24px;
  margin-top: 60px;
  font-size: 13px;
}
footer.site-footer a { color: var(--rongzhen); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  /* Header — title 不被切 */
  header.site-header { padding: 12px 14px; }
  .site-header h1 {
    font-size: 17px;
    line-height: 1.3;
    word-break: break-word;
    margin-bottom: 4px;
  }
  .site-header .case-info { font-size: 11px; line-height: 1.4; }
  .header-row { gap: 8px; }
  .header-right { min-width: 100%; text-align: left; }
  .live-clock { font-size: 12px; }
  .live-weather { font-size: 11px; }

  /* Nav tabs — 緊湊 */
  nav.tabs { padding: 0 8px; }
  nav.tabs a { padding: 10px 12px; font-size: 13px; }

  /* Main content */
  .source-panel { width: 100%; max-width: 100%; }
  main { padding: 16px 12px; }
  main h1 { font-size: 20px; }
  main h2 { font-size: 17px; padding: 6px 10px; }
  main h3 { font-size: 15px; }
  main p, main li, main td { font-size: 14px; line-height: 1.6; }

  /* SVG 圖 — 不要等比縮·改橫向滑 */
  .diagram-box { padding: 12px 8px; margin: 10px 0 20px; }
  .diagram-box h2 { font-size: 14px !important; padding: 0 4px !important; margin-bottom: 8px !important; }
  .diagram-box svg {
    min-width: 700px;
    max-height: none !important;
  }
  .diagram-box {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* FAB 按鈕縮小不擋內容 */
  .source-fab { right: 14px; bottom: 14px; padding: 10px 14px; font-size: 13px; }
  .msg-fab { right: 14px; bottom: 64px; padding: 10px 14px; font-size: 13px; }

  /* Table 手機橫向滑 */
  main table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  main td, main th { white-space: normal; min-width: 80px; }

  /* 空 blockquote 隱藏 */
  main blockquote:empty { display: none; }
}
