/* MentalCure — calm, mobile-first. System fonts only; no external assets. */
:root {
  --bg: #f6f2ea;
  --surface: #fbf9f4;
  --text: #25302f;
  --muted: #5b6765;
  --accent: #1f5f5b;
  --accent-text: #ffffff;
  --accent-soft: #e0ece9;
  --user-bg: #e6eeeb;
  --border: #d9d1c1;
  --danger: #8a2f2f;
  --danger-soft: #f3e1dd;
  --ok-soft: #e0eee3;
  --focus: #0b57d0;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141918;
    --surface: #1b2120;
    --text: #e5e9e6;
    --muted: #a3afac;
    --accent: #7cc4bc;
    --accent-text: #0f1a19;
    --accent-soft: #223532;
    --user-bg: #212b29;
    --border: #2f3a38;
    --danger: #e59a92;
    --danger-soft: #3a2422;
    --ok-soft: #21352a;
    --focus: #8ab4f8;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
main { padding: 1rem 1.1rem 3rem; }
a { color: var(--accent); text-underline-offset: 0.15em; }
h1 { font-size: 1.7rem; line-height: 1.25; margin: 0.4em 0 0.6em; font-weight: 600; }
h2 { font-size: 1.25rem; margin: 2em 0 0.5em; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 1.4em 0 0.4em; }
p, ul, ol, dl { margin: 0 0 1em; }
.lede { font-size: 1.12rem; }
.hint { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.center { text-align: center; }
.sr-only, .skip:not(:focus) {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip:focus { position: fixed; top: 0.5rem; left: 0.5rem; background: var(--surface); padding: 0.5rem 0.8rem; z-index: 10; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

header.site, footer.site {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  max-width: 720px; margin: 0 auto; padding: 0.9rem 1.1rem;
}
header.site .brand { font-weight: 650; letter-spacing: 0.01em; text-decoration: none; color: var(--text); font-size: 1.1rem; }
header.site nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: 0.95rem; }
footer.site { font-size: 0.9rem; color: var(--muted); }
form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }

.prose, .app { max-width: 720px; margin: 0 auto; }
.prose.narrow { max-width: 460px; }
.prose.wide, body.wide .prose { max-width: 1000px; }
body.wide header.site { max-width: 1000px; }

/* controls */
button, .button, summary.button-like {
  font: inherit; cursor: pointer; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); padding: 0.55em 1.1em; text-decoration: none;
  display: inline-block; min-height: 44px; line-height: 1.4;
}
button:hover, .button:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.55; cursor: default; }
button.ghost, .button.ghost, summary.ghost { background: transparent; color: var(--accent); }
button.small, summary.small { font-size: 0.9rem; padding: 0.35em 0.8em; min-height: 38px; }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--bg); }
button.linklike { background: none; border: none; color: var(--accent); padding: 0; min-height: 0; text-decoration: underline; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6em 0.75em; min-height: 44px;
}
textarea { resize: vertical; }
input.short { width: 9em; }
input.mono, pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
label { display: block; font-weight: 500; }
label .hint { display: inline; margin-left: 0.3em; }
label > input, label > select, label > textarea { margin-top: 0.3em; }
.stack > * + * { margin-top: 1rem; }
.stack { margin-bottom: 1.5rem; }
label.check { display: flex; gap: 0.7rem; align-items: flex-start; font-weight: 400; }
label.check input { width: 1.3rem; height: 1.3rem; margin-top: 0.25rem; flex: none; }
fieldset.consents { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
fieldset.consents legend { font-weight: 600; padding: 0 0.4rem; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cta { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 2rem; }

.flash, .alert, .banner {
  border-radius: var(--radius); padding: 0.8rem 1rem; margin: 0 auto 1.2rem; max-width: 720px;
  background: var(--accent-soft); border: 1px solid var(--border);
}
.alert { background: var(--danger-soft); }
.alert.ok { background: var(--ok-soft); }
.alert ul { margin: 0; padding-left: 1.2rem; }
form.danger, .danger-zone { border: 1px solid var(--danger); border-radius: var(--radius); padding: 1rem; }
form.danger h3 { margin-top: 0; color: var(--danger); }
pre.resources {
  white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; font-family: inherit; font-size: 0.98rem;
}
dl { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: 0.3rem 1rem; }
dt { color: var(--muted); font-size: 0.92rem; }
dd { margin: 0; overflow-wrap: anywhere; }
.prewrap, .plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.2rem 1rem 0.6rem; margin-bottom: 1rem; }
.tag { font-size: 0.75rem; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 0.1em 0.6em; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
table.small { font-size: 0.85rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
details summary { cursor: pointer; }

/* ---- chat ---- */
body.chatpage main { padding-bottom: 1rem; }
.app { display: block; }
#thread { padding-bottom: 0.5rem; }
.msg { margin: 1.4rem 0; overflow-wrap: anywhere; }
.msg.user {
  background: var(--user-bg); border-radius: var(--radius); padding: 0.7rem 1rem;
  white-space: pre-wrap; margin-left: 12%;
}
.msg.assistant { padding: 0 0.1rem; }          /* reads like a letter: no bubble */
.msg.assistant p { margin: 0 0 0.9em; }
.msg.assistant.notice { border-left: 3px solid var(--accent); padding-left: 1rem; }
.msg .tag-line { font-size: 0.82rem; color: var(--muted); margin-top: -0.3rem; }
.msg.note { color: var(--muted); font-size: 0.95rem; border-left: 3px solid var(--border); padding-left: 0.9rem; white-space: pre-wrap; }
.status { color: var(--muted); font-size: 0.92rem; margin: 0 0 0.4rem; min-height: 1.4em; }
.status.error { color: var(--danger); }
.form-status { color: var(--muted); font-size: 0.92rem; }
.form-status.bad { color: var(--danger); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0.6rem 0; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; bottom: 110%; left: 0; z-index: 5; display: flex; flex-direction: column; gap: 0.3rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.4rem; min-width: 11rem;
}
.composer {
  position: sticky; bottom: 0; background: var(--bg); padding: 0.5rem 0 0.8rem;
  border-top: 1px solid var(--border);
}
.composer textarea { min-height: 3.2rem; max-height: 40vh; }
.composer-row { display: flex; justify-content: space-between; gap: 0.7rem; align-items: center; margin-top: 0.5rem; }
#voice-controls { display: flex; gap: 0.5rem; align-items: center; flex: 1 1 auto; min-width: 0; }
body.voice-active #send { display: none; }
#voice-live { color: var(--muted); font-style: italic; white-space: pre-wrap; min-height: 0; }
.letter { max-width: 720px; margin: 0 auto; }
.banner blockquote { margin: 0.5rem 0; color: var(--muted); border-left: 3px solid var(--border); padding-left: 0.8rem; white-space: pre-wrap; }
dialog {
  width: min(680px, 94vw); max-height: 88vh; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-head h2 { margin: 0; }
.f-section { margin: 1rem 0; }
.f-section h3 { margin: 0 0 0.3rem; text-transform: capitalize; }
.f-section ul { margin: 0.2rem 0 0.6rem; padding-left: 1.2rem; }
.f-conf { color: var(--muted); font-size: 0.88rem; }

@media (max-width: 520px) {
  body { font-size: 16.5px; }
  .msg.user { margin-left: 4%; }
  dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .status.working::after { content: ""; display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.4em;
    border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
}
