/**
 * Gestaltung der gesamten Anwendung.
 *
 * Haltung: ruhig, viel Weißraum, wenig Farbe. Die Anwendung wird von einer
 * Psychotherapeutin zwischen zwei Terminen bedient und von Patient*innen in einer
 * Situation geöffnet, in der es um Geld und Gesundheitsdaten geht. Beides verträgt
 * keine laute Oberfläche.
 *
 * Mobil zuerst: Patient*innen öffnen den Link fast immer am Handy.
 *
 * Keine externen Schriften. Google Fonts würde bei jedem Seitenaufruf die
 * IP-Adresse an Google übertragen — bei Gesundheitsdaten undenkbar und in
 * Deutschland bereits gerichtlich abgeurteilt.
 */

:root {
    --ink: #2c2a26;
    --ink-soft: #57534c;
    --ink-faint: #8a857c;

    --paper: #fbfaf8;
    --surface: #ffffff;
    --line: #e3e2de;
    --line-strong: #cfcdc7;

    --accent: #3d5a52;
    --accent-dark: #2e453f;
    --accent-wash: #eef2f0;

    --alert: #a4442f;
    --alert-wash: #faf0ec;
    --good: #3d5a52;
    --wait: #8a6d3b;
    --wait-wash: #fbf6ec;

    --radius: 6px;
    --radius-sm: 4px;

    --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --mono: ui-monospace, Menlo, Consolas, 'Liberation Mono', monospace;

    --shadow: 0 1px 2px rgba(44, 42, 38, 0.04), 0 4px 16px rgba(44, 42, 38, 0.05);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 400;
    line-height: 1.25;
    color: var(--ink);
    margin: 0 0 0.5em 0;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; font-family: var(--sans); font-weight: 600; }

p { margin: 0 0 1em 0; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover { color: var(--accent-dark); }

/* Sichtbarer Fokus ist Bedienbarkeit, nicht Dekoration — er darf nie wegoptimiert werden. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 0.875rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Gerüst ----------------------------------------------------------- */

.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.masthead {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.masthead__inner {
    max-width: 62rem;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 60px;
    flex-wrap: wrap;
}

.masthead__brand {
    font-family: var(--serif);
    font-size: 1.1rem;
    color: var(--ink);
    text-decoration: none;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.masthead__practice {
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
}

.nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav a {
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.925rem;
}

.nav a:hover { background: var(--accent-wash); color: var(--accent-dark); }
.nav a[aria-current='page'] { background: var(--accent-wash); color: var(--accent-dark); font-weight: 600; }

.main {
    flex: 1;
    max-width: 62rem;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

.main--narrow { max-width: 34rem; }
.main--reading { max-width: 46rem; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-head p { margin: 0; }

.footer {
    border-top: 1px solid var(--line);
    padding: 1.25rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--ink-faint);
}

/* --- Karten ----------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card + .card { margin-top: 1.25rem; }
.card__title { margin-bottom: 1rem; }

.card__note {
    font-size: 0.875rem;
    color: var(--ink-soft);
    margin: -0.5rem 0 1.25rem 0;
}

/* --- Formulare -------------------------------------------------------- */

.field { margin-bottom: 1.15rem; }
.field:last-child { margin-bottom: 0; }

.field label,
.field > .label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--ink);
}

.field__hint {
    font-size: 0.8125rem;
    color: var(--ink-soft);
    margin: 0.35rem 0 0 0;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='url'],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
}

/* 16px verhindert, dass iOS beim Fokussieren automatisch hineinzoomt. */
@media (max-width: 480px) {
    input, select, textarea { font-size: 16px; }
}

textarea { min-height: 7rem; resize: vertical; }

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    outline: 2px solid var(--accent-wash);
    outline-offset: 0;
}

input[aria-invalid='true'] { border-color: var(--alert); }

.field-row {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
    .field-row--two { grid-template-columns: 1fr 1fr; }
    .field-row--three { grid-template-columns: 1fr 1fr 1fr; }
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.check input { margin-top: 0.25rem; flex-shrink: 0; }
.check label { font-weight: 400; margin: 0; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

/* --- Schaltflächen ---------------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s ease;
}

.button:hover { background: var(--accent-dark); color: #fff; }

.button:disabled,
.button[aria-disabled='true'] {
    opacity: 0.5;
    cursor: not-allowed;
}

.button--quiet {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line-strong);
}

.button--quiet:hover { background: var(--paper); color: var(--ink); }

.button--danger { background: var(--alert); }
.button--danger:hover { background: #8b3927; }

.button--small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.button--wide { width: 100%; }

/* --- Meldungen -------------------------------------------------------- */

.notice {
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.25rem;
    font-size: 0.925rem;
    border-left: 3px solid;
}

.notice p { margin-bottom: 0.5rem; }
.notice p:last-child { margin-bottom: 0; }

.notice--info { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-dark); }
.notice--success { background: var(--accent-wash); border-color: var(--good); color: var(--accent-dark); }
.notice--warning { background: var(--wait-wash); border-color: var(--wait); color: #6b5429; }
.notice--error { background: var(--alert-wash); border-color: var(--alert); color: #7d3423; }

/* --- Zustandskennzeichen ---------------------------------------------- */

.tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.tag--good { background: var(--accent-wash); color: var(--accent-dark); }
.tag--wait { background: var(--wait-wash); color: #6b5429; }
.tag--muted { background: #f0efec; color: var(--ink-soft); }
.tag--alert { background: var(--alert-wash); color: #7d3423; }

/* --- Listen und Tabellen ---------------------------------------------- */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.925rem;
}

table.list th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    font-weight: 600;
    padding: 0 0.75rem 0.6rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.list td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

table.list tr:last-child td { border-bottom: none; }
table.list tbody tr:hover { background: var(--paper); }

.empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--ink-soft);
}

.empty h3 { color: var(--ink); }

/* --- Beschreibungslisten ---------------------------------------------- */

.facts {
    display: grid;
    gap: 0.75rem 1.5rem;
    grid-template-columns: 1fr;
    margin: 0;
}

@media (min-width: 34rem) {
    .facts { grid-template-columns: auto 1fr; }
}

.facts dt {
    font-size: 0.8125rem;
    color: var(--ink-faint);
    font-weight: 600;
}

.facts dd { margin: 0; }

/* --- Fortschritt ------------------------------------------------------ */

.progress {
    height: 5px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.75rem 0 0.5rem;
}

.progress__bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.25s ease;
}

/* --- Öffentliche Abholseite ------------------------------------------- */

.retrieve {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1.25rem 3rem;
}

.retrieve__card {
    width: 100%;
    max-width: 30rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.retrieve__practice {
    text-align: center;
    font-family: var(--serif);
    font-size: 1.05rem;
    color: var(--ink-soft);
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--line);
}

.retrieve__files {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

.retrieve__files li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
}

.retrieve__files li:last-child { border-bottom: none; }

.file-name {
    font-size: 0.95rem;
    word-break: break-word;
}

/* --- Wiederherstellungsphrase ----------------------------------------- */

.phrase {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 1.25rem 0;
    padding: 1.25rem;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
}

@media (min-width: 34rem) {
    .phrase { grid-template-columns: repeat(4, 1fr); }
}

.phrase__word {
    font-family: var(--mono);
    font-size: 0.9rem;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.phrase__index {
    color: var(--ink-faint);
    font-size: 0.75rem;
    min-width: 1.4rem;
    text-align: right;
}

/* --- Installer -------------------------------------------------------- */

.steps {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
}

.steps li {
    font-size: 0.75rem;
    color: var(--ink-faint);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: #f0efec;
}

.steps li[aria-current='step'] { background: var(--accent); color: #fff; font-weight: 600; }
.steps li.is-done { background: var(--accent-wash); color: var(--accent-dark); }

.checks { list-style: none; margin: 0; padding: 0; }

.checks li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.925rem;
}

.checks li:last-child { border-bottom: none; }

.checks__mark {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    font-weight: 700;
}

.checks__mark--ok { color: var(--good); }
.checks__mark--warn { color: var(--wait); }
.checks__mark--fail { color: var(--alert); }

.checks__detail { color: var(--ink-soft); font-size: 0.8125rem; }

/* --- Wortmarke und Symbole -------------------------------------------- */

.masthead__brand,
.brand__title {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.masthead__brand { align-items: baseline; }
.masthead__brand > svg { align-self: center; }

.brand__lock { color: var(--accent); flex-shrink: 0; }
.brand__title { justify-content: center; }
.brand__title .brand__lock { width: 20px; height: 20px; }

/* --- Schaltflächenreihen ---------------------------------------------- */

/* Verweise und Formulare in einer Reihe sind unterschiedlich hoch, wenn man sie
   einfach nebeneinanderstellt — das Formular ist ein Block, der Verweis nicht. */
.button-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.button-row form { display: flex; margin: 0; }

.button--danger-text { color: var(--alert); border-color: var(--line-strong); }
.button--danger-text:hover { background: var(--alert-wash); color: #7d3423; border-color: var(--alert); }
.button--danger-text svg { flex-shrink: 0; }

/* --- Aktionen in Tabellenzeilen --------------------------------------- */

.row-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.row-actions form { display: flex; margin: 0; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-faint);
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease;
}

.icon-button:hover {
    color: var(--alert);
    background: var(--alert-wash);
    border-color: var(--alert-wash);
}

/* --- Farbvorschau in den Einstellungen -------------------------------- */

.colour-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.colour-field input[type='text'] { width: 9rem; font-family: var(--mono); }

.colour-field input[type='color'] {
    width: 2.75rem;
    height: 2.75rem;
    padding: 2px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.colour-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--ink-soft);
}

.colour-swatch {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* --- Signatur-Editor -------------------------------------------------- */

.editor__tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.editor__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.5rem;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.editor__toolbar button {
    padding: 0.3rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.editor__toolbar button:hover {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}

.editor__separator {
    width: 1px;
    background: var(--line-strong);
    margin: 0.15rem 0.3rem;
}

.editor__surface {
    min-height: 12rem;
    padding: 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--surface);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.editor__surface:focus {
    outline: 2px solid var(--accent-wash);
    border-color: var(--accent);
}

.editor__surface img { max-width: 100%; height: auto; }
.editor__surface table { border-collapse: collapse; }

.editor__source {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    min-height: 12rem;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 0.75rem;
}

.media-grid__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    text-align: center;
    word-break: break-word;
}

.media-grid__item:hover { border-color: var(--accent); background: var(--accent-wash); }
.media-grid__item img { max-width: 100%; max-height: 3rem; object-fit: contain; }

/* --- Druckansicht ----------------------------------------------------- */

@media print {
    .masthead, .footer, .form-actions, .no-print { display: none !important; }
    body { background: #fff; }
    .card { border: none; box-shadow: none; padding: 0; }
    .phrase { border: 1px solid #000; }
}
