:root {
    --bg: #080a10;
    --panel: #11151f;
    --panel-soft: #171c28;
    --border: #252c3b;
    --text: #f4f6fb;
    --muted: #8f98aa;
    --accent: #7c3aed;
    --danger: #ef4444;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(circle at 15% 15%, rgba(124, 58, 237, .22), transparent 34%),
        radial-gradient(circle at 85% 80%, rgba(14, 165, 233, .14), transparent 32%),
        #080a10;
}

.auth-shell {
    width: min(1050px, 100%);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    border: 1px solid var(--border);
    border-radius: 28px;
    overflow: hidden;
    background: rgba(17, 21, 31, .88);
    box-shadow: 0 28px 100px rgba(0, 0, 0, .42);
    backdrop-filter: blur(20px);
}

.auth-brand {
    padding: 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(124, 58, 237, .16), transparent),
        var(--panel);
}

.brand-badge {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #8b5cf6, #2563eb);
    font-weight: 800;
    box-shadow: 0 12px 30px rgba(124, 58, 237, .28);
}

.auth-brand h1 {
    margin: 28px 0 12px;
    font-size: clamp(36px, 5vw, 64px);
    line-height: .98;
}

.auth-brand p {
    max-width: 560px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.6;
}

.feature-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.feature-pills span {
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: #c7cddd;
    background: rgba(255,255,255,.025);
}

.auth-card {
    padding: 56px;
    background: #0e1119;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 5px;
    border-radius: 14px;
    background: #090c12;
    margin-bottom: 28px;
}

.auth-tab {
    border: 0;
    padding: 12px;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
}

.auth-tab.is-active {
    background: var(--panel-soft);
    color: var(--text);
}

.auth-form {
    display: none;
    gap: 18px;
}

.auth-form.is-active { display: grid; }

label {
    display: grid;
    gap: 8px;
    color: #cfd5e3;
    font-size: 14px;
}

input, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 12px 13px;
    background: #0b0e15;
    color: var(--text);
    outline: none;
}

input:focus, textarea:focus {
    border-color: #7053d6;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}

.primary-button, .secondary-button, .danger-button {
    border: 0;
    border-radius: 11px;
    padding: 12px 16px;
    font-weight: 700;
}

.primary-button {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: white;
}

.secondary-button {
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.danger-button {
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .28);
    color: #fca5a5;
}

.notice {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
}

.notice-error {
    background: rgba(239, 68, 68, .11);
    border: 1px solid rgba(239, 68, 68, .25);
    color: #fca5a5;
}

.notice-success {
    background: rgba(34, 197, 94, .11);
    border: 1px solid rgba(34, 197, 94, .25);
    color: #86efac;
}

.workspace-page { overflow: hidden; }

.workspace {
    height: 100vh;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr) 290px;
}

.sidebar, .inspector {
    position: relative;
    z-index: 5;
    background: var(--panel);
    border-color: var(--border);
}

.sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.inspector {
    border-left: 1px solid var(--border);
    padding: 22px;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.brand-small {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-small .brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.brand-small div {
    display: grid;
    gap: 3px;
}

.brand-small small { color: var(--muted); }

.icon-button {
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--text);
    min-width: 38px;
    height: 38px;
    border-radius: 10px;
}

.icon-button.accent {
    border-color: rgba(124, 58, 237, .45);
    background: rgba(124, 58, 237, .15);
}

.session-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 18px 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
}

.session-list {
    display: grid;
    gap: 6px;
    padding: 8px 12px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 11px;
    padding: 11px 12px;
    color: #cbd1df;
    background: transparent;
    text-align: left;
}

.session-item:hover, .session-item.is-active {
    background: var(--panel-soft);
    border-color: var(--border);
}

.session-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--session-color);
    box-shadow: 0 0 14px var(--session-color);
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px;
    border-top: 1px solid var(--border);
}

.logout-link {
    color: #fca5a5;
    text-decoration: none;
}

.main-area {
    min-width: 0;
    display: grid;
    grid-template-rows: 62px 56px minmax(0, 1fr);
}

.topbar, .toolbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background: rgba(14, 17, 25, .96);
    border-bottom: 1px solid var(--border);
}

.session-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
}

.session-title {
    width: min(480px, 45vw);
    padding: 8px 10px;
    border-color: transparent;
    background: transparent;
    font-weight: 700;
    font-size: 16px;
}

.save-state {
    margin-left: auto;
    color: var(--muted);
    font-size: 13px;
}

.toolbox {
    overflow-x: auto;
}

.tool-button {
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 8px 11px;
    background: var(--panel-soft);
    color: #d8deeb;
}

.tool-spacer { flex: 1; }

.zoom-label {
    min-width: 54px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.canvas-shell {
    position: relative;
    overflow: hidden;
    background-color: #090c12;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 24px 24px;
}

#canvasContainer {
    width: 100%;
    height: 100%;
}

.canvas-help {
    position: absolute;
    left: 16px;
    bottom: 16px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(13, 16, 24, .88);
    color: var(--muted);
    font-size: 12px;
    pointer-events: none;
}

.inspector-empty {
    min-height: 180px;
    display: grid;
    align-content: center;
    gap: 6px;
    text-align: center;
    color: var(--muted);
}

.inspector-empty strong { color: var(--text); }

.inspector-form {
    display: grid;
    gap: 16px;
}

.inspector-form h3 { margin: 0 0 4px; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .66);
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
    width: min(430px, 100%);
    display: grid;
    gap: 18px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 30px 90px rgba(0,0,0,.4);
}

.modal-card h2 { margin: 0; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 1050px) {
    .workspace { grid-template-columns: 240px minmax(0, 1fr); }
    .inspector {
        position: fixed;
        right: 0;
        top: 118px;
        bottom: 0;
        width: 290px;
        transform: translateX(100%);
        transition: transform .2s ease;
    }
    .inspector.has-selection { transform: translateX(0); }
}

@media (max-width: 760px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { padding: 38px; }
    .auth-card { padding: 32px; }

    .workspace { display: block; }
    .main-area { height: 100vh; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(300px, 86vw);
        z-index: 40;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 20px 0 60px rgba(0,0,0,.42);
    }
    .sidebar.is-open { transform: translateX(0); }
    .session-title { width: 48vw; }
}
