/* Patient app: tokens + shared components. Page CSS may only add .an-* / .do-* classes. */
:root {
  --bg: #f1f5fa; --card: #fff; --ink: #12294d; --text: #2b3b52; --muted: #61728a; --line: #dbe3ee;
  --blue: #1b6ee6; --blue-dark: #1558bd; --blue-soft: #e8f1fd; --blue-tint: #f3f8ff;
  --green-bg: #eef7f0; --green-line: #d3e8d9; --green-ink: #2b6a42;
  --rec: #d92d20; --danger: #b42318; --warn-bg: #fff6e5; --warn-ink: #9a5b00; --dark: #1f3a5f;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(18,41,77,.04), 0 8px 24px rgba(18,41,77,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
#app:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -48px; background: var(--dark); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 8px; }
.grow { flex: 1; min-width: 0; }

/* ---- header + stepper ---- */
.app-header { background: var(--card); border-bottom: 1px solid var(--line); }
.app-header-in { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--blue); box-shadow: inset 0 0 0 5px var(--blue), inset 0 0 0 8px #fff; }
.stepper { flex: 1; min-width: 0; }
.stepper ol { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0; padding: 0; list-style: none; }
.step { display: flex; align-items: center; gap: 9px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.step-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #e9eef5; color: var(--muted); font-size: 13px; font-weight: 600; flex: none; }
.step.is-active { color: var(--blue); }
.step.is-active .step-num, .step.is-done .step-num { background: var(--blue); color: #fff; }
.step.is-done { color: var(--ink); }
.step-bar { flex: 0 1 56px; min-width: 14px; height: 2px; background: var(--line); border-radius: 2px; }
.step-bar.is-done { background: var(--blue); }

/* ---- layout ---- */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 24px 56px; display: grid; gap: 16px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.layout > aside { display: grid; gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 24px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.title { font-size: 28px; line-height: 1.25; font-weight: 500; color: var(--ink); }
.subtitle { color: var(--blue); font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.banner-wrap { max-width: 1180px; margin: 12px auto 0; padding: 0 24px; }
.error-card { display: grid; gap: 12px; justify-items: start; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  font-weight: 500; line-height: 1.2; text-align: center; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--blue-tint); border-color: #c4d3e8; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #162c49; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--blue-tint); color: var(--ink); }
.btn-danger { background: var(--rec); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b42318; }
.btn-pill { border-radius: 999px; padding-left: 24px; padding-right: 24px; }
.btn-soft { background: var(--blue-soft); color: var(--blue-dark); }
.btn-soft:hover:not(:disabled) { background: #d8e8fb; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--blue); font-weight: 500; cursor: pointer; border-radius: 6px; }
.link-btn:hover { text-decoration: underline; }
.footer-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* ---- choices + forms ---- */
.choice-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px;
  padding: 12px 16px; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; color: var(--ink); font-weight: 500;
}
.choice:hover { border-color: #b9cce6; background: var(--blue-tint); }
.choice.is-selected { border-color: var(--blue); background: var(--blue-tint); color: var(--blue-dark); }
.choice.is-selected::after { content: ""; flex: none; width: 7px; height: 12px; margin: 0 4px 3px 0; border: solid var(--blue); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.field { display: grid; gap: 6px; }
.label { font-weight: 500; color: var(--ink); font-size: 14px; }
.input, .select, .textarea {
  width: 100%; padding: 11px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); min-height: 44px;
}
.input::placeholder, .textarea::placeholder { color: #8a99ad; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); outline: 2px solid var(--blue-soft); outline-offset: 0; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--text); }
.checkbox input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); flex: none; }

/* ---- notices, panels, badges ---- */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-dark); }
.notice > svg { flex: none; margin-top: 2px; }
.notice-info { background: var(--blue-soft); color: var(--blue-dark); }
.notice-warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice-danger { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }
.notice-neutral { background: #f3f5f8; color: var(--muted); }
.notice-inline { font-size: 13px; color: var(--danger); }
.panel-green { background: var(--green-bg); border: 1px solid var(--green-line); border-radius: var(--radius); padding: 18px; color: var(--green-ink); }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.panel-green .item-row { border-color: var(--green-line); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue-dark); white-space: nowrap; }
.badge-success { background: #dff1e4; color: var(--green-ink); }
.badge-warn { background: #ffecc7; color: var(--warn-ink); }

/* ---- progress ---- */
.progress { display: flex; gap: 6px; }
.progress .seg { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.progress .seg.done { background: var(--blue); }
.progress .seg.current { background: var(--blue-dark); }

/* ---- icon dots, quote, kv ---- */
.icon-dot { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-green { background: #dff1e4; color: var(--green-ink); }
.tone-purple { background: #efe9fd; color: #6b44d6; }
.tone-orange { background: #ffecd2; color: #c26a00; }
.tone-pink { background: #fde6f0; color: #c2307a; }
.quote { color: var(--blue-dark); font-size: 17px; line-height: 1.6; }
.quote::before { content: "«\00a0"; }
.quote::after { content: "\00a0»"; }
.kv { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* ---- spinner ---- */
.spinner { display: inline-block; width: 18px; height: 18px; flex: none; border: 2px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(241,245,250,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto; }
.modal { position: relative; width: min(480px, 100%); background: #fff; border-radius: 16px; padding: 28px 24px 24px; box-shadow: 0 20px 60px rgba(18,41,77,.2); text-align: center; display: grid; gap: 12px; justify-items: center; }
.modal:focus { outline: none; }
.modal-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; }
.modal-title { font-size: 21px; font-weight: 500; color: var(--ink); }
.modal-body { width: 100%; display: grid; gap: 12px; text-align: center; }
.modal-body ul { text-align: left; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; width: 100%; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 50%; color: var(--muted); }
.modal-x:hover { background: var(--blue-tint); color: var(--ink); }

/* ---- recorder ---- */
.rec { --level: 0; display: grid; gap: 10px; }
.rec-large { justify-items: center; text-align: center; gap: 12px; }
.rec-stage { position: relative; width: 132px; height: 132px; display: grid; place-items: center; }
.rec-ring { position: absolute; inset: 0; border-radius: 50%; background: rgba(217,45,32,.16); opacity: 0; transform: scale(calc(.82 + var(--level) * .5)); transition: transform .08s linear, opacity .2s; }
.rec[data-state="recording"] .rec-ring { opacity: 1; }
.rec-mic { position: relative; width: 104px; height: 104px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); box-shadow: 0 0 0 8px var(--blue-tint); transition: background .2s, color .2s; }
.rec-mic:hover:not(:disabled) { background: #d8e8fb; }
.rec[data-state="recording"] .rec-mic { background: var(--rec); color: #fff; box-shadow: none; }
.rec-timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 18px; letter-spacing: .02em; }
.rec-status { min-height: 1.4em; font-weight: 500; color: var(--muted); }
.rec-status.is-rec { color: var(--rec); }
.rec-error { color: var(--danger); font-size: 14px; max-width: 420px; }
.rec-error[hidden] { display: none; }
.rec-large .rec-mic, .rec-compact .rec-mic { cursor: pointer; }
.rec-compact .rec-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rec-compact .rec-col { display: grid; gap: 2px; min-width: 0; }
.rec-compact .rec-status:empty { display: none; }
.rec-compact .rec-timer { font-size: 14px; }
.rec-compact .rec-cta { min-height: 40px; }
.rec-compact[data-state="recording"] .rec-cta { padding-left: 18px; padding-right: 18px; }

/* ---- listen ---- */
.listen { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; }
.listen-icon { display: inline-flex; }
.listen-btn.is-playing { background: var(--blue); color: #fff; }

/* ---- termine ---- */
.termine { max-width: 760px; }
.termine-card { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 40px 28px; }
.termine-check { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: #dff1e4; color: var(--green-ink); }
.termine-text { color: var(--text); max-width: 560px; }
.termine-details > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; color: var(--ink); list-style: none; border-radius: 8px; }
.termine-details > summary::-webkit-details-marker { display: none; }
.termine-details[open] > summary svg { transform: rotate(180deg); }
.termine-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); font-weight: 600; margin: 20px 0 10px; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .app-header-in { padding: 10px 16px; gap: 12px; }
}
@media (max-width: 640px) {
  .page { padding: 16px 16px 40px; }
  .banner-wrap { padding: 0 16px; }
  .card-pad { padding: 18px; }
  .title { font-size: 23px; }
  .choice-row { grid-template-columns: minmax(0, 1fr); }
  .brand span:last-child { display: none; }
  .stepper ol { gap: 8px; justify-content: flex-end; }
  .step:not(.is-active) .step-label { display: none; }
  .step-bar { flex-basis: 16px; min-width: 8px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .footer-actions .btn { flex: 1 1 auto; }
  .termine-card { padding: 28px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner, .spin { animation-duration: 2s; }
  .rec-ring { transition: none; }
}
