* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  background: #f6f4f1;
  color: #1a1a1a;
}
header h1 { margin: 0; font-size: 1.4rem; }
.sub { margin: 0.25rem 0; color: #555; font-size: 0.9rem; }
.status { font-size: 0.85rem; color: #333; }
.log {
  min-height: 50vh;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  overflow-y: auto;
}
.msg { margin-bottom: 1rem; white-space: pre-wrap; line-height: 1.45; }
.msg.user { color: #0b3d91; }
.msg.assistant { color: #222; }
.msg.system { color: #666; font-size: 0.9rem; }
.composer { display: flex; gap: 0.5rem; }
.composer textarea { flex: 1; padding: 0.6rem; font: inherit; border-radius: 6px; border: 1px solid #ccc; }
.composer button, .end-bar button {
  padding: 0.5rem 0.75rem;
  font: inherit;
  border-radius: 6px;
  border: 1px solid #888;
  background: #fff;
  cursor: pointer;
}
.end-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; align-items: center; }
.copy-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  margin-bottom: 0.25rem;
}
.copy-bar.hidden { display: none; }
.copy-bar button {
  padding: 0.55rem 0.85rem;
  font: inherit;
  border-radius: 6px;
  border: 1px solid #0b3d91;
  background: #eef4fc;
  color: #0b3d91;
  cursor: pointer;
}
.copy-toast {
  font-size: 0.85rem;
  color: #0b5d2a;
}
.copy-toast.hidden { display: none; }
.copy-toast.err { color: #9b1c1c; }
.save-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.save-overlay.hidden { display: none; }
.save-panel {
  background: #fff;
  border-radius: 10px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
.save-panel h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.save-lead { margin: 0 0 1rem; color: #444; font-size: 0.9rem; line-height: 1.4; }
.save-summary {
  background: #f8f7f5;
  border: 1px solid #e0ddd8;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  white-space: pre-wrap;
  margin: 0 0 1rem;
  max-height: 12rem;
  overflow-y: auto;
}
.save-facts { margin-bottom: 1rem; }
.save-section { margin-bottom: 0.75rem; }
.save-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}
.save-fact {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.35rem 0;
  font-size: 0.95rem;
  line-height: 1.4;
}
.save-fact input { margin-top: 0.25rem; flex-shrink: 0; }
.save-fact q { font-style: normal; }
.save-tools { font-size: 0.85rem; color: #555; margin: 0 0 1rem; }
.save-tools.hidden { display: none; }
.save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.save-actions-spacer { flex: 1; }
.save-confirm {
  background: #0b3d91;
  color: #fff;
  border-color: #0b3d91;
}
.link-btn {
  margin-top: 0.5rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; }

/* Inline save panel (in chat log — works without modal HTML) */
.save-flow { padding: 0 !important; }
.save-panel-inline {
  border: 2px solid #0b3d91;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: #f8fafc;
  margin: 0.25rem 0;
}
.save-panel-inline h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.save-lead { margin: 0 0 0.75rem; color: #444; font-size: 0.9rem; line-height: 1.4; }
.save-summary {
  background: #fff;
  border: 1px solid #e0ddd8;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  white-space: pre-wrap;
  margin: 0 0 1rem;
  max-height: 10rem;
  overflow-y: auto;
}
.save-section { margin-bottom: 0.75rem; }
.save-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}
.save-fact {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.35rem 0;
  font-size: 0.95rem;
  line-height: 1.4;
  cursor: pointer;
}
.save-fact input { margin-top: 0.25rem; flex-shrink: 0; }
.save-quote { font-style: italic; }
.save-tools { font-size: 0.85rem; color: #555; margin: 0 0 1rem; }
.save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}
.save-confirm {
  background: #0b3d91;
  color: #fff;
  border-color: #0b3d91;
}
