:root {
    --demo-bg: #f1f5f9;
    --demo-card: #ffffff;
}

body {
    margin: 0;
    background: var(--demo-bg);
    color: #0f172a;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.demo-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

.demo-header h1 {
    margin: 0 0 .25rem;
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.demo-badge {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: #6366f1;
    color: #fff;
    padding: .15rem .5rem;
    border-radius: 999px;
}

.demo-sub {
    margin: 0 0 .5rem;
    color: #475569;
    max-width: 60rem;
    line-height: 1.5;
}

.demo-sub code,
.demo-catalog code {
    background: #e2e8f0;
    padding: .05rem .35rem;
    border-radius: .25rem;
    font-size: .85em;
}

.demo-catalog {
    color: #64748b;
    font-size: .9rem;
    margin: 0 0 1.5rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.demo-loading {
    color: #64748b;
}

.demo-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

.demo-toolbar-hint {
    color: #64748b;
    font-size: .85rem;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.demo-color-row { display: flex; gap: .35rem; align-items: stretch; }
.demo-color-row .demo-color-text { flex: 1; }
.demo-color-row .demo-color-picker {
    width: 38px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: .35rem;
    background: none;
    cursor: pointer;
}

.demo-editor-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 768px) {
    .demo-editor-layout { grid-template-columns: 1fr; }
}

.demo-canvas {
    background: var(--demo-card);
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}

/* ---- Demo widgets (host-owned; the RCL renders them via DynamicComponent) ---- */

.demo-w {
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    /* The grid cell (.dbx-cell) now provides the card border / background /
       radius, so the widget itself stays naked to avoid a double border. */
    padding: 1rem;
    overflow: hidden;
}

.demo-w-text-title {
    margin: 0 0 .5rem;
    font-size: 1.1rem;
}

.demo-w-text-body {
    color: #475569;
    line-height: 1.5;
    font-size: .95rem;
}

.demo-w-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
}

.demo-clock-time {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}

.demo-clock-date {
    font-size: .85rem;
    opacity: .9;
    margin-top: .25rem;
}

.demo-w-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .35rem;
    border-left: 4px solid var(--demo-accent, #6366f1);
    min-width: 0; /* allow flex children to shrink and ellipsize */
}

.demo-stat-top {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: #64748b;
    font-size: .85rem;
    min-width: 0;
}

.demo-stat-top i {
    color: var(--demo-accent, #6366f1);
    font-size: 1.05rem;
    flex: 0 0 auto;
}

.demo-stat-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-stat-value {
    font-size: clamp(1.1rem, 4cqi, 1.9rem); /* scales to the widget's own width */
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-w-stat { container-type: inline-size; } /* enables the cqi unit above */
