* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: #1a1a2e;
    color: #eee;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}

a { color: #5fa6a6; }

/* Demo toolbar (matches other demos) */
.demo-toolbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(26,26,46,0.95);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.demo-toolbar a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #5fa6a6; font-size: 1rem; }
.demo-toolbar .logo { height: 32px; }
.demo-toolbar .brand-wf { font-weight: 520; }
.demo-toolbar .brand-js { font-weight: 700; }
.demo-toolbar .demo-info { font-size: 11px; color: rgba(255,255,255,0.6); text-align: right; }
.demo-toolbar .demo-info strong { color: rgba(255,255,255,0.9); }

/* Page layout */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 72px 24px 64px;
}

.intro {
    border: 1px solid rgba(95,166,166,0.25);
    background: linear-gradient(180deg, rgba(95,166,166,0.06), transparent);
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 32px;
}

.intro h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    color: #5fa6a6;
}

.intro p {
    margin: 0;
    color: rgba(255,255,255,0.75);
    font-size: 0.95rem;
}

.intro .badges {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.intro .badge {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(95,166,166,0.15);
    color: #7cc4c4;
    border: 1px solid rgba(95,166,166,0.3);
}

/* Zone */
.zone {
    background: #16213e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 28px;
}

.zone-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}

.zone-num {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #df9058;
    font-weight: 600;
}

.zone h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #eee;
}

.zone .subtitle {
    color: rgba(255,255,255,0.55);
    font-size: 0.9rem;
    margin: 0 0 18px;
}

.zone .lab-area {
    background: rgba(0,0,0,0.25);
    border: 1px dashed rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 12px;
}

.zone .controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

button {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #5fa6a6;
    color: #1a1a2e;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}
button:hover { background: #7cc4c4; }
button.secondary {
    background: rgba(255,255,255,0.08);
    color: #eee;
    border: 1px solid rgba(255,255,255,0.15);
}
button.secondary:hover { background: rgba(255,255,255,0.14); }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
}
.checkbox-row input { width: 16px; height: 16px; cursor: pointer; }

/* Zone 1 specific */
.outer-zone {
    border: 2px solid rgba(223,144,88,0.4);
    background: rgba(223,144,88,0.06);
    border-radius: 6px;
    padding: 20px;
}
.outer-zone .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #df9058;
    margin-bottom: 8px;
}
.inner-zone {
    border: 2px solid rgba(95,166,166,0.4);
    background: rgba(95,166,166,0.08);
    border-radius: 6px;
    padding: 16px;
    margin-top: 8px;
}
.inner-zone .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #7cc4c4;
    margin-bottom: 8px;
}

/* Zone 2 specific */
.dom-test-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
/* .item layout is parent-independent so jQuery .appendTo() into the
   relocation target preserves the flex layout. */
.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(95,166,166,0.1);
    border: 1px solid rgba(95,166,166,0.25);
    border-radius: 4px;
    font-size: 0.9rem;
}
.item button {
    margin-left: auto;
    padding: 3px 10px;
    font-size: 0.8rem;
}
.dom-test-list > .item,
.dom-test-list > .jquery-wrapper {
    margin-bottom: 0;
}
.count {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 6px;
}

.relocation-target {
    margin-top: 14px;
    padding: 10px;
    border: 1px dashed rgba(223,144,88,0.5);
    border-radius: 5px;
    background: rgba(223,144,88,0.05);
    min-height: 40px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
}
.relocation-target::before {
    content: "Second list — items moved here via state mutation (data-list=\"relocatedItems\")";
    display: block;
    margin-bottom: 4px;
}

.jquery-wrapper {
    border: 2px dotted #df9058 !important;
    padding: 6px !important;
    border-radius: 4px;
    position: relative;
}
.jquery-wrapper::before {
    content: "wrapped by jQuery (foreign DOM — strands on state moves)";
    position: absolute;
    top: -10px;
    left: 8px;
    font-size: 0.65rem;
    background: #16213e;
    padding: 0 4px;
    color: #df9058;
}

/* Decoration applied via jQuery .addClass() — the class lives on the .item
 * element WF tracks, so it survives state-driven moves between lists. */
.item.jq-decorated {
    box-shadow: 0 0 0 2px #5fa6a6 inset;
    position: relative;
}
.item.jq-decorated::after {
    content: "decorated by jQuery (class — survives state moves)";
    position: absolute;
    top: -10px;
    right: 8px;
    font-size: 0.65rem;
    background: #16213e;
    padding: 0 4px;
    color: #5fa6a6;
    pointer-events: none;
}

/* Live console */
.console-wrap {
    background: #0d0d1a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    margin-top: 8px;
    overflow: hidden;
}
.console-wrap .console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.console-wrap .console-header button {
    padding: 2px 10px;
    font-size: 0.7rem;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.1);
}

.console-log {
    list-style: none;
    margin: 0;
    padding: 8px 12px;
    max-height: 220px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.55;
}
.console-log li {
    display: grid;
    grid-template-columns: 70px 90px 1fr;
    gap: 8px;
    padding: 1px 0;
}
.console-log .ts { color: rgba(255,255,255,0.35); }
.console-log .src-jquery { color: #ffb86c; font-weight: 600; }
.console-log .src-wf     { color: #5fa6a6; font-weight: 600; }
.console-log .src-dom    { color: #bd93f9; font-weight: 600; }
.console-log .msg { color: rgba(255,255,255,0.85); white-space: pre-wrap; word-break: break-word; }

.console-empty {
    color: rgba(255,255,255,0.35);
    font-style: italic;
    padding: 6px 0;
}

/* Source blocks */
.source-block {
    margin-top: 14px;
}
.source-block pre {
    background: #0d0d1a;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 0.78rem;
    color: #e6e6e6;
    overflow-x: auto;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.source-block .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.source-block .label button {
    padding: 2px 10px;
    font-size: 0.7rem;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.1);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

/* Mode indicator */
.mode-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 8px;
}
.mode-default {
    background: rgba(255,184,108,0.15);
    color: #ffb86c;
    border: 1px solid rgba(255,184,108,0.35);
}
.mode-stop {
    background: rgba(80,250,123,0.12);
    color: #50fa7b;
    border: 1px solid rgba(80,250,123,0.35);
}

@media (max-width: 600px) {
    .demo-toolbar { padding: 8px 12px; }
    .demo-toolbar a { font-size: 0.85rem; gap: 6px; }
    .demo-toolbar .logo { height: 26px; }
    .demo-toolbar .demo-info { font-size: 0.7rem; }
    .container { padding: 64px 14px 40px; }
    .zone { padding: 16px; }
    .console-log { font-size: 0.72rem; }
    .console-log li { grid-template-columns: 56px 70px 1fr; gap: 6px; }
}
