* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

h1 { font-size: 18px; margin: 0; }

.badge {
  font-size: 12px;
  font-weight: normal;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 1px 8px;
  vertical-align: middle;
}

.toolbar { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.toolbar input[type="date"] { padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; }

button {
  font: inherit;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
button.primary { background: #2563eb; color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.secondary { background: #fff; color: #374151; border-color: #d1d5db; }
button.secondary:hover { background: #f9fafb; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:disabled:hover { background: #fff; }

.step2-note {
  margin: 12px 24px 0;
  padding: 8px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
}
.step2-note code { background: #dbeafe; padding: 0 4px; border-radius: 3px; }
.step2-note a { color: #1d4ed8; font-weight: 600; }

#rule-warning {
  margin: 0 24px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #991b1b;
  font-size: 13px;
  line-height: 1.7;
}
#rule-warning strong { display: block; margin-bottom: 4px; }

main {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  min-height: 0;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #f3f4f6;
}
.pane-head button { margin-left: auto; padding: 3px 10px; font-size: 12px; }

#counts { font-weight: normal; }
#counts .c-replace { color: #dc2626; }
#counts .c-warn { color: #b45309; }
#counts .c-info { color: #047857; }

textarea, .result {
  flex: 1;
  padding: 16px;
  font-size: 16px;
  line-height: 2;
  overflow-y: auto;
}
textarea { border: none; outline: none; resize: none; font-family: inherit; }
.result { white-space: pre-wrap; word-break: break-word; }
.placeholder { color: #9ca3af; font-size: 14px; }

mark.ann { cursor: pointer; border-radius: 3px; padding: 1px 0; }
mark.ann.replace { background: #fee2e2; border-bottom: 2px solid #dc2626; }
mark.ann.warn { background: #fef3c7; border-bottom: 2px solid #d97706; }
mark.ann.info { background: #d1fae5; border-bottom: 2px solid #059669; }
/* AI 建議：較不確定，以紫色虛線區別於確定性規則 */
mark.ann.llm { background: #ede9fe; border-bottom: 2px dashed #7c3aed; }

#popover {
  position: absolute;
  z-index: 10;
  max-width: 320px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.popover-actions { display: flex; gap: 8px; margin-top: 10px; }
.popover-actions button { padding: 4px 14px; font-size: 13px; }
