:root {
    --bg: #15161d;
    --bg-elevated: #1b1d28;
    --bg-panel: #20222d;
    --bg-panel-soft: rgba(38, 40, 55, 0.74);
    --line: rgba(98, 114, 164, 0.28);
    --text: #f8f8f2;
    --text-soft: #bdc3da;
    --muted: #7f89ad;
    --accent: #bd93f9;
    --accent-cyan: #8be9fd;
    --accent-green: #50fa7b;
    --accent-pink: #ff79c6;
    --accent-orange: #ffb86c;
    --danger: #ff5555;
    --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
    --radius: 18px;
}

* { 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: radial-gradient(circle at top right, rgba(189, 147, 249, 0.08), transparent 18%), var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.main-nav { border-right: 1px solid var(--line); padding: 24px 18px; background: rgba(18, 19, 27, 0.85); backdrop-filter: blur(18px); display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, var(--accent), var(--accent-cyan)); color: #11131a; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small, .muted-line, .form-note, .project-row small, .activity-list small, .compact-list, .inline-hint { color: var(--muted); }
.nav-links { display: grid; gap: 8px; }
.nav-links a { padding: 12px 14px; border-radius: 14px; color: var(--text-soft); background: transparent; transition: 150ms ease; }
.nav-links a:hover, .nav-links a.is-active { background: rgba(189, 147, 249, 0.12); color: var(--text); }
.nav-footnote { margin-top: auto; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-panel-soft); }
.nav-footnote h4 { margin: 0 0 8px; }
.nav-footnote p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.5; }

.main-stage { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px 24px; border-bottom: 1px solid var(--line); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 20; background: rgba(21, 22, 29, 0.82); }
.global-search { flex: 1; max-width: 560px; }
.global-search input { width: 100%; padding: 14px 18px; border-radius: 999px; border: 1px solid var(--line); background: rgba(33, 35, 47, 0.8); color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(29, 31, 44, 0.78); }
.user-chip strong, .user-chip small { display: block; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(139, 233, 253, 0.16); color: var(--accent-cyan); font-weight: 700; }
.content-shell { padding: 24px; display: flex; flex-direction: column; gap: 24px; }

.flash { margin: 16px 24px 0; padding: 14px 18px; border-radius: 16px; border: 1px solid var(--line); }
.flash-success { background: rgba(80, 250, 123, 0.12); color: var(--accent-green); }
.flash-error { background: rgba(255, 85, 85, 0.12); color: #ff9fa2; }

.workspace-hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 28px 30px; border: 1px solid var(--line); border-radius: 30px; background: linear-gradient(180deg, rgba(36, 38, 51, 0.8), rgba(23, 24, 33, 0.95)); box-shadow: var(--shadow); }
.workspace-hero.compact { padding-top: 22px; padding-bottom: 22px; }
.workspace-hero h1 { margin: 8px 0 10px; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.05; letter-spacing: -0.04em; max-width: 13ch; }
.workspace-hero p { margin: 0; max-width: 62ch; color: var(--text-soft); line-height: 1.6; }
.eyebrow { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: rgba(189, 147, 249, 0.14); color: #d8c5ff; font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.metrics-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metrics-strip article { padding: 24px; border-radius: 24px; border: 1px solid var(--line); background: rgba(29, 31, 44, 0.74); }
.metrics-strip strong { display: block; font-size: 2rem; letter-spacing: -0.04em; }
.metrics-strip span { color: var(--muted); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 20px; }
.dashboard-grid.search-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-grid.wiki-layout, .dashboard-grid.db-layout { grid-template-columns: 320px minmax(0, 1.3fr) 320px; }
.panel, .stack-panel { border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(180deg, rgba(31, 33, 47, 0.94), rgba(25, 26, 36, 0.92)); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.stack-panel { margin-top: -8px; }
.panel-bar, .editor-topbar, .editor-toolbar, .section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.section-head { align-items: end; margin-bottom: 18px; }
.section-head h2, .section-head h3 { margin: 6px 0 0; font-size: 1.32rem; }
.section-head p { margin: 0; }

.project-list, .template-list, .activity-list, .compact-list { display: grid; gap: 12px; padding: 0; list-style: none; margin: 0; }
.project-row { display: grid; gap: 8px; padding: 16px 18px; border-radius: 18px; border: 1px solid rgba(98, 114, 164, 0.18); background: rgba(26, 28, 39, 0.82); }
.project-row:hover { border-color: rgba(189, 147, 249, 0.34); }
.project-row-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.template-row { display: grid; gap: 6px; padding: 14px 16px; border-left: 2px solid rgba(189, 147, 249, 0.4); background: rgba(26, 28, 39, 0.6); border-radius: 16px; }
.activity-list li { display: grid; gap: 4px; padding: 14px 0; border-bottom: 1px solid rgba(98, 114, 164, 0.12); }
.activity-list li:last-child { border-bottom: 0; }
.empty-state { color: var(--muted); }

.primary-button, .ghost-button, .mini-button, .link-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 14px; border: 1px solid transparent; padding: 11px 16px; transition: 150ms ease;
}
.primary-button { background: linear-gradient(140deg, var(--accent), #d7b4ff); color: #16171f; font-weight: 700; }
.primary-button:hover { transform: translateY(-1px); }
.ghost-button, .mini-button { background: rgba(31, 33, 47, 0.88); border-color: var(--line); color: var(--text); }
.mini-button { padding: 8px 12px; border-radius: 12px; font-size: 0.92rem; }
.link-button { padding: 0; background: transparent; color: var(--text-soft); border: 0; justify-content: start; }
.inline-actions, .inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select, .inline-form textarea { flex: 1; min-width: 0; }

.stack-form { display: grid; gap: 16px; }
.stack-form label { display: grid; gap: 8px; }
.stack-form input, .stack-form textarea, .stack-form select, .inline-form input, .inline-form select, .inline-form textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; background: rgba(24, 25, 35, 0.92); color: var(--text);
}
.checkbox-row { display: flex !important; align-items: center; gap: 10px; }
.checkbox-row input { width: auto; }
.template-picker { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.template-option { display: flex; gap: 14px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); background: rgba(26, 28, 39, 0.82); align-items: start; }
.template-option input { margin-top: 4px; width: auto; }
.template-option-violet { border-color: rgba(189, 147, 249, 0.3); }
.template-option-pink { border-color: rgba(255, 121, 198, 0.3); }
.template-option-cyan { border-color: rgba(139, 233, 253, 0.3); }
.template-option-green { border-color: rgba(80, 250, 123, 0.3); }
.template-option-orange { border-color: rgba(255, 184, 108, 0.3); }
.bullet-list { margin: 0; padding-left: 18px; display: grid; gap: 10px; color: var(--text-soft); }

.subnav-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.subnav-strip a { padding: 10px 14px; border-radius: 14px; background: rgba(31, 33, 47, 0.88); border: 1px solid var(--line); color: var(--text-soft); }

.auth-body { overflow: hidden; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 0.85fr; }
.auth-brand { padding: 64px; display: grid; place-items: center; background: radial-gradient(circle at top left, rgba(139, 233, 253, 0.12), transparent 24%), radial-gradient(circle at bottom right, rgba(189, 147, 249, 0.16), transparent 24%), #16171f; }
.auth-brand-inner { max-width: 640px; display: grid; gap: 20px; }
.auth-brand-inner h1 { margin: 0; font-size: clamp(2.4rem, 5vw, 4.8rem); line-height: 0.96; letter-spacing: -0.05em; }
.auth-brand-inner p { margin: 0; color: var(--text-soft); font-size: 1.06rem; line-height: 1.6; }
.auth-points { display: grid; gap: 14px; margin-top: 10px; }
.auth-points div { padding: 16px 18px; border-radius: 20px; border: 1px solid var(--line); background: rgba(24, 26, 35, 0.74); }
.auth-points strong, .auth-points small { display: block; }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(460px, 100%); padding: 32px; border-radius: 30px; border: 1px solid var(--line); background: rgba(28, 30, 41, 0.96); box-shadow: var(--shadow); }

.ide-page .content-shell { padding: 0; }
.ide-stage { display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; gap: 1px; min-height: calc(100vh - 83px); background: rgba(98, 114, 164, 0.16); }
.ide-stage > .panel, .ide-main { border-radius: 0; border: 0; box-shadow: none; background: var(--bg-elevated); }
.ide-explorer, .ide-right { padding: 18px; overflow: auto; }
.ide-main { display: grid; grid-template-rows: auto auto minmax(0, 1fr) 280px; min-width: 0; }
.project-kicker { padding: 14px 0 18px; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.file-tree { padding-top: 14px; font-size: 0.95rem; }
.file-tree details { margin-bottom: 4px; }
.file-tree summary, .file-node { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; color: var(--text-soft); cursor: pointer; }
.file-tree summary:hover, .file-node:hover, .file-node.is-active { background: rgba(189, 147, 249, 0.14); color: var(--text); }
.file-tree summary::-webkit-details-marker { display: none; }
.panel-subsection { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }

.editor-topbar, .editor-toolbar { padding: 14px 18px; border-bottom: 1px solid var(--line); background: rgba(23, 24, 33, 0.96); }
.editor-toolbar { color: var(--muted); font-size: 0.92rem; }
.editor-tabs { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.editor-tab { display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px; background: rgba(49, 52, 68, 0.88); color: var(--text-soft); }
.editor-tab.is-active { background: rgba(189, 147, 249, 0.16); color: var(--text); }
.editor-close { border: 0; background: transparent; color: inherit; padding: 0; font-size: 0.92rem; }
.editor-frame { min-width: 0; min-height: 0; }
#ide-editor { width: 100%; height: 100%; min-height: 420px; background: var(--bg-panel); color: var(--text); border: 0; padding: 18px; resize: none; }
.CodeMirror { height: 100%; min-height: 420px; font-size: 14px; background: #1f202a; }

.console-panel { border-top: 1px solid var(--line); border-radius: 0; padding: 16px 18px; min-width: 0; }
.terminal-output { margin: 12px 0; padding: 14px; border-radius: 16px; background: #11131a; border: 1px solid var(--line); color: #dfe6ff; white-space: pre-wrap; max-height: 180px; overflow: auto; }
.console-history { display: grid; gap: 10px; max-height: 120px; overflow: auto; }
.history-entry { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }

.inspector-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.inspector-tabs button { padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(29, 31, 44, 0.84); color: var(--text-soft); }
.inspector-tabs button.is-active { background: rgba(189, 147, 249, 0.15); color: var(--text); }
.inspector-panel { display: none; gap: 14px; }
.inspector-panel.is-active { display: grid; }
.inspector-output { display: grid; gap: 6px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(17, 19, 26, 0.86); color: var(--text-soft); min-height: 80px; }

.kanban-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.kanban-column { border: 1px solid var(--line); border-radius: 24px; background: rgba(25, 27, 38, 0.92); min-height: 420px; display: flex; flex-direction: column; }
.kanban-column header { padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(98, 114, 164, 0.12); box-shadow: inset 3px 0 0 var(--column-accent); }
.kanban-dropzone { padding: 14px; display: grid; gap: 12px; min-height: 220px; }
.kanban-task { padding: 14px; border-radius: 18px; background: rgba(31, 33, 47, 0.88); border: 1px solid rgba(98, 114, 164, 0.18); display: grid; gap: 10px; cursor: grab; }
.kanban-task p { margin: 0; color: var(--text-soft); }
.kanban-task footer { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.priority { padding: 4px 8px; border-radius: 999px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.priority-high { background: rgba(255, 85, 85, 0.14); color: #ff9fa2; }
.priority-medium { background: rgba(255, 184, 108, 0.14); color: var(--accent-orange); }
.priority-low { background: rgba(80, 250, 123, 0.14); color: var(--accent-green); }

.query-result { min-height: 240px; }
.result-table-wrap { overflow: auto; border-radius: 18px; border: 1px solid var(--line); }
table.result-table { width: 100%; border-collapse: collapse; }
.result-table th, .result-table td { padding: 12px 14px; border-bottom: 1px solid rgba(98, 114, 164, 0.12); text-align: left; vertical-align: top; }
.result-table th { position: sticky; top: 0; background: #171923; }

@media (max-width: 1200px) {
    .app-shell { grid-template-columns: 1fr; }
    .main-nav { display: none; }
    .dashboard-grid, .dashboard-grid.search-results, .dashboard-grid.wiki-layout, .dashboard-grid.db-layout { grid-template-columns: 1fr; }
    .ide-stage { grid-template-columns: 1fr; }
}
