:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #243029;
  background: #f2f1ec;
}

* { box-sizing: border-box; }
body { margin: 0; }
.shell { max-width: 790px; margin: 0 auto; padding: 28px 18px 60px; }
.masthead { padding: 16px 4px 26px; }
.eyebrow { color: #596960; font-size: 0.79rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; }
h1 { margin: 8px 0; color: #1e4437; font-size: clamp(2rem, 7vw, 3.3rem); letter-spacing: 0.06em; }
h2 { margin-top: 0; font-size: 1.3rem; }
h3 { margin-top: 28px; font-size: 1.08rem; }
p { line-height: 1.55; }
.panel { margin-bottom: 18px; padding: 25px; border: 1px solid #dbe1d9; border-radius: 16px; background: #fff; box-shadow: 0 7px 20px #1b3d2c0d; }
label { display: block; margin: 18px 0 8px; font-weight: 600; }
textarea, select { width: 100%; padding: 11px 13px; border: 1px solid #aebbb1; border-radius: 8px; background: white; color: inherit; font: inherit; }
textarea { resize: vertical; }
textarea:focus, select:focus, button:focus-visible, a:focus-visible,
[tabindex="-1"]:focus-visible { outline: 3px solid #9cbda6; outline-offset: 2px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 14px; color: #627168; font-size: 0.9rem; }
button { padding: 11px 20px; border: 0; border-radius: 8px; background: #245c46; color: #fff; font: inherit; font-weight: 650; cursor: pointer; }
button:hover { background: #174a36; }
button:disabled { opacity: 0.55; cursor: wait; }
#feedback-button { margin-top: 18px; }
.answer { white-space: pre-wrap; font-size: 1.06rem; }
.note { padding: 10px 13px; border-left: 3px solid #9fb9a6; background: #f4f7f3; }
.sources { padding-left: 22px; }
.sources li { padding: 10px 0; }
.sources strong, .sources span { display: block; }
.sources blockquote { margin: 10px 0; padding: 6px 12px; border-left: 3px solid #b5c6b8; white-space: pre-wrap; }
.muted, footer { color: #596960; font-size: 0.9rem; }
footer { padding: 8px 4px; }
[hidden] { display: none !important; }
@media (max-width: 530px) {
  .panel { padding: 20px 16px; }
  .form-footer button { width: 100%; }
}

.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin-bottom: 0; }
.secondary-button { background: #e6eee9; color: #214638; }
.secondary-button:hover { background: #d6e4dc; }
.conversation-log { display: grid; gap: 12px; margin-top: 16px; }
.conversation-message { max-width: 88%; padding: 12px 14px; border-radius: 14px; }
.conversation-message strong { display: block; margin-bottom: 5px; font-size: 0.85rem; }
.conversation-message p { margin: 0; white-space: pre-wrap; }
.conversation-message.user { justify-self: end; background: #e7f0eb; }
.conversation-message.assistant { justify-self: start; background: #f5f4ef; border: 1px solid #e0e3dc; }
#conversation-meta { margin-bottom: 0; }
@media (max-width: 530px) {
  .dialog-heading { display: block; }
  .dialog-heading .secondary-button { width: 100%; margin-top: 10px; }
  .conversation-message { max-width: 96%; }
}

#memory-propose-button { margin-top: 18px; }
.memory-list { display: grid; gap: 12px; margin-top: 18px; }
.memory-card { padding: 14px; border: 1px solid #dbe1d9; border-radius: 12px; background: #f8faf7; }
.memory-card strong, .memory-card span { display: block; }
.memory-card p { margin: 8px 0; white-space: pre-wrap; }
.memory-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.memory-actions button { padding: 9px 14px; }
.memory-status-approved { color: #214638; font-weight: 700; }
.memory-status-rejected { color: #6e5146; font-weight: 700; }

.memory-footer { margin-top: 16px; }
.memory-delete-button { background: #f0e7e2; color: #5b3f35; }
.memory-delete-button:hover { background: #e5d7d0; }

.memory-selection-section { margin-top: 28px; padding-top: 8px; border-top: 1px solid #dbe1d9; }
.memory-selection-list { display: grid; gap: 10px; margin: 14px 0; }
.memory-selection-row { padding: 12px; border: 1px solid #dbe1d9; border-radius: 10px; background: #fbfcfa; }
.memory-selection-row label { margin: 0; display: flex; align-items: flex-start; gap: 10px; font-weight: 600; }
.memory-selection-row label + label { margin-top: 10px; font-weight: 500; }
.memory-selection-row input[type="checkbox"] { margin-top: 0.2em; flex: 0 0 auto; }
.memory-selection-row .memory-selection-summary { margin: 8px 0 0 26px; color: #596960; }
#memory-selection-button { margin-top: 4px; }
.memory-selection-result { display: grid; gap: 8px; margin-top: 12px; }
.memory-selection-decision { padding: 10px 12px; border-left: 3px solid #9fb9a6; background: #f4f7f3; }
.memory-selection-decision strong, .memory-selection-decision span { display: block; }
.memory-selection-blocked { border-left-color: #b99889; background: #faf4f1; }


.account-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.danger-button { background: #7b3e35; }
.danger-button:hover { background: #653128; }
.account-export {
  max-height: 320px;
  overflow: auto;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #dbe1d9;
  border-radius: 10px;
  background: #f7f8f5;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
}
.conversation-history { margin-top: 26px; padding-top: 8px; border-top: 1px solid #dbe1d9; }
.history-list { display: grid; gap: 10px; margin-top: 12px; }
.history-card { padding: 12px; border: 1px solid #dbe1d9; border-radius: 10px; background: #fbfcfa; }
.history-card strong, .history-card span { display: block; }
.history-card button { margin-top: 10px; padding: 8px 13px; }
@media (max-width: 530px) {
  .account-actions button { width: 100%; }
}
