.mmv {
    --mmv-bg: #f4f6f8;
    --mmv-surface: #ffffff;
    --mmv-border: #e6eaef;
    --mmv-accent: #1565c0;
    --mmv-accent-hover: #0d47a1;
    --mmv-text: #1f2937;
    --mmv-muted: #5f6b7a;
    --mmv-note-bg: #e3f2fd;
    --mmv-note-border: #1565c0;
    color: var(--mmv-text);
    font-family: Avenir, "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
    margin: 1.5rem 0;
}

.mmv-card {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--mmv-surface);
    border: 1px solid var(--mmv-border);
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.mmv-header {
    background: linear-gradient(135deg, #f7fafc, var(--mmv-bg));
    padding: 1.25rem;
    border-bottom: 1px solid var(--mmv-border);
}

.mmv-header h2 {
    margin: 0 0 0.4rem;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    line-height: 1.2;
}

.mmv-header p {
    margin: 0;
    color: var(--mmv-muted);
}

.mmv-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--mmv-border);
    background: #fafbfc;
}

/* Harden layout against theme CSS overrides that can cause control overlap. */
.mmv .mmv-form {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: start;
}

.mmv .mmv-form > * {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.mmv .mmv-field {
    display: block !important;
}

.mmv .mmv-field label {
    display: block !important;
    position: static !important;
    float: none !important;
    clear: both !important;
    width: auto !important;
    margin: 0 0 8px 0 !important;
    transform: none !important;
}

.mmv .mmv-field input,
.mmv .mmv-field select {
    display: block !important;
    position: relative !important;
    float: none !important;
    clear: both !important;
}

.mmv .mmv-field input,
.mmv .mmv-field select,
.mmv .mmv-actions button {
    width: 100% !important;
    max-width: 100% !important;
}

.mmv .mmv-actions {
    display: flex !important;
    align-items: flex-end !important;
    align-self: end !important;
}

.mmv-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.mmv-field label {
    font-size: 0.9rem;
    color: var(--mmv-muted);
    font-weight: 600;
}

.mmv-field input,
.mmv-field select {
    border: 2px solid #d8dee6;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    font-size: 1rem;
    width: 100%;
    background: #fff;
}

.mmv-field input:focus,
.mmv-field select:focus {
    border-color: var(--mmv-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.mmv-actions {
    display: flex;
    align-items: flex-end;
    min-width: 0;
}

.mmv-actions button {
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: var(--mmv-accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.75rem 1rem;
    cursor: pointer;
}

.mmv-actions button:hover {
    background: var(--mmv-accent-hover);
}

.mmv-viz {
    padding: 1rem;
}

.mmv-grid-shell {
    border: 1px solid var(--mmv-border);
    border-radius: 10px;
    background: #fbfdff;
    padding: 0.7rem;
}

.mmv-grid-flow {
    --dot-size: 12px;
    --dot-gap: 3px;
    --dot-pitch: calc(var(--dot-size) + var(--dot-gap));
    display: grid;
    grid-auto-flow: row dense;
    grid-template-columns: repeat(auto-fill, minmax(var(--dot-pitch), var(--dot-pitch)));
    grid-auto-rows: max(var(--dot-pitch), 1.2rem);
    align-items: center;
    padding: 0.25rem 0.1rem 0.4rem;
    line-height: 1;
    word-break: normal;
}

.mmv-dot-token {
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 999px;
    border: 1px solid currentColor;
    opacity: 0.95;
    justify-self: center;
    align-self: center;
}

.mmv-dot-token.live {
    background: currentColor;
}

.mmv-age-inline-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.96rem;
    font-weight: 700;
    color: #1f4061;
    white-space: nowrap;
    letter-spacing: 0.02em;
    grid-column: span var(--marker-dots, 18);
    align-self: center;
}

.mmv-summary {
    margin-top: 0.9rem;
    border: 1px solid var(--mmv-border);
    border-radius: 10px;
    background: #f8fafb;
    padding: 0.8rem;
    line-height: 1.5;
}

.mmv-privacy {
    margin: 0 1rem 1rem;
    border-left: 4px solid var(--mmv-note-border);
    background: var(--mmv-note-bg);
    border-radius: 8px;
    padding: 0.8rem 0.95rem;
    color: #234;
}

@media (max-width: 640px) {
    .mmv {
        margin: 0.75rem 0;
    }

    .mmv-header,
    .mmv-form,
    .mmv-viz {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .mmv-form {
        grid-template-columns: 1fr;
        gap: 0.7rem;
    }

    .mmv .mmv-form {
        grid-template-columns: 1fr !important;
    }

    .mmv-privacy {
        margin-left: 0.85rem;
        margin-right: 0.85rem;
    }

    .mmv-grid-flow {
        --dot-size: 11px;
    }

    .mmv-age-inline-text {
        font-size: 0.79rem;
    }
}
