/* nhc-form-widgets.css — the one stylesheet for the widgets that
 * pkg/ui_htmx/templates/form_surface.tmpl renders, that
 * assets/nhc-form-enhancements.js drives and that the React client's
 * UniversalDatePicker, UniversalDateRangePicker and RichTextEditor render:
 * the local date/time picker, its calendar grid and the rich text editor.
 *
 * This file is the single owner of those rules for both renderers. The
 * widget markup, the widget JS and the widget CSS are one contract, so they
 * live together under pkg/ui_htmx/assets: Go embeds this file and serves it
 * at FormWidgetStylesheetPath, and the React components import it by
 * relative path, exactly as they already import the widget JS from
 * clients/ui-react/src/lib/datetime-core.ts. There is no second copy under
 * clients/ui-react/src to keep in step.
 *
 * It is served as one file, so a relative @import would resolve against the
 * serving path and 404: the rules that used to live in richtext-source-mode,
 * richtext-white-surface and richtext-fullscreen are inlined below.
 *
 * Design tokens: this file uses the shared NHC design-system token names
 * (--border, --ring, --text-high/med/low, --bg-level-1/2, --ds-z-*). A host
 * whose stylesheet uses different names declares them for these widgets;
 * the portal theme does that in pkg/cmsportal/theme/assets/portal-account.css.
 */

nhc-date-time-picker {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.nhc-datetime {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
}

.nhc-datetime__group {
    position: relative;
    flex: 0 1 auto;
    min-width: 0;
}

.nhc-datetime__group--date {
    flex-basis: min(100%, 16rem);
}

.nhc-datetime__group--time {
    flex-basis: min(100%, 10rem);
}

.nhc-datetime__control {
    display: flex;
    align-items: center;
    min-height: 2.35rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    gap: 0.2rem;
    transition: none;
}

.nhc-datetime__control:focus-within {
    box-shadow: none;
}

.nhc-datetime__input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
    border-radius: 0;
    background: color-mix(in srgb, var(--bg-level-2) 92%, #0f151f);
    color: var(--text-high);
    font-size: 0.94rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    min-height: 2.35rem;
    padding: 0 0.6rem;
    box-shadow: none;
}

.nhc-datetime__input::placeholder {
    color: color-mix(in srgb, var(--text-low) 82%, transparent);
}

.nhc-datetime__input:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--ring) 48%, var(--border));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 14%, transparent);
}

.nhc-datetime__trigger {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-med);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 140ms ease, opacity 140ms ease;
}

.nhc-datetime__trigger:hover,
.nhc-datetime__trigger:focus-visible,
.nhc-datetime__trigger[aria-expanded="true"] {
    outline: none;
    color: color-mix(in srgb, var(--ring) 78%, white);
}

.nhc-datetime__panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: var(--ds-z-popover);
    width: min(20rem, calc(100vw - 2rem));
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
    border-radius: 0.8rem;
    background: color-mix(in srgb, var(--bg-level-1) 97%, #0b1017);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    padding: 0.85rem;
}

.nhc-datetime__panel[hidden],
.nhc-datetime__chooser[hidden],
.nhc-datetime__group[hidden] {
    display: none !important;
}

.nhc-datetime__panel--time {
    width: min(14rem, calc(100vw - 2rem));
}

.nhc-datetime__group[data-panel-placement="top"] .nhc-datetime__panel {
    top: auto;
    bottom: calc(100% + 0.35rem);
}

.nhc-datetime__panel-header {
    display: grid;
    grid-template-columns: 1.8rem minmax(0, 1fr) 1.8rem;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.6rem;
}

.nhc-datetime__nav {
    width: 1.8rem;
    height: 1.8rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-med);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
}

.nhc-datetime__nav:hover,
.nhc-datetime__nav:focus-visible {
    outline: none;
    color: color-mix(in srgb, var(--ring) 78%, white);
}

.nhc-datetime__headline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 0;
}

.nhc-datetime__headline-btn {
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-high);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.12rem 0.16rem;
}

.nhc-datetime__headline-btn:hover,
.nhc-datetime__headline-btn:focus-visible,
.nhc-datetime__headline-btn[aria-pressed="true"] {
    outline: none;
    color: color-mix(in srgb, var(--ring) 78%, white);
}

.nhc-datetime__choice {
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-high);
    font-variant-numeric: tabular-nums;
}

.nhc-datetime__choice.is-selected,
.nhc-datetime__choice:hover,
.nhc-datetime__choice:focus-visible {
    outline: none;
    color: color-mix(in srgb, var(--ring) 82%, white);
    background: color-mix(in srgb, var(--ring) 12%, transparent);
}

.nhc-datetime__choice.is-selected {
    font-weight: 600;
    box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--ring) 72%, transparent);
}

.nhc-datetime__chooser {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.2rem;
}

.nhc-datetime__chooser--years {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.nhc-datetime__choice {
    min-height: 2rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.8rem;
    font-weight: 400;
}

.nhc-datetime__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.6rem;
}

.nhc-datetime__chip {
    min-height: 1.85rem;
    padding: 0.32rem 0.6rem;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ring) 12%, transparent);
    color: color-mix(in srgb, var(--ring) 78%, white);
    font-size: 0.74rem;
    font-weight: 600;
}

/* The named way out of an open panel, beside the quick chips. */
.nhc-datetime__chip--done {
    margin-left: auto;
    background: color-mix(in srgb, var(--ring) 22%, transparent);
}

.nhc-datetime__chip:hover,
.nhc-datetime__chip:focus-visible {
    outline: none;
    background: color-mix(in srgb, var(--ring) 18%, transparent);
}

.nhc-datetime__time-shell {
    display: grid;
    gap: 0.7rem;
}

.nhc-datetime__time-row {
    display: grid;
    grid-template-columns: 1.9rem minmax(0, 1fr);
    align-items: center;
    gap: 0.6rem;
}

.nhc-datetime__time-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--text-low);
}

.nhc-datetime__stepper {
    display: grid;
    grid-template-columns: 1.7rem minmax(0, 1fr) 1.7rem;
    align-items: center;
    gap: 0.18rem;
}

.nhc-datetime__step {
    width: 1.7rem;
    height: 1.7rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-med);
    font-size: 1rem;
    font-weight: 600;
}

.nhc-datetime__step:hover,
.nhc-datetime__step:focus-visible {
    outline: none;
    color: color-mix(in srgb, var(--ring) 78%, white);
}

.nhc-datetime__step-input {
    width: 100%;
    min-height: 2rem;
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
    border-radius: 0.55rem;
    background: color-mix(in srgb, var(--bg-level-2) 82%, transparent);
    color: var(--text-high);
    text-align: center;
    font-size: 0.94rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    padding: 0 0.4rem;
}

.nhc-datetime__step-input:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--ring) 48%, var(--border));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 14%, transparent);
}

@media (max-width: 720px) {
    .nhc-datetime {
        gap: 0.55rem;
    }

    .nhc-datetime__group,
    .nhc-datetime__group--date,
    .nhc-datetime__group--time {
        flex-basis: 100%;
    }

    .nhc-datetime__panel,
    .nhc-datetime__panel--time {
        width: min(100vw - 2rem, 20rem);
    }
}

/* Shared day grid for nhc-date-time-picker and nhc-daterange-picker. Owns the
   weekday header, the 7-column day grid, and every state a plain day button
   can be in; range-only modifiers (start/end/in-range/preview) live in
   daterange.css next to the range picker chrome that uses them. */

.nhc-calendar__weekdays,
.nhc-calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.18rem;
}

.nhc-calendar__weekdays {
    margin-bottom: 0.25rem;
}

.nhc-calendar__weekdays span {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-low);
}

.nhc-calendar__day {
    min-height: 2.25rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-high);
    font-size: 0.875rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.nhc-calendar__day.is-outside {
    opacity: 0.42;
}

.nhc-calendar__day.is-today {
    color: color-mix(in srgb, var(--ring) 82%, white);
}

.nhc-calendar__day.is-disabled,
.nhc-calendar__day:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nhc-calendar__day:hover:not(:disabled),
.nhc-calendar__day:focus-visible,
.nhc-calendar__day.is-selected {
    outline: none;
    color: color-mix(in srgb, var(--ring) 82%, white);
    background: color-mix(in srgb, var(--ring) 12%, transparent);
}

.nhc-calendar__day.is-selected {
    font-weight: 600;
    box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--ring) 72%, transparent);
}

/* Touch screens (phones and tablets) get finger-sized days; the grid keeps
   seven columns, so the cell width already follows the container. */
@media (pointer: coarse) {
    .nhc-calendar__day {
        min-height: 2.6rem;
        font-size: 0.95rem;
    }

    .nhc-calendar__weekdays span {
        font-size: 0.74rem;
    }
}

.nhc-richtext__source-canvas {
    background: #fff;
}

.nhc-richtext__source {
    flex: 1 1 auto;
    width: 100%;
    min-height: 100%;
    border: 0;
    background: #fff;
    color: #111827;
    outline: none;
    padding: 0.85rem 0.95rem;
    resize: none;
    font: 0.86rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    tab-size: 2;
}

.nhc-richtext__source::selection {
    background: #bfdbfe;
}

.nhc-richtext__source:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.nhc-richtext[data-richtext-surface-tone="white"] {
    background: #fff;
    border-color: #d1d5db;
}

.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__canvas {
    background: #fff;
}

.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface {
    background: #fff;
    color: #111827;
}

.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface:empty::before {
    color: #6b7280;
}

.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface h1,
.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface h2,
.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface h3,
.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface h4,
.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface h5,
.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface h6,
.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface strong {
    color: #111827;
}

.nhc-richtext[data-richtext-surface-tone="white"] .nhc-richtext__surface blockquote {
    color: #374151;
    border-left-color: #d1d5db;
}

[data-editor-fullscreen-host="1"] {
    position: relative;
}

/* Hide covered controls and scrollbars without moving the React-owned editor. */
[data-editor-fullscreen-host="1"]:has(.nhc-richtext.is-fullscreen) {
    visibility: hidden;
    overflow: clip;
}

.nhc-richtext.is-fullscreen {
    position: fixed;
    top: var(--nhc-visual-viewport-offset-top, 0px);
    left: var(--nhc-visual-viewport-offset-left, 0px);
    width: var(--nhc-shell-viewport-width, 100vw);
    height: var(--nhc-shell-viewport-height, 100dvh);
    visibility: visible;
    z-index: var(--ds-z-panel);
    border-radius: 0;
    box-shadow: none;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--bg-level-1) 98%, #06090f) 0%,
            color-mix(in srgb, var(--bg-level-0) 98%, #04070d) 100%);
}

[data-editor-fullscreen-host="1"] .nhc-richtext.is-fullscreen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.nhc-richtext.is-fullscreen,
.nhc-richtext.nhc-richtext--fill-available.is-fullscreen {
    min-height: 0;
    max-height: 100%;
}

.nhc-richtext.is-fullscreen .nhc-richtext__canvas {
    flex: 1 1 0;
    min-height: 0;
    resize: none;
}

.nhc-richtext.is-fullscreen .nhc-richtext__toolbar {
    min-height: 0;
    max-height: 40%;
    overflow-y: auto;
}

.nhc-richtext.is-fullscreen .nhc-richtext__surface,
.nhc-richtext.is-fullscreen .nhc-richtext__source {
    min-height: 100%;
    max-height: none;
    padding: 1rem 1.1rem 1.4rem;
}


.nhc-richtext {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 0;
    gap: 0;
    border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--bg-level-1) 96%, #0b1017);
    overflow: hidden;
}

.nhc-richtext.nhc-richtext--fill-available {
    flex: 1 1 auto;
    min-height: 12rem;
}

.nhc-richtext.nhc-richtext--fill-available .nhc-richtext__canvas,
.nhc-richtext.nhc-richtext--fill-available .nhc-richtext__source-canvas {
    flex: 1 1 auto;
}

.nhc-richtext__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.14rem;
    padding: 0.26rem 0.35rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
    background: color-mix(in srgb, var(--bg-level-2) 78%, #101722);
    position: relative;
    flex: 0 0 auto;
    z-index: var(--ds-z-selection);
}

.nhc-richtext__toolbar[data-link-open="1"] {
    align-items: stretch;
}

.nhc-richtext__sep {
    width: 1px;
    height: 1.15rem;
    flex: 0 0 auto;
    margin: 0 0.15rem;
    background: color-mix(in srgb, var(--border) 70%, transparent);
}

.nhc-richtext__tool,
.nhc-richtext__popover-btn {
    appearance: none;
    font: inherit;
    cursor: pointer;
}

.nhc-richtext .nhc-richtext__tool,
.nhc-richtext .nhc-form__inline-action.nhc-richtext__tool {
    min-width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent;
    color: color-mix(in srgb, var(--text-high) 88%, white);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: none;
    white-space: nowrap;
}

.nhc-richtext .nhc-richtext__tool--label,
.nhc-richtext .nhc-form__inline-action.nhc-richtext__tool--label {
    min-width: 2.05rem;
    padding: 0 0.35rem;
    font-size: 0.69rem;
    letter-spacing: 0.02em;
}

.nhc-richtext .nhc-richtext__tool:hover,
.nhc-richtext .nhc-richtext__tool:focus-visible,
.nhc-richtext .nhc-richtext__tool[aria-pressed="true"],
.nhc-richtext .nhc-form__inline-action.nhc-richtext__tool:hover,
.nhc-richtext .nhc-form__inline-action.nhc-richtext__tool:focus-visible,
.nhc-richtext .nhc-form__inline-action.nhc-richtext__tool[aria-pressed="true"] {
    background: color-mix(in srgb, var(--ring) 10%, transparent);
    color: color-mix(in srgb, var(--ring) 68%, white);
}

.nhc-richtext .nhc-richtext__tool[aria-pressed="true"],
.nhc-richtext .nhc-form__inline-action.nhc-richtext__tool[aria-pressed="true"] {
    background: color-mix(in srgb, var(--ring) 24%, var(--bg-level-2));
    color: var(--ring);
    box-shadow: inset 0 -2px 0 var(--ring);
}

.nhc-richtext__tool:disabled,
.nhc-richtext__popover-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.nhc-richtext__icon {
    width: 0.9rem;
    height: 0.9rem;
    display: block;
}

.nhc-richtext__canvas {
    display: flex;
    min-height: 12rem;
    min-width: 0;
    resize: vertical;
    overflow: auto;
    overscroll-behavior: contain;
    background: color-mix(in srgb, var(--bg-level-1) 95%, #101722);
}

.nhc-richtext__canvas[hidden],
.nhc-richtext__popover[hidden] {
    display: none;
}

.nhc-richtext__surface {
    flex: 1 1 auto;
    min-height: 100%;
    max-height: none;
    overflow: visible;
    padding: 0.85rem 0.95rem;
    outline: none;
    color: color-mix(in srgb, var(--text-high) 94%, white);
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: normal;
    word-break: break-word;
}

.nhc-richtext__surface[contenteditable="false"] {
    opacity: 0.7;
    cursor: not-allowed;
}

.nhc-richtext__surface:empty::before {
    content: attr(data-placeholder);
    color: color-mix(in srgb, var(--text-low) 88%, #94a3b8);
}

@media (max-width: 640px) {
    .mail-compose-body-editor {
        flex: 0 0 auto;
        height: clamp(12rem, 44dvh, 28rem);
        min-height: 12rem;
        max-height: 28rem;
    }

    .mail-compose-body-editor .nhc-richtext {
        height: 100%;
        min-height: 0;
    }

    .mail-compose-body-editor .nhc-richtext__toolbar {
        max-height: 3.58rem;
        gap: 0.04rem;
        padding: 0.2rem 0.2rem;
        overflow-y: auto;
    }

    .mail-compose-body-editor .nhc-richtext__tool {
        min-width: 1.55rem;
        height: 1.55rem;
    }

    .mail-compose-body-editor .nhc-richtext__sep {
        margin-inline: 0.03rem;
    }

    .mail-compose-body-editor .nhc-richtext__canvas {
        resize: none;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mail-compose-body-editor .nhc-richtext__surface {
        overflow: visible;
    }
}

.nhc-richtext__surface > *:first-child {
    margin-top: 0;
}

.nhc-richtext__surface > *:last-child {
    margin-bottom: 0;
}

.nhc-richtext__surface p,
.nhc-richtext__surface ul,
.nhc-richtext__surface ol,
.nhc-richtext__surface blockquote,
.nhc-richtext__surface pre {
    margin: 0 0 0.95rem;
}

.nhc-richtext__surface h1,
.nhc-richtext__surface h2,
.nhc-richtext__surface h3,
.nhc-richtext__surface h4,
.nhc-richtext__surface h5,
.nhc-richtext__surface h6 {
    margin: 1.1rem 0 0.55rem;
    color: color-mix(in srgb, var(--text-high) 98%, white);
    font-weight: 700;
    line-height: 1.18;
    letter-spacing: -0.015em;
}

.nhc-richtext__surface h1 {
    font-size: 1.55rem;
}

.nhc-richtext__surface h2 {
    font-size: 1.28rem;
}

.nhc-richtext__surface h3 {
    font-size: 1.08rem;
}

.nhc-richtext__surface strong {
    font-weight: 700;
    color: color-mix(in srgb, var(--text-high) 100%, white);
}

.nhc-richtext__surface em {
    font-style: italic;
}

.nhc-richtext__surface u {
    text-underline-offset: 0.14em;
    text-decoration-thickness: 0.09em;
}

.nhc-richtext__surface img,
.nhc-richtext__surface table,
.nhc-richtext__surface pre,
.nhc-richtext__surface blockquote {
    max-width: 100%;
}

.nhc-richtext__surface blockquote {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0.9rem;
    border-left: 3px solid color-mix(in srgb, var(--ring) 54%, transparent);
    color: color-mix(in srgb, var(--text-med) 90%, #cbd5e1);
    font-style: italic;
}

.nhc-richtext__surface ul {
    list-style: disc outside;
    padding-left: 1.45rem;
}

.nhc-richtext__surface ol {
    list-style: decimal outside;
    padding-left: 1.35rem;
}

.nhc-richtext__surface ul ul {
    list-style-type: circle;
}

.nhc-richtext__surface ul ul ul {
    list-style-type: square;
}

.nhc-richtext__surface ol ol {
    list-style-type: lower-alpha;
}

.nhc-richtext__surface li + li {
    margin-top: 0.3rem;
}

.nhc-richtext__surface li::marker {
    color: color-mix(in srgb, var(--ring) 66%, var(--text-high));
}

.nhc-richtext__surface a {
    color: color-mix(in srgb, var(--ring) 72%, #1d4ed8);
    text-decoration: underline;
}

/* The htmx editor toggles the link popover with the hidden attribute
 * (form-enhancements-richtext.js); the class's display:flex would win over
 * the UA [hidden] rule on a host without a [hidden] reset (the portal
 * theme), so the [hidden] state is spelled out above. */
.nhc-richtext__popover {
    position: static;
    z-index: var(--ds-z-editor-tools);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: min(100%, 34rem);
    max-width: 100%;
    flex: 1 0 100%;
    order: 99;
    margin-top: 0.1rem;
    padding: 0.45rem 0 0;
    border-radius: 0.55rem;
    background: transparent;
    box-shadow: none;
}

.nhc-richtext__popover-input {
    min-width: 13rem;
    width: 100%;
    flex: 1 1 21rem;
    height: 2rem;
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    border-radius: 0.4rem;
    padding: 0 0.8rem;
    font-size: 0.82rem;
    background: color-mix(in srgb, var(--bg-level-2) 92%, #111827);
    color: var(--text-high);
}

.nhc-richtext__popover-btn {
    height: 2rem;
    min-width: 5.5rem;
    padding: 0 0.89rem;
    border-radius: 0.4rem;
    border: 1px solid color-mix(in srgb, var(--ring) 32%, transparent);
    background: color-mix(in srgb, var(--ring) 16%, var(--bg-level-2));
    color: color-mix(in srgb, var(--ring) 76%, white);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .nhc-richtext__popover {
        width: 100%;
    }

    .nhc-richtext__popover-input {
        min-width: 0;
    }
}

/* ----------------------------------------------------------------------
 * Notices, invalid fields and the image field's status line: the one
 * "something must be fixed or did not work" look for every htmx SDUI form.
 *
 * pkg/eventapp/ui.WithFormNotice (server) and form-enhancements-notices.js
 * (browser) both render `.nhc-form-notice.nhc-form-notice--<kind>` with
 * data-form-notice="1", role="alert"/"status" and aria-live; dialog-shell.js
 * focuses it after a swap. A refused field carries aria-invalid="true" and
 * an `.nhc-form__validation` block under it, whether the server rendered
 * the refusal (FormFieldRuntime.ValidationMessages) or the browser's native
 * validation did (form-enhancements-fields.js markInvalidField). The image
 * field's `.nhc-form__media-status` line reports upload/download progress
 * and failure by data-state (form-enhancements-media.js setMediaStatus).
 *
 * The three hues are mixed with the host's own text colour, so the same
 * rules read on the admin shell's light surfaces and a portal's dark ones;
 * a host may still override the --nhc-notice-* hues.
 * -------------------------------------------------------------------- */

.nhc-form-notice,
.nhc-form__validation,
.nhc-form__media-status {
    --nhc-notice-error: #ef4444;
    --nhc-notice-warning: #f59e0b;
    --nhc-notice-success: #22c55e;
    --nhc-notice-ink: color-mix(in srgb, var(--nhc-notice-hue) 65%, var(--text-high, currentColor));
}

.nhc-form-notice {
    --nhc-notice-hue: var(--nhc-notice-success);
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 0 0 1rem 0;
    padding: 0.65rem 0.85rem;
    border: 1px solid color-mix(in srgb, var(--nhc-notice-hue) 55%, transparent);
    border-left-width: 4px;
    border-radius: 0.6rem;
    background: color-mix(in srgb, var(--nhc-notice-hue) 14%, transparent);
    color: var(--nhc-notice-ink);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0;
    text-transform: none;
    scroll-margin-top: 0.75rem;
}

.nhc-form-notice::before {
    content: "i";
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.05rem;
    border-radius: 999px;
    background: var(--nhc-notice-hue);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
}

.nhc-form-notice--error {
    --nhc-notice-hue: var(--nhc-notice-error);
}

.nhc-form-notice--error::before {
    content: "!";
}

.nhc-form-notice--warning {
    --nhc-notice-hue: var(--nhc-notice-warning);
}

.nhc-form-notice--warning::before {
    content: "!";
}

.nhc-form-notice--success::before {
    content: "\2713";
}

.nhc-form-notice:focus {
    outline: 2px solid color-mix(in srgb, var(--nhc-notice-hue) 70%, transparent);
    outline-offset: 2px;
}

/* Invalid control: red ring on the control the browser or server refused,
 * and the label of that field marked the same way. */
.nhc-form [aria-invalid="true"],
.nhc-form .nhc-richtext:has([aria-invalid="true"]) .nhc-richtext__canvas,
.nhc-form nhc-date-time-picker[aria-invalid="true"] .nhc-datetime__control,
.nhc-form nhc-date-time-picker:has([aria-invalid="true"]) .nhc-datetime__control {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, #ef4444 35%, transparent);
}

.nhc-form .nhc-form__field:has([aria-invalid="true"]) > .nhc-form__label {
    color: color-mix(in srgb, #ef4444 70%, var(--text-high, currentColor));
}

.nhc-form__validation {
    --nhc-notice-hue: var(--nhc-notice-error);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.3rem;
    color: var(--nhc-notice-ink);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
}

.nhc-form__validation > [role="alert"]::before {
    content: "! ";
    font-weight: 800;
}

.nhc-form__validation > [role="status"] {
    --nhc-notice-hue: var(--nhc-notice-warning);
}

/* Image field status line: hidden until it has something to say. */
.nhc-form__media-status {
    display: none;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.35rem;
    min-height: 1.15rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-med, currentColor);
    scroll-margin-bottom: 0.75rem;
}

.nhc-form__media-status:not(:empty) {
    display: flex;
}

.nhc-form__media-status[data-state="error"] {
    --nhc-notice-hue: var(--nhc-notice-error);
    color: var(--nhc-notice-ink);
}

.nhc-form__media-status[data-state="warning"] {
    --nhc-notice-hue: var(--nhc-notice-warning);
    color: var(--nhc-notice-ink);
}

.nhc-form__media-status[data-state="ok"] {
    --nhc-notice-hue: var(--nhc-notice-success);
    color: var(--nhc-notice-ink);
}

.nhc-form__media-status[data-state="error"]::before,
.nhc-form__media-status[data-state="warning"]::before,
.nhc-form__media-status[data-state="ok"]::before {
    content: "!";
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    background: var(--nhc-notice-hue);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
}

.nhc-form__media-status[data-state="ok"]::before {
    content: "\2713";
}

.nhc-form__media-status[data-state="loading"]::before {
    content: "";
    flex: 0 0 auto;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 999px;
    border: 2px solid color-mix(in srgb, currentColor 35%, transparent);
    border-top-color: currentColor;
    animation: nhc-media-status-spin 0.8s linear infinite;
}

@keyframes nhc-media-status-spin {
    to { transform: rotate(360deg); }
}
