/* The status and the close share the dialog's top row. */
#akashic-health-records-patient-portal-root .ahr-task-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 28px;
}

/* Two facts to a row, as the task deck lays them out; the facts themselves are shared. */
#akashic-health-records-patient-portal-root .ahr-task-facts {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

/* The two outcomes, side by side at the foot of the task. */
#akashic-health-records-patient-portal-root .ahr-task-outcomes {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

#akashic-health-records-patient-portal-root .ahr-task-progress > .ak-progress {
    flex: 1;
}

#akashic-health-records-patient-portal-root .ahr-referral-head {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

#akashic-health-records-patient-portal-root .ahr-referral-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#akashic-health-records-patient-portal-root .ahr-referral-name b,
#akashic-health-records-patient-portal-root .ahr-referral-person b {
    font-size: 15px;
    font-weight: 500;
    color: var(--ink-strong);
}

#akashic-health-records-patient-portal-root .ahr-referral-name span {
    margin-top: 1px;
    font-size: 12.5px;
    color: var(--ink-muted);
}

#akashic-health-records-patient-portal-root .ahr-referral-person {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

#akashic-health-records-patient-portal-root .ahr-referral-meta {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--ink-strong);
}

#akashic-health-records-patient-portal-root .ahr-referral-label {
    width: 56px;
    flex: none;
    padding-top: 2px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: .04em;
}

#akashic-health-records-patient-portal-root .ahr-referral-tel {
    color: var(--primary);
}

#akashic-health-records-patient-portal-root .ahr-referral-note {
    margin: 8px 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--ink-muted);
}

#akashic-health-records-patient-portal-root .ahr-referral-note--quiet {
    color: var(--faint);
}

#akashic-health-records-patient-portal-root .ahr-referral-pending {
    display: grid;
    gap: 3px;
    margin-top: 10px;
    padding: 12px;
    background: var(--sunken);
}

#akashic-health-records-patient-portal-root .ahr-referral-pending b {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-strong);
}

#akashic-health-records-patient-portal-root .ahr-referral-pending span {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--ink-muted);
}

#akashic-health-records-patient-portal-root .ahr-referral-invite {
    display: grid;
    gap: 6px;
    margin: 8px 0;
    padding: 10px;
    background: var(--sunken);
}

#akashic-health-records-patient-portal-root .ahr-referral-invite .ahr-referral-label {
    width: auto;
}

#akashic-health-records-patient-portal-root .ahr-referral-invite ul {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#akashic-health-records-patient-portal-root .ahr-referral-invite li {
    position: relative;
    padding-left: 14px;
    font-size: 13px;
    color: var(--ink-strong);
}

#akashic-health-records-patient-portal-root .ahr-referral-invite li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 7px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
}

#akashic-health-records-patient-portal-root .ahr-referral-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

#akashic-health-records-patient-portal-root .ahr-referral-dialog {
    width: 100%;
    max-width: min(42rem, calc(100% - 2rem));
}

/* THE PATIENT'S TASK OVERLAY, drawn from the task deck (patient-portal.html #s-task-modal): a small
   overlay 14px in from a phone's edges, 12px inside, and 12px between its parts. */
#akashic-health-records-patient-portal-root .patient-task-dialog {
    width: calc(100% - 28px);
    max-width: 500px;
    padding: 12px;
}

#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-body {
    display: grid;
    gap: 12px;
    padding: 0;
}

#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-body > *,
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-heading > *,
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-doit > * {
    margin: 0;
}

#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-heading {
    display: grid;
    gap: 12px;
}

/* The status sits 8px above the title, the rest 12px apart. */
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-status-row + .ahr-task-heading,
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-heading > .ahr-task-status-row + * {
    margin-top: -4px;
}

#akashic-health-records-patient-portal-root .ahr-task-doit {
    display: grid;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

/* The action row sits 8px further down than the body's 12px rhythm, as the deck's action rows do. */
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-body > .ahr-task-doit {
    margin-top: 8px;
}

/* Two outcomes share the row in equal halves: the refusal at the left, the completion filling the right. */
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-outcomes--pair {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 8px;
}

#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-outcomes--pair > .btn-red {
    justify-self: start;
}

/* A SHORT FORM IN THE OVERLAY: the title, progress and save line 12px apart, then each question in its
   own bordered box (the deck's .q), with no card or lift around the form itself. */
#akashic-health-records-patient-portal-root .patient-task-dialog form > .ahr-task-heading {
    margin-bottom: 12px;
}

#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-task-heading > [role="status"]:empty {
    margin-top: -12px;
}

#akashic-health-records-patient-portal-root .patient-task-dialog [data-slot="wp-card"] {
    border: 0;
    background: transparent;
}

#akashic-health-records-patient-portal-root .patient-task-dialog [data-slot="wp-card-body"] {
    padding: 0;
}

#akashic-health-records-patient-portal-root .patient-task-dialog [data-slot="wp-card"] > [data-slot="elevation"],
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-q-item [data-slot="spacer"] {
    display: none;
}

/* The deck's .q: a bordered box per question, 8px apart. */
#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-q-item {
    margin-bottom: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--ak-card-radius);
    background: var(--surface);
}

#akashic-health-records-patient-portal-root .patient-task-dialog .ahr-q-item > [data-slot="flex"]:first-child {
    margin-bottom: 6px;
}

/* 12px from the last question to Submit: its 8px gap plus 4px. */
#akashic-health-records-patient-portal-root .patient-task-dialog form > .ahr-task-outcomes {
    margin-top: 4px;
}
