/* pagedrop chat iframe. Deliberately self-contained: the iframe renders on a
   different origin from the uploaded page, so nothing here inherits or leaks
   styling across that boundary. Fonts are system stacks rather than a CDN so
   the CSP can stay tight. */

:root {
  --paper: #f7f4ee;
  --ink: #1a1a18;
  --muted: #6b6862;
  --rule: #e2ddd3;
  --accent: #2f4858;
  --wine: #7b2d3b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Hiragino Sans",
    "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ── header ─────────────────────────────────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  flex: 0 0 auto;
}

.brand {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: #ece7dd;
  color: var(--ink);
}

/* ── panels ─────────────────────────────────────────────────────── */

.panel {
  margin: auto;
  padding: 24px;
  text-align: center;
  max-width: 34ch;
}

.panel-title {
  font-weight: 600;
  margin: 0 0 8px;
}

.panel-body {
  color: var(--muted);
  margin: 0 0 16px;
}

.btn {
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  padding: 8px 16px;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.error {
  color: var(--wine);
  margin: 8px 0 0;
  font-size: 14px;
}

/* ── chat ───────────────────────────────────────────────────────── */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.notice {
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12.5px;
  border-bottom: 1px solid var(--rule);
}

.messages {
  list-style: none;
  margin: 0;
  padding: 14px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.msg {
  margin: 0 0 14px;
}

.msg-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-user .msg-body {
  background: #ece7dd;
  padding: 8px 12px;
  border-radius: var(--radius);
  display: inline-block;
  max-width: 90%;
}

.msg-status {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.sources-title {
  margin: 10px 0 2px;
  font-size: 13px;
  color: var(--muted);
}

.sources {
  margin: 0;
  padding-left: 1.2em;
  font-size: 13px;
}

.sources a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.queries {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.chip {
  background: #ece7dd;
  border-radius: 999px;
  padding: 1px 9px;
}

/* ── composer ───────────────────────────────────────────────────── */

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--rule);
  flex: 0 0 auto;
}

.composer textarea {
  flex: 1 1 auto;
  resize: none;
  font: inherit;
  color: inherit;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
  max-height: 160px;
}

.composer textarea:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
