/* Atlas of Lives — browser voice dictation for editable text fields. */
.atlas-dictation-toolbar {
    display: grid;
    grid-template-columns: auto minmax(130px, 1fr) auto;
    align-items: center;
    gap: .45rem .6rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    visibility: hidden;
    transition: max-height .2s ease, opacity .16s ease, margin .2s ease, padding .2s ease;
}

.atlas-dictation-toolbar.is-open,
.atlas-dictation-toolbar.is-listening {
    max-height: 126px;
    margin-top: .42rem;
    padding: .12rem 0 .08rem;
    opacity: 1;
    overflow: visible;
    visibility: visible;
}


/* Keep dictation controls inside the field's own form column. */
.form-grid > *,
.form-grid > label,
.form-grid > div,
.atlas-dictation-target,
.atlas-dictation-target + .atlas-dictation-toolbar {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.atlas-dictation-status {
    grid-column: 1 / -1;
    grid-row: 2;
}

.atlas-dictation-button,
.atlas-dictation-language {
    min-height: 34px;
    border: 1px solid rgba(31, 90, 76, .24);
    border-radius: 999px;
    background: rgba(247, 249, 246, .96);
    color: var(--forest, #234d43);
    font: inherit;
    font-size: .79rem;
    font-weight: 780;
}

.atlas-dictation-button {
    min-width: 72px;
    padding: .38rem .72rem;
    cursor: pointer;
}

.atlas-dictation-button:hover,
.atlas-dictation-button:focus-visible {
    border-color: var(--forest, #234d43);
    background: var(--forest, #234d43);
    color: #fff;
}

.atlas-dictation-button.is-listening {
    border-color: #8d3e35;
    background: #8d3e35;
    color: #fff;
}

.atlas-dictation-language {
    width: 100%;
    padding: .34rem 2rem .34rem .68rem;
    cursor: pointer;
}

.atlas-dictation-language:disabled {
    cursor: not-allowed;
    opacity: .68;
}

.atlas-dictation-status {
    min-width: 0;
    color: var(--muted, #66736e);
    font-size: .76rem;
    font-weight: 650;
    line-height: 1.28;
}

.atlas-dictation-status[data-state="listening"] {
    color: var(--forest, #234d43);
}

.atlas-dictation-status[data-state="error"],
.atlas-dictation-status[data-state="limit"] {
    color: #8d3e35;
}

.atlas-dictation-counter {
    justify-self: end;
    white-space: nowrap;
    color: var(--muted, #66736e);
    font-size: .75rem;
    font-weight: 760;
}

.atlas-dictation-counter.is-near-limit {
    color: #95680c;
}

.atlas-dictation-counter.is-at-limit {
    color: #8d3e35;
}

.atlas-dictation-counter[hidden] {
    display: none;
}

.atlas-dictation-target:focus {
    outline-offset: 2px;
}

@media (max-width: 720px) {
    .atlas-dictation-toolbar {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .atlas-dictation-toolbar.is-open,
    .atlas-dictation-toolbar.is-listening {
        max-height: 132px;
    }
}

@media (max-width: 430px) {
    .atlas-dictation-toolbar {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .atlas-dictation-counter {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .atlas-dictation-status {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .atlas-dictation-toolbar.is-open,
    .atlas-dictation-toolbar.is-listening {
        max-height: 170px;
    }
}

/* Atlas form alignment and overflow corrections. */
#place-form,
#moment-form,
#capsule-form {
    scroll-margin-top: 118px;
}

.form-grid > *,
.form-grid > label,
.form-grid > div {
    min-width: 0;
}

/* Keep dictation controls compact on both half-width and full-width fields. */
.atlas-dictation-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem .6rem;
}

.atlas-dictation-button {
    flex: 0 0 auto;
}

.atlas-dictation-language {
    flex: 0 1 190px;
    width: auto;
    min-width: 140px;
    max-width: 210px;
}

.atlas-dictation-status {
    flex: 1 1 180px;
    min-width: 150px;
}

.atlas-dictation-counter {
    flex: 0 0 auto;
    margin-left: auto;
}

/* Life places: neutral defaults and visually balanced year fields. */
.atlas-place-form-grid > label {
    align-content: start;
}

.atlas-place-form-grid .atlas-year-field small {
    min-height: 1.15rem;
}

.atlas-primary-place-row {
    align-items: center;
    min-height: 44px;
}

.atlas-primary-place-row input {
    margin-top: 0;
}

/* People & access invitation modal. */
.atlas-invite-modal {
    width: min(100%, 680px);
}

.atlas-invite-grid {
    align-items: start;
}

.atlas-invite-grid > label {
    min-width: 0;
}

.atlas-invite-form input[type="email"],
.atlas-invite-form input[type="text"],
.atlas-invite-form input:not([type]),
.atlas-invite-form select {
    width: 100%;
    min-height: 56px;
    box-sizing: border-box;
}

.atlas-invite-check {
    align-items: center;
}

.atlas-invite-check input {
    margin-top: 0;
}

.atlas-invite-submit {
    width: 100%;
}

@media (max-width: 720px) {
    #place-form,
    #moment-form,
    #capsule-form {
        scroll-margin-top: 96px;
    }

    .atlas-dictation-language {
        flex: 1 1 150px;
        max-width: none;
    }

    .atlas-dictation-status {
        flex-basis: 100%;
    }

    .atlas-dictation-counter {
        margin-left: 0;
    }
}
