/* Studio editor: classic window-style panes, compact controls. */
.studio-body .container { max-width: none; margin: 0; padding: 0; display: block; }
.studio-body .footer, .studio-body .subbar { display: none; }
.studio-body .content > .alert { margin: 6px 8px 0; }

.studio { display: flex; flex-direction: column; height: calc(100vh - 45px); min-height: 520px; background: #d4d8de; }

.studio-toolbar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 5px 8px; background: linear-gradient(#f4f6f8, #dde2e8); border-bottom: 1px solid #a9b2bd;
}
.studio-back { font-size: 12px; font-weight: bold; }
.studio-title { color: var(--header-text); font-size: 14px; }
.studio-role { font-size: 11px; color: #666; border: 1px solid #c3c9d0; padding: 0 5px; background: #fff; }
.studio-sep { width: 1px; height: 20px; background: #b6bec8; margin: 0 2px; }
.studio-status { margin-left: auto; font-size: 12px; color: #555; }
.studio-status.success { color: #24561a; font-weight: bold; }
.studio-status.error { color: #a1251a; font-weight: bold; }
.studio-status.busy { color: #1d4a80; }

.studio-main { flex: 1; display: grid; grid-template-columns: 250px 1fr 280px; min-height: 0; gap: 4px; padding: 4px; }
.studio-pane, .studio-center { background: #fff; border: 1px solid #a9b2bd; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.studio-center { background: #e9edf1; }
.pane-title {
    background: linear-gradient(#e2ebf6, #cddbec); color: var(--header-text); font-weight: bold; font-size: 12px;
    padding: 4px 7px; border-bottom: 1px solid #a9b2bd; display: flex; justify-content: space-between; align-items: center;
}
.pad { padding: 8px; }

/* Explorer */
.explorer-tree { flex: 1; overflow: auto; font-size: 12px; padding: 2px 0; outline: none; user-select: none; }
.tree-row { display: flex; align-items: center; gap: 4px; height: 20px; padding-right: 6px; cursor: default; white-space: nowrap; border: 1px solid transparent; }
.tree-row:hover { background: #eef4fb; }
.tree-row.selected { background: #cfe3f8; border-color: #8ab4e6; }
.tree-row.locked .tree-name { font-weight: bold; }
.tree-row.drop-inside { background: #d9f0d4; border-color: #6bb35e; }
.tree-row.drop-before { border-top: 2px solid #2f9e2f; }
.tree-row.drop-after { border-bottom: 2px solid #2f9e2f; }
.tree-toggle { width: 12px; text-align: center; color: #555; cursor: pointer; flex: none; }
.tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-tag { font-size: 10px; color: #777; border: 1px solid #ccc; padding: 0 3px; line-height: 13px; }
.tree-tag.tag-error { color: #a1251a; border-color: #e0a19a; background: #fbe3e1; }
.tree-rename { font: 12px Arial, sans-serif; padding: 0 2px; height: 17px; width: 140px; }

.cls-icon {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    min-width: 16px; height: 14px; padding: 0 2px; font-size: 9px; font-weight: bold; color: #fff; background: #8a94a0; border: 1px solid rgba(0, 0, 0, .25);
}
.cls-Service { background: #3b6ea8; }
.cls-Part { background: #8c8c8c; }
.cls-Model { background: #6b7fa3; }
.cls-Folder, .cls-StarterPlayerScripts, .cls-StarterCharacterScripts { background: #d9a520; }
.cls-Script { background: #1f6fd1; }
.cls-LocalScript { background: #1aa3b8; }
.cls-ModuleScript { background: #7b4fc4; }
.cls-RemoteEvent, .cls-RemoteFunction { background: #e07b1f; }
.cls-BindableEvent, .cls-BindableFunction { background: #b8661a; }
.cls-IntValue, .cls-StringValue, .cls-BoolValue, .cls-NumberValue { background: #3f9a4b; }

/* Center: tabs, viewport, script editor, output */
.studio-tabs { display: flex; gap: 2px; padding: 3px 3px 0; background: #d4d8de; border-bottom: 1px solid #a9b2bd; overflow-x: auto; flex: none; }
.studio-tab {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font: bold 12px Arial, sans-serif; color: #555;
    background: linear-gradient(#f6f6f6, #e1e1e1); border: 1px solid #a9b2bd; border-bottom: 0; cursor: pointer; white-space: nowrap;
}
.studio-tab.active { background: #fff; color: var(--header-text); }
.studio-tab.dirty .tab-title::after { content: " \2022"; color: #c4281c; }
.tab-close { border: 0; background: none; cursor: pointer; color: #888; font-size: 14px; line-height: 1; padding: 0; }
.tab-close:hover { color: #c4281c; }

.studio-views { flex: 1; position: relative; min-height: 0; }
.studio-view { position: absolute; inset: 0; display: none; flex-direction: column; background: #fff; }
.studio-view.active { display: flex; }
.studio-viewport { flex: 1; min-height: 0; position: relative; background: #9fc5e8; }
.studio-viewport canvas { display: block; cursor: grab; }
.viewport-hint { font-size: 11px; color: #666; padding: 2px 6px; background: #f4f6f8; border-top: 1px solid #ccd3db; }

.script-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 6px; background: #f4f6f8; border-bottom: 1px solid #ccd3db; font-size: 12px; }
.script-info.status-ok { color: #24561a; }
.script-info.status-error { color: #a1251a; font-weight: bold; }
.code-editor { flex: 1; display: flex; min-height: 0; background: #1e1f24; }
.code-gutter {
    flex: none; width: 44px; overflow: hidden; padding: 6px 0; background: #2a2c33; color: #7d8590; text-align: right;
    font: 13px/18px Consolas, "Courier New", monospace; user-select: none;
}
.gut-line { padding-right: 6px; height: 18px; }
.gut-error { background: #6b1f1f; color: #ffb3b3; }
.code-text {
    flex: 1; resize: none; border: 0; outline: none; padding: 6px 8px; margin: 0; tab-size: 4;
    font: 13px/18px Consolas, "Courier New", monospace; background: #1e1f24; color: #e6e6e6; white-space: pre; overflow: auto;
}
.code-text:read-only { color: #b9b9b9; }
.script-problems { flex: none; max-height: 110px; overflow: auto; font-size: 12px; border-top: 1px solid #ccd3db; background: #fff8f7; }
.script-problems:empty { display: none; }
.problem { padding: 2px 8px; color: #8a1f14; }
.problem-line { font-weight: bold; margin-right: 4px; }

.studio-output { flex: none; height: 170px; display: flex; flex-direction: column; border-top: 1px solid #a9b2bd; background: #fff; }
.output-log { flex: 1; overflow: auto; font: 12px/16px Consolas, "Courier New", monospace; padding: 2px 6px; }
.out-line { display: flex; gap: 6px; white-space: pre-wrap; word-break: break-word; }
.out-time { color: #999; flex: none; }
.out-script { flex: none; }
.out-error .out-msg { color: #b3261e; }
.out-warn .out-msg { color: #a86200; }
.out-system .out-msg { color: #1d4a80; font-style: italic; }

/* Properties */
.properties { flex: 1; overflow: auto; font-size: 12px; }
.prop-table { width: 100%; border-collapse: collapse; }
.prop-table th { text-align: left; font-weight: normal; color: #444; padding: 3px 6px; width: 40%; border-bottom: 1px solid #eee; vertical-align: middle; }
.prop-table td { padding: 2px 6px; border-bottom: 1px solid #eee; }
.prop-table tr.prop-section th { background: #eef2f6; font-weight: bold; color: var(--header-text); }
.prop-table input:not([type=checkbox]):not([type=color]), .prop-table select { width: 100%; font: 12px Arial, sans-serif; padding: 1px 3px; border: 1px solid #b9c0c8; }
.prop-table input[type=color] { width: 44px; height: 20px; }
.vec3 { display: flex; gap: 2px; }
.vec3 input { min-width: 0; }
.prop-ro { color: #666; }
.status-ok { color: #24561a; }
.status-error { color: #a1251a; font-weight: bold; }
.service-info { padding: 6px 8px; font-size: 12px; border-top: 1px solid #ddd; }

/* Context menu */
.context-menu {
    position: fixed; z-index: 50; min-width: 180px; background: #fff; border: 1px solid #8a94a0;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, .15); padding: 2px 0; font-size: 12px;
}
.menu-item {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 10px; border: 0; background: none;
    font: 12px Arial, sans-serif; text-align: left; cursor: pointer; position: relative; color: #222;
}
.menu-item:hover:not(:disabled) { background: #cfe3f8; }
.menu-item:disabled { color: #aaa; cursor: default; }
.menu-key { margin-left: auto; color: #888; font-size: 11px; }
.has-sub .submenu {
    display: none; position: absolute; left: 100%; top: -3px; min-width: 170px; max-height: 70vh; overflow: auto;
    background: #fff; border: 1px solid #8a94a0; box-shadow: 2px 2px 0 rgba(0, 0, 0, .15); padding: 2px 0;
}
.has-sub:hover .submenu, .has-sub:focus-within .submenu { display: block; }

/* Dialogs */
.studio-dialog-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20, 30, 45, .35); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; }
.studio-dialog-backdrop[hidden] { display: none; }
.studio-dialog { width: min(560px, calc(100vw - 32px)); max-height: 80vh; overflow: auto; margin: 0; }
.collab { margin-top: 14px; border-top: 1px solid #ddd; padding-top: 8px; }
.collab h3 { font-size: 13px; }
.collab-row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #eee; }

@media (max-width: 900px) {
    .studio { height: auto; }
    .studio-main { grid-template-columns: 1fr; }
    .studio-explorer, .studio-properties { max-height: 320px; }
    .studio-center { min-height: 520px; }
}
