/* ===================================
   Module 3 — Browser & DOM
   Extra component styles
   =================================== */

/* =============================
   1. INTRO — Topics Grid + CTA
   ============================= */
.m3-topics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.25rem 0;
}

.m3-topic {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid;
}

.m3-topic--green  { background: rgba(110, 231, 183, 0.12); border-color: rgba(110, 231, 183, 0.3); color: #6ee7b7; }
.m3-topic--blue   { background: rgba(96, 165, 250, 0.12);  border-color: rgba(96, 165, 250, 0.3);  color: #60a5fa; }
.m3-topic--purple { background: rgba(167, 139, 250, 0.12); border-color: rgba(167, 139, 250, 0.3); color: #a78bfa; }
.m3-topic--yellow { background: rgba(250, 204, 21, 0.12);  border-color: rgba(250, 204, 21, 0.3);  color: #facc15; }
.m3-topic--pink   { background: rgba(244, 114, 182, 0.12); border-color: rgba(244, 114, 182, 0.3); color: #f472b6; }
.m3-topic--red    { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.3); color: #f87171; }

[data-theme="light"] .m3-topic--green  { background: rgba(5, 150, 105, 0.08); border-color: rgba(5, 150, 105, 0.25); color: #059669; }
[data-theme="light"] .m3-topic--blue   { background: rgba(37, 99, 235, 0.08); border-color: rgba(37, 99, 235, 0.25); color: #2563eb; }
[data-theme="light"] .m3-topic--purple { background: rgba(124, 58, 237, 0.08); border-color: rgba(124, 58, 237, 0.25); color: #7c3aed; }
[data-theme="light"] .m3-topic--yellow { background: rgba(202, 138, 4, 0.08);  border-color: rgba(202, 138, 4, 0.25);  color: #ca8a04; }
[data-theme="light"] .m3-topic--pink   { background: rgba(219, 39, 119, 0.08); border-color: rgba(219, 39, 119, 0.25); color: #db2777; }
[data-theme="light"] .m3-topic--red    { background: rgba(220, 38, 38, 0.08);  border-color: rgba(220, 38, 38, 0.25);  color: #dc2626; }

/* CTA Box */
.m3-cta-box {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0 0;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.1), rgba(110, 231, 183, 0.1));
    border: 1px solid rgba(122, 162, 255, 0.2);
}

.m3-cta-icon { font-size: 2rem; flex-shrink: 0; }
.m3-cta-text { flex: 1; }
.m3-cta-text h4 { margin: 0 0 0.25rem; font-size: 0.95rem; color: var(--text-primary); }
.m3-cta-text p  { margin: 0; font-size: 0.85rem; color: var(--text-tertiary); }

.m3-cta-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    background: var(--accent-gradient);
    color: #0f1220;
    transition: transform 0.2s, box-shadow 0.2s;
}

.m3-cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(122, 162, 255, 0.3);
}

[data-theme="light"] .m3-cta-btn { color: #fff; }

[data-theme="light"] .m3-cta-box {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(5, 150, 105, 0.06));
    border-color: rgba(37, 99, 235, 0.15);
}

[data-theme="light"] .m3-cta-btn:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* =============================
   2. WINDOW / DOCUMENT — Property Cards & Ref Cards
   ============================= */
.m3-props-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.m3-prop-card {
    padding: 1rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    transition: border-color 0.2s;
}

.m3-prop-card:hover { border-color: var(--border-hover); }

.m3-prop-card__title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.m3-prop-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.m3-prop-card__badges code {
    font-size: 0.78rem;
    padding: 0.15em 0.45em;
}

.m3-prop-card--green  { border-left: 3px solid #6ee7b7; }
.m3-prop-card--blue   { border-left: 3px solid #60a5fa; }
.m3-prop-card--purple { border-left: 3px solid #a78bfa; }
.m3-prop-card--yellow { border-left: 3px solid #facc15; }
.m3-prop-card--orange { border-left: 3px solid #f97316; }
.m3-prop-card--gray   { border-left: 3px solid #94a3b8; }
.m3-prop-card--red    { border-left: 3px solid #f87171; }
.m3-prop-card--pink   { border-left: 3px solid #f472b6; }

[data-theme="light"] .m3-prop-card--green  { border-left-color: #059669; }
[data-theme="light"] .m3-prop-card--blue   { border-left-color: #2563eb; }
[data-theme="light"] .m3-prop-card--purple { border-left-color: #7c3aed; }
[data-theme="light"] .m3-prop-card--yellow { border-left-color: #ca8a04; }
[data-theme="light"] .m3-prop-card--orange { border-left-color: #ea580c; }
[data-theme="light"] .m3-prop-card--gray   { border-left-color: #64748b; }
[data-theme="light"] .m3-prop-card--red    { border-left-color: #dc2626; }
[data-theme="light"] .m3-prop-card--pink   { border-left-color: #db2777; }

/* Ref cards (document section) */
.m3-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.m3-ref-card {
    padding: 1rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.m3-ref-card--green  { border-left: 3px solid #6ee7b7; }
.m3-ref-card--blue   { border-left: 3px solid #60a5fa; }
.m3-ref-card--purple { border-left: 3px solid #a78bfa; }

[data-theme="light"] .m3-ref-card--green  { border-left-color: #059669; }
[data-theme="light"] .m3-ref-card--blue   { border-left-color: #2563eb; }
[data-theme="light"] .m3-ref-card--purple { border-left-color: #7c3aed; }

.m3-ref-card__title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.m3-ref-card code {
    font-size: 0.78rem;
}

.m3-ref-desc {
    color: var(--text-tertiary);
    font-size: 0.82rem;
}

.m3-ready-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.m3-mini-badge {
    display: inline-block;
    padding: 0.2em 0.55em;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.m3-mini-badge--orange { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.m3-mini-badge--blue   { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.m3-mini-badge--green  { background: rgba(110, 231, 183, 0.15); color: #6ee7b7; }

[data-theme="light"] .m3-mini-badge--orange { background: rgba(234, 88, 12, 0.1); color: #ea580c; }
[data-theme="light"] .m3-mini-badge--blue   { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
[data-theme="light"] .m3-mini-badge--green  { background: rgba(5, 150, 105, 0.1); color: #059669; }

/* =============================
   3. DOM TREE — Node Badges + Navigation
   ============================= */
.m3-node-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1rem 0;
}

.m3-node-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid;
}

.m3-node-badge--green  { background: rgba(110, 231, 183, 0.12); border-color: rgba(110, 231, 183, 0.25); color: #6ee7b7; }
.m3-node-badge--blue   { background: rgba(96, 165, 250, 0.12);  border-color: rgba(96, 165, 250, 0.25);  color: #60a5fa; }
.m3-node-badge--purple { background: rgba(167, 139, 250, 0.12); border-color: rgba(167, 139, 250, 0.25); color: #a78bfa; }
.m3-node-badge--yellow { background: rgba(250, 204, 21, 0.12);  border-color: rgba(250, 204, 21, 0.25);  color: #facc15; }

[data-theme="light"] .m3-node-badge--green  { background: rgba(5, 150, 105, 0.08); border-color: rgba(5, 150, 105, 0.2); color: #059669; }
[data-theme="light"] .m3-node-badge--blue   { background: rgba(37, 99, 235, 0.08); border-color: rgba(37, 99, 235, 0.2); color: #2563eb; }
[data-theme="light"] .m3-node-badge--purple { background: rgba(124, 58, 237, 0.08); border-color: rgba(124, 58, 237, 0.2); color: #7c3aed; }
[data-theme="light"] .m3-node-badge--yellow { background: rgba(202, 138, 4, 0.08);  border-color: rgba(202, 138, 4, 0.2);  color: #ca8a04; }

/* Nav grid (parent/children/siblings) */
.m3-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.m3-nav-box {
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.m3-nav-box--green  { border-left: 3px solid #6ee7b7; }
.m3-nav-box--blue   { border-left: 3px solid #60a5fa; }
.m3-nav-box--purple { border-left: 3px solid #a78bfa; }

[data-theme="light"] .m3-nav-box--green  { border-left-color: #059669; }
[data-theme="light"] .m3-nav-box--blue   { border-left-color: #2563eb; }
[data-theme="light"] .m3-nav-box--purple { border-left-color: #7c3aed; }

.m3-nav-box__title {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.m3-nav-box__note {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.m3-dim {
    color: var(--text-tertiary);
    font-size: 0.82rem;
}

/* =============================
   3b. DOM TREE — HTML → DOM Visual Diagram
   ============================= */
.m3-html-to-dom {
    margin: 1.5rem 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    overflow: hidden;
}

.m3-html-to-dom__title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(122, 162, 255, 0.04);
}

.m3-html-to-dom__panels {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
}

.m3-html-to-dom__panel {
    padding: 1.25rem;
}

.m3-html-to-dom__panel--source {
    border-right: 1px solid var(--border-color);
}

.m3-html-to-dom__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed var(--border-color);
}

.m3-html-to-dom__code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.65;
    margin: 0;
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: pre;
}

.m3-html-to-dom__code code {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    font-size: inherit;
    color: var(--text-secondary);
}

.m3-html-to-dom__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-primary);
    padding: 0 0.6rem;
    opacity: 0.6;
}

/* Visual DOM tree */
.m3-html-to-dom__tree {
    padding: 0.5rem 0;
}

.m3-dom-node {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: 5px;
    margin-bottom: 0.2rem;
}

.m3-dom-node--doc {
    background: rgba(122, 162, 255, 0.15);
    color: #7aa2ff;
    border: 1px solid rgba(122, 162, 255, 0.25);
    font-weight: 700;
}

.m3-dom-node--el {
    background: rgba(110, 231, 183, 0.1);
    color: #6ee7b7;
    border: 1px solid rgba(110, 231, 183, 0.18);
}

.m3-dom-text {
    font-weight: 400;
    font-size: 0.75rem;
    color: #facc15;
    margin-left: 0.4rem;
    opacity: 0.8;
}

.m3-dom-text::before { content: '→ '; color: var(--text-tertiary); font-size: 0.7rem; }

.m3-dom-attr {
    font-weight: 400;
    font-size: 0.75rem;
    color: #a78bfa;
    margin-left: 0.15rem;
}

.m3-dom-branch {
    position: relative;
    padding-left: 1.5rem;
    margin-left: 0.55rem;
}

.m3-dom-branch::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0.65rem;
    width: 1.5px;
    background: var(--border-hover);
    opacity: 0.45;
}

.m3-dom-branch::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0.85rem;
    width: 0.85rem;
    height: 1.5px;
    background: var(--border-hover);
    opacity: 0.45;
}

/* Light mode */
[data-theme="light"] .m3-html-to-dom {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .m3-html-to-dom__title {
    background: rgba(37, 99, 235, 0.04);
    color: #475569;
}

[data-theme="light"] .m3-html-to-dom__panel--source {
    border-right-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .m3-html-to-dom__code {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .m3-dom-node--doc {
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, 0.2);
}

[data-theme="light"] .m3-dom-node--el {
    background: rgba(5, 150, 105, 0.06);
    color: #047857;
    border-color: rgba(5, 150, 105, 0.18);
}

[data-theme="light"] .m3-dom-text {
    color: #b45309;
}

[data-theme="light"] .m3-dom-attr {
    color: #7c3aed;
}

[data-theme="light"] .m3-dom-branch::before,
[data-theme="light"] .m3-dom-branch::after {
    background: #94a3b8;
    opacity: 0.4;
}

/* Responsive */
@media (max-width: 640px) {
    .m3-html-to-dom__panels {
        grid-template-columns: 1fr;
    }

    .m3-html-to-dom__panel--source {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .m3-html-to-dom__arrow {
        padding: 0.4rem 0;
        font-size: 1.2rem;
        transform: rotate(90deg);
    }
}

/* =============================
   4. DOM INHERITANCE — Collapsible Tree
   ============================= */
.m3-dom-tree {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    margin: 1.25rem 0;
    overflow-x: auto;
}

.m3-tree { list-style: none; padding: 0; margin: 0; }
.m3-tree ul {
    list-style: none;
    padding-left: 1.75rem;
    margin: 0.15rem 0 0;
    position: relative;
}

/* Vertical connector line */
.m3-tree ul::before {
    content: '';
    position: absolute;
    left: 0.55rem;
    top: 0;
    bottom: 0.9rem;
    width: 1.5px;
    background: var(--border-hover);
    border-radius: 1px;
    opacity: 0.5;
}

.m3-tree li {
    margin: 0.2rem 0;
    position: relative;
}

/* Horizontal connector line to each node */
.m3-tree ul > li::before {
    content: '';
    position: absolute;
    left: -1.2rem;
    top: 0.85rem;
    width: 0.85rem;
    height: 1.5px;
    background: var(--border-hover);
    opacity: 0.5;
}

/* Hide children of collapsed nodes */
.m3-has-children > ul { display: none; }
.m3-has-children.m3-open > ul { display: block; }

.m3-node {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    cursor: default;
    transition: background 0.15s, box-shadow 0.15s;
}

.m3-has-children > .m3-node { cursor: pointer; }
.m3-has-children > .m3-node:hover { background: rgba(122, 162, 255, 0.1); }

.m3-node--root {
    background: rgba(122, 162, 255, 0.15);
    color: #7aa2ff;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid rgba(122, 162, 255, 0.25);
}

.m3-node--abstract {
    background: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
    font-weight: 600;
    border: 1px solid rgba(167, 139, 250, 0.15);
}

.m3-node--leaf {
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
}

.m3-node--more { color: var(--text-tertiary); font-style: italic; font-size: 0.78rem; }

.m3-node--attr {
    background: rgba(250, 204, 21, 0.12);
    color: #facc15;
    font-weight: 600;
    border: 1px solid rgba(250, 204, 21, 0.2);
}

[data-theme="light"] .m3-node--root {
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, 0.2);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.1);
}

[data-theme="light"] .m3-node--abstract {
    background: rgba(124, 58, 237, 0.06);
    color: #6d28d9;
    border-color: rgba(124, 58, 237, 0.15);
}

[data-theme="light"] .m3-node--leaf {
    color: #334155;
}

[data-theme="light"] .m3-node--attr {
    background: rgba(202, 138, 4, 0.08);
    color: #92400e;
    border-color: rgba(202, 138, 4, 0.2);
}

[data-theme="light"] .m3-has-children > .m3-node:hover { background: rgba(37, 99, 235, 0.08); }

/* Tree connector lines — light mode */
[data-theme="light"] .m3-tree ul::before {
    background: #94a3b8;
    opacity: 0.4;
}

[data-theme="light"] .m3-tree ul > li::before {
    background: #94a3b8;
    opacity: 0.4;
}

.m3-toggle {
    font-size: 0.65rem;
    user-select: none;
    width: 1.1em;
    text-align: center;
    transition: transform 0.2s;
}

.m3-attr-note {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}

.m3-note-text {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    font-style: italic;
}

/* =============================
   5. SELECTORS — Grid + Badges
   ============================= */
.m3-select-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.25rem 0;
}

.m3-select-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.m3-select-row code {
    font-size: 0.82rem;
    min-width: 0;
    word-break: break-all;
}

.m3-select-row > span:not(.m3-badge) {
    flex: 1;
    min-width: 120px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.m3-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2em 0.55em;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.m3-badge--green  { background: rgba(110, 231, 183, 0.15); color: #6ee7b7; }
.m3-badge--blue   { background: rgba(96, 165, 250, 0.15);  color: #60a5fa; }
.m3-badge--purple { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.m3-badge--yellow { background: rgba(250, 204, 21, 0.15);  color: #facc15; }
.m3-badge--red    { background: rgba(248, 113, 113, 0.15); color: #f87171; }

[data-theme="light"] .m3-badge--green  { background: rgba(5, 150, 105, 0.1); color: #059669; }
[data-theme="light"] .m3-badge--blue   { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
[data-theme="light"] .m3-badge--purple { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
[data-theme="light"] .m3-badge--yellow { background: rgba(202, 138, 4, 0.1);  color: #b45309; }
[data-theme="light"] .m3-badge--red    { background: rgba(220, 38, 38, 0.1);  color: #dc2626; }

/* =============================
   5b. DETAILS — Deep Dive Toggle Boxes
   ============================= */
.m3-details-box {
    margin: 1.25rem 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    overflow: hidden;
}

.m3-details-box summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.m3-details-box summary::-webkit-details-marker { display: none; }
.m3-details-box summary::marker { display: none; content: ''; }
.m3-details-box summary:hover { background: rgba(122, 162, 255, 0.05); }

.m3-details-arrow {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent-primary);
    transition: transform 0.25s ease;
}

.m3-details-box[open] .m3-details-arrow {
    transform: rotate(90deg);
}

.m3-details-content {
    padding: 0.5rem 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.m3-details-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem;
}

.m3-details-content h4:first-child { margin-top: 0.5rem; }

.m3-details-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 0.75rem;
}

.m3-details-box--blue   { border-left: 3px solid #60a5fa; }
.m3-details-box--green  { border-left: 3px solid #6ee7b7; }
.m3-details-box--purple { border-left: 3px solid #a78bfa; }
.m3-details-box--yellow { border-left: 3px solid #facc15; }

[data-theme="light"] .m3-details-box {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .m3-details-box summary:hover { background: rgba(37, 99, 235, 0.04); }

[data-theme="light"] .m3-details-box--blue   { border-left-color: #2563eb; }
[data-theme="light"] .m3-details-box--green  { border-left-color: #059669; }
[data-theme="light"] .m3-details-box--purple { border-left-color: #7c3aed; }
[data-theme="light"] .m3-details-box--yellow { border-left-color: #ca8a04; }

/* Deep Dive — Visual Scenario Steps */
.m3-deep-scenario {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    border: 1px solid var(--border-color);
}

.m3-deep-scenario__step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.m3-deep-scenario__label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 85px;
    padding: 0.3rem 0.65rem;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    border: 1px solid;
    flex-shrink: 0;
}

.m3-deep-scenario__label--green  { background: rgba(110, 231, 183, 0.1); border-color: rgba(110, 231, 183, 0.25); color: #6ee7b7; }
.m3-deep-scenario__label--blue   { background: rgba(96, 165, 250, 0.1);  border-color: rgba(96, 165, 250, 0.25);  color: #60a5fa; }
.m3-deep-scenario__label--purple { background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.25); color: #a78bfa; }
.m3-deep-scenario__label--yellow { background: rgba(250, 204, 21, 0.1);  border-color: rgba(250, 204, 21, 0.25);  color: #facc15; }

[data-theme="light"] .m3-deep-scenario {
    background: #f8fafc;
}

[data-theme="light"] .m3-deep-scenario__label--green  { background: rgba(5, 150, 105, 0.06); border-color: rgba(5, 150, 105, 0.2); color: #059669; }
[data-theme="light"] .m3-deep-scenario__label--blue   { background: rgba(37, 99, 235, 0.06); border-color: rgba(37, 99, 235, 0.2); color: #2563eb; }
[data-theme="light"] .m3-deep-scenario__label--purple { background: rgba(124, 58, 237, 0.06); border-color: rgba(124, 58, 237, 0.2); color: #7c3aed; }
[data-theme="light"] .m3-deep-scenario__label--yellow { background: rgba(202, 138, 4, 0.06); border-color: rgba(202, 138, 4, 0.2); color: #b45309; }

.m3-deep-scenario__desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.m3-deep-scenario__arrow {
    width: 85px;
    text-align: center;
    color: var(--accent-primary);
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
    opacity: 0.5;
}

/* Deep Dive — Comparison Table */
.m3-deep-comparison {
    margin: 1.25rem 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.m3-deep-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.m3-deep-table th {
    background: var(--bg-tertiary);
    padding: 0.75rem 0.85rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.m3-deep-table th:first-child {
    width: 130px;
}

.m3-deep-table td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: top;
}

.m3-deep-table td:first-child {
    color: var(--text-primary);
}

.m3-deep-table tbody tr:last-child td {
    border-bottom: none;
}

.m3-deep-table tbody tr:hover {
    background: rgba(122, 162, 255, 0.03);
}

[data-theme="light"] .m3-deep-table th {
    background: #f1f5f9;
}

[data-theme="light"] .m3-deep-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

/* =============================
   6. MANIPULATION — API Cards + Dataset Flow
   ============================= */
.m3-api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.m3-api-card {
    padding: 1rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.m3-api-card__header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.m3-api-card__header code {
    font-size: 0.85rem;
    font-weight: 600;
}

.m3-api-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.m3-api-card--green  { border-left: 3px solid #6ee7b7; }
.m3-api-card--yellow { border-left: 3px solid #facc15; }
.m3-api-card--red    { border-left: 3px solid #f87171; }

[data-theme="light"] .m3-api-card--green  { border-left-color: #059669; }
[data-theme="light"] .m3-api-card--yellow { border-left-color: #ca8a04; }
[data-theme="light"] .m3-api-card--red    { border-left-color: #dc2626; }

/* Dataset Flow */
.m3-dataset-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.25rem 0;
    flex-wrap: wrap;
}

.m3-dataset-box {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    text-align: center;
}

.m3-dataset-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 0.35rem;
}

.m3-dataset-arrow {
    font-size: 1.5rem;
    color: var(--accent-primary);
}

.m3-dataset-ops {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.m3-op-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
}

.m3-op-label {
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.m3-op-box--green .m3-op-label { color: #6ee7b7; }
.m3-op-box--blue  .m3-op-label { color: #60a5fa; }
.m3-op-box--red   .m3-op-label { color: #f87171; }

[data-theme="light"] .m3-op-box--green .m3-op-label { color: #059669; }
[data-theme="light"] .m3-op-box--blue  .m3-op-label { color: #2563eb; }
[data-theme="light"] .m3-op-box--red   .m3-op-label { color: #dc2626; }

/* =============================
   7. CREATION — Methods Grid + Adjacent Diagram + Keypoints
   ============================= */
.m3-methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.m3-method-box {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.m3-method-label {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15em 0.45em;
    border-radius: 3px;
    margin-bottom: 0.35rem;
}

.m3-method-box--green  .m3-method-label { background: rgba(110, 231, 183, 0.15); color: #6ee7b7; }
.m3-method-box--blue   .m3-method-label { background: rgba(96, 165, 250, 0.15);  color: #60a5fa; }
.m3-method-box--purple .m3-method-label { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.m3-method-box--orange .m3-method-label { background: rgba(249, 115, 22, 0.15);  color: #f97316; }

[data-theme="light"] .m3-method-box--green  .m3-method-label { background: rgba(5, 150, 105, 0.1); color: #059669; }
[data-theme="light"] .m3-method-box--blue   .m3-method-label { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
[data-theme="light"] .m3-method-box--purple .m3-method-label { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
[data-theme="light"] .m3-method-box--orange .m3-method-label { background: rgba(234, 88, 12, 0.1);  color: #ea580c; }

.m3-method-box code { font-size: 0.78rem; }

/* insertAdjacentHTML Diagram */
.m3-adjacent-diagram {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin: 1rem 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

.m3-adjacent-container {
    border: 2px dashed var(--border-hover);
    border-radius: 6px;
    padding: 0.5rem 0;
    margin: 0.5rem 0;
}

.m3-adjacent-tag {
    color: var(--text-tertiary);
    padding: 0.15rem 0.5rem;
}

.m3-adjacent-content {
    color: var(--text-tertiary);
    padding: 0.15rem 0.5rem;
    font-style: italic;
}

.m3-adjacent-indent {
    padding-left: 1.5rem;
}

.m3-adjacent-line {
    padding: 0.2rem 0.5rem;
    margin: 0.15rem 0;
}

.m3-adjacent-line--orange { color: #f97316; }
.m3-adjacent-line--green  { color: #6ee7b7; }
.m3-adjacent-line--blue   { color: #60a5fa; }
.m3-adjacent-line--purple { color: #a78bfa; }

[data-theme="light"] .m3-adjacent-line--orange { color: #ea580c; }
[data-theme="light"] .m3-adjacent-line--green  { color: #059669; }
[data-theme="light"] .m3-adjacent-line--blue   { color: #2563eb; }
[data-theme="light"] .m3-adjacent-line--purple { color: #7c3aed; }

/* Keypoints */
.m3-keypoints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1rem 0;
}

.m3-keypoint {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.82rem;
    background: rgba(122, 162, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid rgba(122, 162, 255, 0.15);
}

[data-theme="light"] .m3-keypoint {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.12);
}

/* =============================
   8. TRAVERSAL — Visual Tree
   ============================= */
.m3-tree-visual {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin: 1.25rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.m3-tree-level { text-align: center; }

.m3-tree-node {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    border: 2px solid;
}

.m3-tree-node--parent   { background: rgba(167, 139, 250, 0.15); border-color: #a78bfa; color: #a78bfa; }
.m3-tree-node--first    { background: rgba(110, 231, 183, 0.12); border-color: #6ee7b7; color: #6ee7b7; }
.m3-tree-node--selected { background: rgba(96, 165, 250, 0.12);  border-color: #60a5fa; color: #60a5fa; }
.m3-tree-node--last     { background: rgba(248, 113, 113, 0.12); border-color: #f87171; color: #f87171; }

[data-theme="light"] .m3-tree-node--parent   { background: rgba(124, 58, 237, 0.08); border-color: #7c3aed; color: #7c3aed; }
[data-theme="light"] .m3-tree-node--first    { background: rgba(5, 150, 105, 0.08);  border-color: #059669; color: #059669; }
[data-theme="light"] .m3-tree-node--selected { background: rgba(37, 99, 235, 0.08);  border-color: #2563eb; color: #2563eb; }
[data-theme="light"] .m3-tree-node--last     { background: rgba(220, 38, 38, 0.08);  border-color: #dc2626; color: #dc2626; }

.m3-tree-arrow-down,
.m3-tree-arrow-up {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.82rem;
}

.m3-tree-arrow-down span,
.m3-tree-arrow-up span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    margin-left: 0.3rem;
}

.m3-tree-children {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.m3-tree-child-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.m3-tree-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    min-width: 130px;
    text-align: right;
}

.m3-tree-label--green  { color: #6ee7b7; }
.m3-tree-label--yellow { color: #facc15; }
.m3-tree-label--red    { color: #f87171; }

[data-theme="light"] .m3-tree-label--green  { color: #059669; }
[data-theme="light"] .m3-tree-label--yellow { color: #b45309; }
[data-theme="light"] .m3-tree-label--red    { color: #dc2626; }

.m3-tree-sibling-arrow {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}

.m3-tree-pipe { color: var(--border-hover); }

/* =============================
   9. SCRIPT LOADING — Timeline
   ============================= */
.m3-timeline-demo {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin: 1.25rem 0;
}

.m3-scenario-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.m3-scenario-btn {
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.m3-scenario-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.m3-scenario-btn.active {
    background: var(--accent-primary);
    color: #0f1220;
    border-color: var(--accent-primary);
    font-weight: 700;
}

[data-theme="light"] .m3-scenario-btn.active {
    color: #fff;
}

/* Timeline rows */
.m3-timeline-visual {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.m3-timeline-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.m3-row-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    min-width: 48px;
    text-transform: uppercase;
}

.m3-timeline-bar {
    flex: 1;
    height: 28px;
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    position: relative;
}

[data-theme="light"] .m3-timeline-bar {
    background: rgba(0, 0, 0, 0.03);
}

.m3-bar-seg {
    height: 100%;
    transition: width 0.4s ease, left 0.4s ease;
    border-radius: 2px;
}

/* First row segments (flex) */
.m3-bar-seg--html    { background: #60a5fa; }
.m3-bar-seg--blocked { background: #f87171; opacity: 0.7; }

/* Second row segments (absolute position) */
.m3-timeline-row:nth-child(2) .m3-timeline-bar {
    position: relative;
}

.m3-timeline-row:nth-child(2) .m3-bar-seg {
    position: absolute;
    top: 0;
}

.m3-bar-seg--download { background: #facc15; }
.m3-bar-seg--execute  { background: #6ee7b7; }

[data-theme="light"] .m3-bar-seg--html    { background: #3b82f6; }
[data-theme="light"] .m3-bar-seg--blocked { background: #ef4444; }
[data-theme="light"] .m3-bar-seg--download { background: #eab308; }
[data-theme="light"] .m3-bar-seg--execute  { background: #10b981; }

/* Legend */
.m3-timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
}

.m3-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.m3-legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.m3-legend-color--html     { background: #60a5fa; }
.m3-legend-color--blocked  { background: #f87171; }
.m3-legend-color--download { background: #facc15; }
.m3-legend-color--execute  { background: #6ee7b7; }

[data-theme="light"] .m3-legend-color--html     { background: #3b82f6; }
[data-theme="light"] .m3-legend-color--blocked  { background: #ef4444; }
[data-theme="light"] .m3-legend-color--download { background: #eab308; }
[data-theme="light"] .m3-legend-color--execute  { background: #10b981; }

.m3-scenario-explanation {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.m3-scenario-explanation p { margin: 0; }

/* =============================
   10. EVENTS — Tabbed Hub
   ============================= */
.m3-event-hub {
    margin: 1rem 0;
}

.m3-event-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
    margin-bottom: 0;
}

.m3-event-tab {
    padding: 0.55rem 1rem;
    border: none;
    background: none;
    color: var(--text-tertiary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.m3-event-tab:hover { color: var(--text-primary); }

.m3-event-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.m3-event-panel {
    display: none;
    padding: 1.25rem 0 0;
}

.m3-event-panel.active { display: block; }

.m3-event-panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.m3-event-panel h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem;
}

.m3-event-panel p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 0.75rem;
}

/* Event flow steps (Basics tab) */
.m3-event-flow-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.25rem 0;
    flex-wrap: wrap;
}

.m3-flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.75rem 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid;
    text-align: center;
    min-width: 100px;
}

.m3-flow-step__icon { font-size: 1.3rem; }
.m3-flow-step__label { font-size: 0.78rem; font-weight: 600; }

.m3-flow-step--blue   { border-color: rgba(96, 165, 250, 0.3);  background: rgba(96, 165, 250, 0.08);  color: #60a5fa; }
.m3-flow-step--purple { border-color: rgba(167, 139, 250, 0.3); background: rgba(167, 139, 250, 0.08); color: #a78bfa; }
.m3-flow-step--green  { border-color: rgba(110, 231, 183, 0.3); background: rgba(110, 231, 183, 0.08); color: #6ee7b7; }

[data-theme="light"] .m3-flow-step--blue   { border-color: rgba(37, 99, 235, 0.25); background: rgba(37, 99, 235, 0.06); color: #2563eb; }
[data-theme="light"] .m3-flow-step--purple { border-color: rgba(124, 58, 237, 0.25); background: rgba(124, 58, 237, 0.06); color: #7c3aed; }
[data-theme="light"] .m3-flow-step--green  { border-color: rgba(5, 150, 105, 0.25); background: rgba(5, 150, 105, 0.06); color: #059669; }

.m3-flow-arrow {
    font-size: 1.2rem;
    color: var(--text-tertiary);
}

/* Event types (Types tab) */
.m3-event-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.m3-event-category {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.m3-event-category h4 {
    font-size: 0.88rem;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.m3-event-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.m3-event-tag {
    display: inline-block;
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    background: rgba(122, 162, 255, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(122, 162, 255, 0.15);
}

.m3-event-tag--deprecated {
    background: rgba(248, 113, 113, 0.08);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.15);
    text-decoration: line-through;
}

[data-theme="light"] .m3-event-tag {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.15);
    color: #2563eb;
}

[data-theme="light"] .m3-event-tag--deprecated {
    background: rgba(220, 38, 38, 0.06);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.15);
}

/* Event object properties (Object tab) */
.m3-evt-props-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.m3-evt-prop {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.m3-evt-prop code {
    font-size: 0.78rem;
    white-space: nowrap;
}

.m3-evt-prop span {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Event flow diagram (Flow tab) */
.m3-flow-diagram {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.m3-flow-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 2px solid;
    text-align: center;
}

.m3-phase-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
}

.m3-phase-name {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.m3-phase-dir {
    font-size: 1.1rem;
}

.m3-flow-phase p {
    font-size: 0.78rem;
    margin: 0;
    line-height: 1.4;
}

.m3-flow-phase--capture {
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(96, 165, 250, 0.06);
    color: #60a5fa;
}

.m3-flow-phase--capture .m3-phase-num {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

.m3-flow-phase--target {
    border-color: rgba(250, 204, 21, 0.4);
    background: rgba(250, 204, 21, 0.06);
    color: #facc15;
}

.m3-flow-phase--target .m3-phase-num {
    background: rgba(250, 204, 21, 0.2);
    color: #facc15;
}

.m3-flow-phase--bubble {
    border-color: rgba(110, 231, 183, 0.4);
    background: rgba(110, 231, 183, 0.06);
    color: #6ee7b7;
}

.m3-flow-phase--bubble .m3-phase-num {
    background: rgba(110, 231, 183, 0.2);
    color: #6ee7b7;
}

[data-theme="light"] .m3-flow-phase--capture { border-color: rgba(37, 99, 235, 0.35); background: rgba(37, 99, 235, 0.04); color: #2563eb; }
[data-theme="light"] .m3-flow-phase--capture .m3-phase-num { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
[data-theme="light"] .m3-flow-phase--target  { border-color: rgba(202, 138, 4, 0.35); background: rgba(202, 138, 4, 0.04); color: #b45309; }
[data-theme="light"] .m3-flow-phase--target  .m3-phase-num { background: rgba(202, 138, 4, 0.12); color: #b45309; }
[data-theme="light"] .m3-flow-phase--bubble  { border-color: rgba(5, 150, 105, 0.35); background: rgba(5, 150, 105, 0.04); color: #059669; }
[data-theme="light"] .m3-flow-phase--bubble  .m3-phase-num { background: rgba(5, 150, 105, 0.12); color: #059669; }

.m3-flow-phase--capture p,
.m3-flow-phase--target p,
.m3-flow-phase--bubble p {
    color: var(--text-secondary);
}

/* Delegation benefits */
.m3-benefits {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1rem 0;
}

.m3-benefit {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(110, 231, 183, 0.1);
    color: #6ee7b7;
    border: 1px solid rgba(110, 231, 183, 0.2);
}

[data-theme="light"] .m3-benefit {
    background: rgba(5, 150, 105, 0.08);
    color: #059669;
    border-color: rgba(5, 150, 105, 0.2);
}

/* =============================
   11. AJAX — XHR Flow + Events + Evolution Tabs
   ============================= */
.m3-xhr-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1.25rem 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.m3-xhr-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    border: 1px solid;
    text-align: center;
    min-width: 85px;
    flex-shrink: 0;
}

.m3-xhr-step-label {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
}

.m3-xhr-step strong { font-size: 0.78rem; }
.m3-xhr-step code   { font-size: 0.68rem; }

.m3-xhr-step--green  { border-color: rgba(110, 231, 183, 0.35); background: rgba(110, 231, 183, 0.06); color: #6ee7b7; }
.m3-xhr-step--green  .m3-xhr-step-label { background: rgba(110, 231, 183, 0.2); }
.m3-xhr-step--blue   { border-color: rgba(96, 165, 250, 0.35); background: rgba(96, 165, 250, 0.06); color: #60a5fa; }
.m3-xhr-step--blue   .m3-xhr-step-label { background: rgba(96, 165, 250, 0.2); }
.m3-xhr-step--purple { border-color: rgba(167, 139, 250, 0.35); background: rgba(167, 139, 250, 0.06); color: #a78bfa; }
.m3-xhr-step--purple .m3-xhr-step-label { background: rgba(167, 139, 250, 0.2); }
.m3-xhr-step--pink   { border-color: rgba(244, 114, 182, 0.35); background: rgba(244, 114, 182, 0.06); color: #f472b6; }
.m3-xhr-step--pink   .m3-xhr-step-label { background: rgba(244, 114, 182, 0.2); }
.m3-xhr-step--orange { border-color: rgba(249, 115, 22, 0.35); background: rgba(249, 115, 22, 0.06); color: #f97316; }
.m3-xhr-step--orange .m3-xhr-step-label { background: rgba(249, 115, 22, 0.2); }

[data-theme="light"] .m3-xhr-step--green  { border-color: rgba(5, 150, 105, 0.3); background: rgba(5, 150, 105, 0.04); color: #059669; }
[data-theme="light"] .m3-xhr-step--blue   { border-color: rgba(37, 99, 235, 0.3); background: rgba(37, 99, 235, 0.04); color: #2563eb; }
[data-theme="light"] .m3-xhr-step--purple { border-color: rgba(124, 58, 237, 0.3); background: rgba(124, 58, 237, 0.04); color: #7c3aed; }
[data-theme="light"] .m3-xhr-step--pink   { border-color: rgba(219, 39, 119, 0.3); background: rgba(219, 39, 119, 0.04); color: #db2777; }
[data-theme="light"] .m3-xhr-step--orange { border-color: rgba(234, 88, 12, 0.3);  background: rgba(234, 88, 12, 0.04);  color: #ea580c; }

[data-theme="light"] .m3-xhr-step--green  .m3-xhr-step-label { background: rgba(5, 150, 105, 0.15); }
[data-theme="light"] .m3-xhr-step--blue   .m3-xhr-step-label { background: rgba(37, 99, 235, 0.15); }
[data-theme="light"] .m3-xhr-step--purple .m3-xhr-step-label { background: rgba(124, 58, 237, 0.15); }
[data-theme="light"] .m3-xhr-step--pink   .m3-xhr-step-label { background: rgba(219, 39, 119, 0.15); }
[data-theme="light"] .m3-xhr-step--orange .m3-xhr-step-label { background: rgba(234, 88, 12, 0.15); }

.m3-xhr-arrow {
    font-size: 1rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

/* XHR Events badges */
.m3-xhr-events {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.m3-xhr-event {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid;
}

.m3-xhr-event--green  { background: rgba(110, 231, 183, 0.1); border-color: rgba(110, 231, 183, 0.25); color: #6ee7b7; }
.m3-xhr-event--red    { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.25); color: #f87171; }
.m3-xhr-event--blue   { background: rgba(96, 165, 250, 0.1);  border-color: rgba(96, 165, 250, 0.25);  color: #60a5fa; }
.m3-xhr-event--purple { background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.25); color: #a78bfa; }
.m3-xhr-event--yellow { background: rgba(250, 204, 21, 0.1);  border-color: rgba(250, 204, 21, 0.25);  color: #facc15; }
.m3-xhr-event--gray   { background: rgba(148, 163, 184, 0.1); border-color: rgba(148, 163, 184, 0.25); color: #94a3b8; }

[data-theme="light"] .m3-xhr-event--green  { background: rgba(5, 150, 105, 0.06); border-color: rgba(5, 150, 105, 0.2); color: #059669; }
[data-theme="light"] .m3-xhr-event--red    { background: rgba(220, 38, 38, 0.06); border-color: rgba(220, 38, 38, 0.2); color: #dc2626; }
[data-theme="light"] .m3-xhr-event--blue   { background: rgba(37, 99, 235, 0.06); border-color: rgba(37, 99, 235, 0.2); color: #2563eb; }
[data-theme="light"] .m3-xhr-event--purple { background: rgba(124, 58, 237, 0.06); border-color: rgba(124, 58, 237, 0.2); color: #7c3aed; }
[data-theme="light"] .m3-xhr-event--yellow { background: rgba(202, 138, 4, 0.06);  border-color: rgba(202, 138, 4, 0.2);  color: #b45309; }
[data-theme="light"] .m3-xhr-event--gray   { background: rgba(100, 116, 139, 0.06); border-color: rgba(100, 116, 139, 0.2); color: #64748b; }

/* Evolution Tabs */
.m3-evo-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border-bottom: 2px solid var(--border-color);
    margin-top: 1.25rem;
    margin-bottom: 0;
}

.m3-evo-tab {
    padding: 0.5rem 0.85rem;
    border: none;
    background: none;
    color: var(--text-tertiary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.m3-evo-tab:hover { color: var(--text-primary); }

.m3-evo-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.m3-evo-panel {
    display: none;
    padding: 1rem 0 0;
}

.m3-evo-panel.active { display: block; }

.m3-evo-verdict {
    padding: 0.65rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    border-left: 4px solid;
}

.m3-evo-verdict--bad  { background: rgba(248, 113, 113, 0.08); border-color: #f87171; color: #f87171; }
.m3-evo-verdict--ok   { background: rgba(250, 204, 21, 0.08);  border-color: #facc15; color: #facc15; }
.m3-evo-verdict--good { background: rgba(110, 231, 183, 0.08); border-color: #6ee7b7; color: #6ee7b7; }
.m3-evo-verdict--best { background: rgba(96, 165, 250, 0.08);  border-color: #60a5fa; color: #60a5fa; }

[data-theme="light"] .m3-evo-verdict--bad  { background: rgba(220, 38, 38, 0.05); border-color: #dc2626; color: #dc2626; }
[data-theme="light"] .m3-evo-verdict--ok   { background: rgba(202, 138, 4, 0.05);  border-color: #b45309; color: #b45309; }
[data-theme="light"] .m3-evo-verdict--good { background: rgba(5, 150, 105, 0.05);  border-color: #059669; color: #059669; }
[data-theme="light"] .m3-evo-verdict--best { background: rgba(37, 99, 235, 0.05);  border-color: #2563eb; color: #2563eb; }

/* Evolution Summary */
.m3-evo-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.m3-evo-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.m3-evo-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.m3-evo-item strong {
    display: block;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

/* =============================
   12. COMPARISON GRID — 3-column variant
   ============================= */
.comparison-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

/* =============================
   12b. LIGHT MODE — Card / Container backgrounds
   All components using --bg-tertiary → white in light mode
   ============================= */
[data-theme="light"] .m3-prop-card,
[data-theme="light"] .m3-ref-card,
[data-theme="light"] .m3-nav-box,
[data-theme="light"] .m3-api-card,
[data-theme="light"] .m3-dataset-box,
[data-theme="light"] .m3-op-box,
[data-theme="light"] .m3-method-box,
[data-theme="light"] .m3-select-row,
[data-theme="light"] .m3-evt-prop,
[data-theme="light"] .m3-event-category,
[data-theme="light"] .m3-evo-item {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .m3-dom-tree,
[data-theme="light"] .m3-adjacent-diagram,
[data-theme="light"] .m3-tree-visual,
[data-theme="light"] .m3-timeline-demo,
[data-theme="light"] .m3-xhr-flow {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .m3-scenario-btn {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .m3-scenario-explanation {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.08);
}

/* =============================
   13. RESPONSIVE — Mobile Fixes
   ============================= */
@media (max-width: 768px) {
    .m3-cta-box {
        flex-direction: column;
        text-align: center;
    }

    .m3-xhr-flow {
        justify-content: center;
    }

    .m3-flow-diagram {
        grid-template-columns: 1fr;
    }

    .m3-flow-phase {
        flex-direction: row;
        text-align: left;
        gap: 0.75rem;
    }

    .m3-tree-child-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .m3-tree-label {
        text-align: center;
        min-width: unset;
    }

    .comparison-grid--3 {
        grid-template-columns: 1fr;
    }

    .m3-event-tabs,
    .m3-evo-tabs {
        gap: 0;
    }

    .m3-event-tab,
    .m3-evo-tab {
        padding: 0.45rem 0.6rem;
        font-size: 0.72rem;
    }

    .m3-evt-props-grid {
        grid-template-columns: 1fr;
    }

    .m3-evo-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .m3-topics-grid {
        gap: 0.4rem;
    }

    .m3-topic {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .m3-props-grid,
    .m3-ref-grid,
    .m3-nav-grid,
    .m3-api-grid,
    .m3-methods-grid,
    .m3-event-categories {
        grid-template-columns: 1fr;
    }

    .m3-select-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .m3-select-row > span:not(.m3-badge) {
        min-width: unset;
    }

    .m3-xhr-step {
        min-width: 70px;
        padding: 0.45rem 0.55rem;
    }

    .m3-xhr-step code { font-size: 0.6rem; }

    .m3-event-flow-steps {
        flex-direction: column;
    }

    .m3-flow-arrow {
        transform: rotate(90deg);
    }

    .m3-dataset-flow {
        flex-direction: column;
    }

    .m3-dataset-arrow {
        transform: rotate(90deg);
    }
}

/* =============================
   NEW: Capture Phase Explanation
   ============================= */
.m3-capture-explanation {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-tertiary, #1a1f36);
    border-radius: var(--radius, 14px);
    border: 1px solid var(--border-color, #2a2f4a);
}

.m3-capture-explanation h4 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    color: var(--text-primary, #e8ecff);
}

.m3-capture-explanation > p {
    margin: 0 0 1rem;
    color: var(--text-secondary, #8b92b0);
    line-height: 1.6;
}

.m3-capture-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0;
}

.m3-capture-box {
    padding: 1rem;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.m3-capture-box__title {
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.m3-capture-box p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #8b92b0);
    line-height: 1.5;
}

[data-theme="light"] .m3-capture-explanation {
    background: #f0f4ff;
    border-color: #c7d2fe;
}

[data-theme="light"] .m3-capture-box {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.15);
}

[data-theme="light"] .m3-capture-box__title { color: #2563eb; }

/* =============================
   NEW: Event Flow Interactive Demo
   ============================= */
.m3-flow-demo {
    margin: 1.25rem 0 0;
    padding: 1.25rem;
    background: var(--bg-tertiary, #1a1f36);
    border-radius: var(--radius, 14px);
    border: 1px solid var(--border-color, #2a2f4a);
}

.m3-flow-demo__boxes {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.m3-flow-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
    text-align: center;
}

.m3-flow-box:hover { transform: scale(1.02); }

.m3-flow-box--outer {
    background: rgba(34, 197, 94, 0.12);
    border: 2px solid rgba(34, 197, 94, 0.5);
    color: #22c55e;
    padding: 1.5rem;
}

.m3-flow-box--middle {
    background: rgba(59, 130, 246, 0.12);
    border: 2px solid rgba(59, 130, 246, 0.5);
    color: #3b82f6;
    padding: 1.25rem;
    margin-top: 0.75rem;
}

.m3-flow-box--inner {
    background: rgba(168, 85, 247, 0.12);
    border: 2px solid rgba(168, 85, 247, 0.5);
    color: #a855f7;
    padding: 1rem 1.5rem;
    margin-top: 0.75rem;
}

.m3-flow-box--flash {
    animation: m3-flash 0.4s ease;
}

@keyframes m3-flash {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 20px rgba(96, 165, 250, 0.6); }
}

.m3-flow-demo__output {
    background: var(--code-bg, #0b0e1a);
    border: 1px solid var(--border-color, #2a2f4a);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 80px;
    max-height: 160px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.m3-flow-demo__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.m3-flow-demo__label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #8b92b0);
    cursor: pointer;
}

.m3-flow-demo__label input[type="checkbox"] {
    accent-color: var(--accent-primary, #7aa2ff);
    width: 16px;
    height: 16px;
}

.m3-flow-demo__clear {
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, #2a2f4a);
    background: transparent;
    color: var(--text-secondary, #8b92b0);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.m3-flow-demo__clear:hover {
    background: rgba(255,255,255,0.05);
}

.m3-flow-demo__explanation {
    font-size: 0.82rem;
    color: var(--text-secondary, #8b92b0);
    padding: 0.6rem 0.85rem;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 8px;
    border-left: 3px solid #ef4444;
}

[data-theme="light"] .m3-flow-demo {
    background: #f0f4ff;
    border-color: #c7d2fe;
}

[data-theme="light"] .m3-flow-demo__output {
    background: #f8f9fb;
    border-color: #d1d5db;
}

[data-theme="light"] .m3-flow-box--outer { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.4); }
[data-theme="light"] .m3-flow-box--middle { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.4); }
[data-theme="light"] .m3-flow-box--inner { background: rgba(168, 85, 247, 0.08); border-color: rgba(168, 85, 247, 0.4); }

/* =============================
   NEW: Interactive Insertion Playground
   ============================= */
.m3-insert-playground {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--bg-tertiary, #1a1f36);
    border-radius: var(--radius, 14px);
    border: 1px solid var(--border-color, #2a2f4a);
}

.m3-insert-playground__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.m3-insert-playground__subtitle {
    font-weight: 600;
    color: var(--text-primary, #e8ecff);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.m3-insert-method-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.m3-insert-method-btn {
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, #2a2f4a);
    background: transparent;
    color: var(--text-secondary, #8b92b0);
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.2s;
}

.m3-insert-method-btn:hover {
    border-color: var(--accent-primary, #7aa2ff);
    color: var(--accent-primary, #7aa2ff);
}

.m3-insert-method-btn.active {
    background: var(--accent-primary, #7aa2ff);
    color: #fff;
    border-color: var(--accent-primary, #7aa2ff);
}

.m3-insert-method-btn--prepend.active   { background: #22c55e; border-color: #22c55e; }
.m3-insert-method-btn--append.active    { background: #3b82f6; border-color: #3b82f6; }
.m3-insert-method-btn--beforebegin.active { background: #f97316; border-color: #f97316; }
.m3-insert-method-btn--afterbegin.active  { background: #22c55e; border-color: #22c55e; }
.m3-insert-method-btn--beforeend.active   { background: #3b82f6; border-color: #3b82f6; }
.m3-insert-method-btn--afterend.active    { background: #a855f7; border-color: #a855f7; }

.m3-insert-input-group {
    margin-bottom: 0.75rem;
}

.m3-insert-input-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary, #8b92b0);
    margin-bottom: 0.35rem;
}

.m3-insert-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, #2a2f4a);
    background: var(--code-bg, #0b0e1a);
    color: var(--text-primary, #e8ecff);
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    box-sizing: border-box;
}

.m3-insert-input:focus {
    outline: none;
    border-color: var(--accent-primary, #7aa2ff);
    box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.15);
}

.m3-insert-action-btns {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.m3-insert-action-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

.m3-insert-action-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.m3-insert-action-btn--insert { background: var(--accent-primary, #7aa2ff); color: #fff; }
.m3-insert-action-btn--reset  { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

.m3-insert-code-preview {
    background: var(--code-bg, #0b0e1a);
    border-radius: 8px;
    border: 1px solid var(--border-color, #2a2f4a);
    padding: 0.75rem;
}

.m3-insert-code-preview__label {
    font-size: 0.75rem;
    color: var(--text-secondary, #8b92b0);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.m3-insert-code-preview__code {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.5;
}

.m3-insert-code-preview__code code {
    color: var(--text-primary, #e8ecff);
    font-family: 'JetBrains Mono', monospace;
}

/* Container and zones */
.m3-insert-container {
    background: var(--code-bg, #0b0e1a);
    border: 2px solid var(--accent-primary, #7aa2ff);
    border-radius: 10px;
    padding: 0.75rem;
    min-height: 200px;
}

.m3-insert-zone {
    min-height: 24px;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    margin: 0.35rem 0;
    border: 1px dashed;
    transition: background 0.3s;
}

.m3-insert-zone--beforebegin { border-color: rgba(249, 115, 22, 0.4); background: rgba(249, 115, 22, 0.05); }
.m3-insert-zone--afterbegin  { border-color: rgba(34, 197, 94, 0.4);  background: rgba(34, 197, 94, 0.05);  }
.m3-insert-zone--beforeend   { border-color: rgba(59, 130, 246, 0.4); background: rgba(59, 130, 246, 0.05); }
.m3-insert-zone--afterend    { border-color: rgba(168, 85, 247, 0.4); background: rgba(168, 85, 247, 0.05); }

.m3-insert-zone--flash {
    animation: m3-zone-flash 0.6s ease;
}

@keyframes m3-zone-flash {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: inset 0 0 15px rgba(122, 162, 255, 0.3); }
}

.m3-insert-zone__label {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.7;
}

.m3-insert-zone__label--orange { color: #f97316; }
.m3-insert-zone__label--green  { color: #22c55e; }
.m3-insert-zone__label--blue   { color: #60a5fa; }
.m3-insert-zone__label--purple { color: #a855f7; }
.m3-insert-zone__label--accent { color: var(--accent-primary, #7aa2ff); font-size: 0.8rem; margin-bottom: 0.4rem; display: block; }

.m3-insert-original {
    padding: 0.5rem 0.75rem;
    margin: 0.3rem 0;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 6px;
    font-size: 0.82rem;
    color: #60a5fa;
}

.m3-insert-new-item {
    padding: 0.5rem 0.75rem;
    margin: 0.3rem 0;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 6px;
    font-size: 0.82rem;
    color: #22c55e;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.m3-insert-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-secondary, #8b92b0);
}

[data-theme="light"] .m3-insert-playground {
    background: #f0f4ff;
    border-color: #c7d2fe;
}

[data-theme="light"] .m3-insert-input {
    background: #f8f9fb;
    border-color: #d1d5db;
    color: #1e293b;
}

[data-theme="light"] .m3-insert-container {
    background: #f8f9fb;
    border-color: #3b82f6;
}

[data-theme="light"] .m3-insert-code-preview {
    background: #f8f9fb;
    border-color: #d1d5db;
}

/* =============================
   NEW: Sync Warning Box
   ============================= */
.m3-sync-warning {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    margin-bottom: 1rem;
    align-items: flex-start;
}

.m3-sync-warning__icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
}

.m3-sync-warning__content {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary, #8b92b0);
}

.m3-sync-warning__content strong {
    color: #ef4444;
    display: block;
    margin-bottom: 0.25rem;
}

[data-theme="light"] .m3-sync-warning {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
}

/* =============================
   NEW: AJAX Live Playground
   ============================= */
.m3-ajax-playground {
    margin: 1.25rem 0;
    padding: 1.25rem;
    background: var(--bg-tertiary, #1a1f36);
    border-radius: var(--radius, 14px);
    border: 1px solid var(--border-color, #2a2f4a);
}

.m3-ajax-playground__header {
    margin-bottom: 1rem;
}

.m3-ajax-playground__results {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

.m3-ajax-result-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary, #8b92b0);
}

.m3-ajax-result-item--main {
    color: var(--accent-primary, #7aa2ff);
    font-weight: 700;
    font-size: 1rem;
}

.m3-ajax-result-label {
    opacity: 0.7;
}

.m3-ajax-playground__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.m3-ajax-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 1px solid;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    background: transparent;
}

.m3-ajax-btn:hover:not(:disabled) { opacity: 0.85; transform: translateY(-1px); }
.m3-ajax-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.m3-ajax-btn--red    { color: #ef4444; border-color: rgba(239, 68, 68, 0.4);  background: rgba(239, 68, 68, 0.08);  }
.m3-ajax-btn--yellow { color: #fbbf24; border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.m3-ajax-btn--green  { color: #22c55e; border-color: rgba(34, 197, 94, 0.4);  background: rgba(34, 197, 94, 0.08);  }
.m3-ajax-btn--purple { color: #a855f7; border-color: rgba(168, 85, 247, 0.4); background: rgba(168, 85, 247, 0.08); }

.m3-ajax-btn__icon { font-size: 1rem; }

.m3-ajax-playground__log {
    background: var(--code-bg, #0b0e1a);
    border: 1px solid var(--border-color, #2a2f4a);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-secondary, #8b92b0);
}

[data-theme="light"] .m3-ajax-playground {
    background: #f0f4ff;
    border-color: #c7d2fe;
}

[data-theme="light"] .m3-ajax-playground__log {
    background: #f8f9fb;
    border-color: #d1d5db;
}

[data-theme="light"] .m3-ajax-btn--red    { background: rgba(239, 68, 68, 0.05); }
[data-theme="light"] .m3-ajax-btn--yellow { background: rgba(251, 191, 36, 0.05); }
[data-theme="light"] .m3-ajax-btn--green  { background: rgba(34, 197, 94, 0.05); }
[data-theme="light"] .m3-ajax-btn--purple { background: rgba(168, 85, 247, 0.05); }

/* =============================
   RESPONSIVE: New Components
   ============================= */
@media (max-width: 768px) {
    .m3-insert-playground__grid {
        grid-template-columns: 1fr;
    }

    .m3-capture-boxes {
        grid-template-columns: 1fr;
    }

    .m3-flow-demo__controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .m3-ajax-playground__buttons {
        flex-direction: column;
    }

    .m3-ajax-btn {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .m3-insert-method-btns {
        flex-direction: column;
    }

    .m3-insert-action-btns {
        flex-direction: column;
    }

    .m3-ajax-playground__results {
        flex-direction: column;
        align-items: flex-start;
    }
}
