:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #e2e8f0;
    background: #0f172a;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body, #root { width: 100%; height: 100%; min-height: 100dvh; }
body { margin: 0; overflow: hidden; background: #0f172a; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 3px solid rgba(56, 189, 248, 0.85);
    outline-offset: 2px;
}

::selection { color: #0f172a; background: #7dd3fc; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e293b; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

.loader {
    border: 3px solid #1e293b;
    border-bottom-color: #38bdf8;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

.sidebar-transition { transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.tab-btn { position: relative; transition: color 0.2s, background-color 0.2s; }
.tab-btn.active::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 2px;
    background: #38bdf8;
}

.error-fallback {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
    height: 100%;
    padding: 2rem;
    color: #fecaca;
    background: #1e293b;
}
.error-fallback__icon { color: #f87171; font-size: 1.5rem; }
.error-fallback h2 { margin: 0 0 .35rem; font-size: 1rem; font-weight: 700; }
.error-fallback p { margin: 0 0 1rem; color: #cbd5e1; font-size: .875rem; }
.error-fallback__actions { display: flex; gap: .75rem; align-items: center; }
.error-fallback__actions button, .error-fallback__actions a {
    border-radius: .5rem;
    padding: .5rem .75rem;
    font-size: .8rem;
    font-weight: 600;
}
.error-fallback__actions button { border: 1px solid #0ea5e9; color: #e0f2fe; background: #0369a1; cursor: pointer; }
.error-fallback__actions a { color: #bae6fd; text-decoration: underline; }

@keyframes rotation { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* SurveyOS SDK design-system primitives. Generated tools use these semantic
   classes through SurveyOS.ui instead of inventing button and state styles. */
.so-button {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border: 1px solid transparent;
    border-radius: .55rem;
    padding: .55rem .8rem;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .18s, border-color .18s, color .18s, transform .18s;
}
.so-button:hover:not(:disabled) { transform: translateY(-1px); }
.so-button:disabled { cursor: not-allowed; opacity: .48; }
.so-button--primary { color: #e0f2fe; background: #0369a1; border-color: #0284c7; }
.so-button--primary:hover:not(:disabled) { background: #0284c7; }
.so-button--secondary { color: #e2e8f0; background: #334155; border-color: #475569; }
.so-button--secondary:hover:not(:disabled) { background: #475569; }
.so-button--ghost { color: #bae6fd; background: transparent; border-color: transparent; }
.so-button--ghost:hover:not(:disabled) { background: #1e293b; }
.so-button--outline { color: #bae6fd; background: transparent; border-color: #0e7490; }
.so-button--outline:hover:not(:disabled) { background: #083344; }
.so-button--destructive { color: #fee2e2; background: #991b1b; border-color: #dc2626; }
.so-button--icon { width: 2.75rem; padding: .5rem; color: #cbd5e1; background: #1e293b; border-color: #475569; }
.so-button-group, .so-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.so-field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; color: #cbd5e1; font-size: .8rem; }
.so-field__label { font-weight: 650; }
.so-required { color: #fb7185; }
.so-field__hint { color: #64748b; font-size: .7rem; }
.so-field__error { display: flex; align-items: center; gap: .3rem; color: #fda4af; font-size: .72rem; }
.so-field input, .so-field select, .so-field textarea { width: 100%; min-height: 2.75rem; border: 1px solid #334155; border-radius: .5rem; color: #f8fafc; background: #0f172a; padding: .55rem .7rem; }
.so-field input:focus, .so-field select:focus, .so-field textarea:focus { border-color: #38bdf8; outline: 2px solid rgba(56,189,248,.25); }
.so-check { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; color: #cbd5e1; font-size: .8rem; }
.so-check input { width: 1.1rem; height: 1.1rem; accent-color: #0284c7; }
.so-panel { border: 1px solid #334155; border-radius: .75rem; background: rgba(15,23,42,.72); }
.so-panel__header { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border-bottom: 1px solid #334155; }
.so-panel__header h3 { margin: 0; color: #f8fafc; font-size: .9rem; }
.so-eyebrow { margin: 0 0 .2rem; color: #67e8f9; font-size: .65rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.so-dialog-backdrop { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(2,6,23,.78); }
.so-dialog { width: min(58rem, 100%); max-height: min(90dvh, 52rem); overflow: auto; border: 1px solid #334155; border-radius: 1rem; color: #cbd5e1; background: #0f172a; box-shadow: 0 1.5rem 4rem rgba(0,0,0,.45); }
.so-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid #334155; }
.so-dialog > header h2 { margin: 0; color: #f8fafc; font-size: 1.05rem; }
.so-tabs { display: flex; gap: .25rem; overflow-x: auto; padding: .75rem 1rem 0; border-bottom: 1px solid #334155; }
.so-tabs button { min-height: 2.5rem; flex: 0 0 auto; border: 0; border-bottom: 2px solid transparent; color: #94a3b8; background: transparent; padding: .45rem .65rem; font-size: .72rem; font-weight: 700; cursor: pointer; }
.so-tabs button:hover, .so-tabs button.is-active { color: #e0f2fe; border-bottom-color: #38bdf8; }
.so-state { display: flex; align-items: flex-start; gap: .7rem; padding: 1rem; color: #94a3b8; }
.so-state h3 { margin: 0 0 .25rem; color: #f8fafc; font-size: .85rem; }
.so-state p { margin: 0 0 .65rem; font-size: .75rem; }
.so-state--empty { color: #67e8f9; }
.so-state--error { color: #fda4af; }
.so-spin { animation: rotation 1s linear infinite; }
.so-statusbar { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; min-height: 2.2rem; padding: .35rem .75rem; border-top: 1px solid #334155; color: #94a3b8; background: #0f172a; font-size: .68rem; }
.so-statusbar > span { display: inline-flex; align-items: center; gap: .35rem; }
.so-status-dot { width: .45rem; height: .45rem; border-radius: 999px; background: #34d399; }
.so-table-wrap { overflow-x: auto; }
.so-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.so-table th, .so-table td { padding: .55rem .65rem; border-bottom: 1px solid #1e293b; text-align: left; white-space: nowrap; }
.so-table th { color: #94a3b8; font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
.so-table td { color: #cbd5e1; }
.so-table__pager { display: flex; align-items: center; justify-content: flex-end; gap: .65rem; padding: .55rem; color: #94a3b8; font-size: .7rem; }
.so-property-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; margin: 0; }
.so-property-grid > div { padding: .65rem; border: 1px solid #334155; border-radius: .5rem; background: #0f172a; }
.so-property-grid dt { color: #64748b; font-size: .68rem; }
.so-property-grid dd { margin: .2rem 0 0; color: #f8fafc; font-size: .8rem; overflow-wrap: anywhere; }
.so-dropzone { display: grid; min-height: 5rem; place-items: center; border: 1px dashed #38bdf8; border-radius: .75rem; color: #bae6fd; background: rgba(14,116,144,.1); cursor: pointer; text-align: center; }
.so-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.so-reference { padding-bottom: .75rem; }
.so-reference__intro { display: flex; align-items: flex-start; gap: .7rem; padding: 1rem 1.15rem .25rem; }
.so-reference__intro p { margin: 0; max-width: 48rem; font-size: .78rem; line-height: 1.5; color: #94a3b8; }
.so-reference__badge { flex: 0 0 auto; border: 1px solid rgba(34,211,238,.35); border-radius: 999px; padding: .22rem .5rem; color: #a5f3fc; background: rgba(8,145,178,.15); font-size: .65rem; font-weight: 800; letter-spacing: .08em; }
.so-reference__content { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(14rem, .7fr); gap: 1rem; padding: 1rem 1.15rem; }
.so-reference__api-list { display: grid; gap: .6rem; }
.so-reference__api, .so-reference__registry, .so-reference__templates { border: 1px solid #334155; border-radius: .65rem; background: rgba(30,41,59,.45); }
.so-reference__api { padding: .75rem; }
.so-reference__api-heading, .so-reference__section-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.so-reference__api-heading code { color: #7dd3fc; font-weight: 800; }
.so-reference__api-heading span, .so-reference__section-heading span:last-child { color: #64748b; font-size: .65rem; }
.so-reference__api p { margin: .45rem 0; color: #94a3b8; font-size: .72rem; line-height: 1.45; }
.so-reference__example { display: block; overflow-wrap: anywhere; color: #a7f3d0; font-size: .66rem; line-height: 1.45; }
.so-reference__registry, .so-reference__templates { padding: .75rem; }
.so-reference__section-heading { color: #e2e8f0; font-size: .72rem; font-weight: 750; }
.so-reference__registry-group { display: grid; gap: .3rem; margin-top: .7rem; }
.so-reference__registry-group > span { color: #64748b; font-size: .63rem; letter-spacing: .1em; text-transform: uppercase; }
.so-reference__registry-group > div, .so-reference__template-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.so-reference__registry-group > div span, .so-reference__template-list span { border: 1px solid #334155; border-radius: .4rem; padding: .25rem .4rem; color: #94a3b8; background: #0f172a; font-size: .63rem; }
.so-reference__registry-group > div span.is-core { border-color: rgba(34,211,238,.35); color: #a5f3fc; }
.so-reference__templates { margin: 0 1.15rem; }
.so-reference__template-list { margin-top: .55rem; }
.so-reference__footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .2rem 1.15rem 0; color: #64748b; font-size: .68rem; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 720px) {
    .so-reference__content { grid-template-columns: 1fr; }
    .so-reference__intro { flex-direction: column; }
    .so-reference__footer { align-items: flex-start; flex-direction: column-reverse; }
}
@media (max-width: 767px) {
    .error-fallback { padding: 1.25rem; }
}
