body { background: var(--bg); color: var(--ink); font: 12px/1.5 var(--font); }
body.scene-editor, body.read-only { --menu-top: 0px; --content-top: 36px; }
button, input, select, textarea, .Text, .Input, .Select, .Button { font-family: var(--font); }
button, input, select, textarea { border-radius: 0 !important; box-shadow: none !important; }
hr { border-color: var(--line); }

#fiend-header {
  position: absolute;
  top: 0;
  z-index: 20;
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
#fiend-header .fiend-brand { font-size: 15px; }
.fiend-title { flex: 1; min-width: 0; padding-left: 20px; border-left: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fiend-status { color: var(--muted); font-size: 11px; white-space: nowrap; }
#fiend-status::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 8px; background: #9b9b9b; }
#fiend-status[data-state="error"] { color: var(--bright); }
#fiend-status[data-state="error"]::before { width: 6px; height: 6px; border: 1px solid var(--bright); background: transparent; }
.header-actions { display: flex; flex-shrink: 0; gap: 6px; }
#fiend-header .fiend-button { padding: 6px 10px; font-size: 11px; white-space: nowrap; }

#menubar { top: var(--menu-top, 56px); height: 36px; background: var(--surface); border-bottom: 1px solid var(--line); }
.scene-editor #menubar { display: flex; align-items: center; }
.scene-editor #menubar > .menu { float: none; }
.fiend-menubar-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; padding: 0 12px; }
.fiend-menubar-actions .fiend-button { padding: 3px 9px; font-size: 11px; white-space: nowrap; }
#menubar .menu { padding-right: 0; }
#menubar .menu .title { padding: 10px 14px; color: var(--muted); font-size: 11px; }
#menubar .menu:hover > .title { color: var(--bright); background: var(--hover); }
#menubar .menu .options { z-index: 10; padding: 4px 0; background: var(--surface); border: 1px solid #444; box-shadow: none; }
#menubar .menu .options .option { color: var(--ink); padding: 4px 14px; font-size: 12px; }
#menubar .menu .options .option:hover { color: var(--bright); background: #252525; }
#menubar .menu .options .option:not(.submenu-title):active { color: var(--bright); background: #303030; }
#menubar .menu .options .inactive { color: #626262; font-size: 12px; }
#menubar .menu .options hr { border-color: var(--line); }
#menubar .menu .key { color: var(--muted); border-color: var(--line); border-radius: 0; font: 9px var(--font); }
#menubar .menu.right > span:first-child { display: none; }

#viewport, #sidebar, #resizer, #script, #player { top: var(--content-top, 92px); }
#viewport .Text { color: #aaa; font-size: 11px; text-shadow: none; }
#sidebar { background: var(--bg); border-left: 1px solid var(--line); }
#sidebar .Panel { color: var(--muted); border-color: var(--line); }
#sidebar .Row { min-height: 26px; margin-bottom: 8px; }
#sidebar .Row .Label { color: var(--muted); font-size: 11px; }
#sidebar .Text { font-size: 11px; }
#sidebar .Panel.Material canvas { border-color: var(--line); }
.Panel { color: var(--muted); }

.TabbedPanel .Tabs, #tabs { background: var(--surface); border-color: var(--line); }
.TabbedPanel .Tabs .Tab, #tabs span { color: var(--muted); border-color: var(--line); padding: 10px 13px; font: 11px/15px var(--font); letter-spacing: .3px; }
.TabbedPanel .Tab.selected, #tabs span.selected { color: var(--bright); background: var(--bg); }
.TabbedPanel .Tab:hover { color: var(--bright); }
.TabbedPanel .Tabs::-webkit-scrollbar { background: var(--bg); }
.TabbedPanel .Tabs::-webkit-scrollbar-thumb, .TabbedPanel .Tabs:hover::-webkit-scrollbar-thumb { background: #454545; }
#scriptTab { display: none !important; }

.Button { padding: 5px 8px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); font-size: 11px; font-weight: 400; text-transform: none; }
.Button:hover { color: var(--bright); background: #202020; border-color: #666; }
.Button.selected { color: var(--bright); background: #282828; border-color: #777; }
.Button:disabled { color: #5e5e5e; cursor: default; }
.Input, .TextArea { color: var(--ink); background: var(--surface); border: 1px solid var(--line); font-size: 11px; }
.Input:focus, .TextArea:focus { border-color: #777; }
.Input.Number { color: var(--ink) !important; background: var(--surface); border: 1px solid var(--line); padding: 3px; font-size: 11px; }
.Select { min-height: 24px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 3px 4px; font-size: 11px; text-transform: none; }
.Select:hover { color: var(--bright); background: #202020; border-color: #666; }
input[type="color"] { height: 22px; padding: 3px; border: 1px solid var(--line); background: var(--surface); }
input[type="checkbox"] { appearance: none; position: relative; width: 24px; height: 14px; margin: 0 6px 0 0; padding: 0; border: 1px solid #626262; background: transparent; vertical-align: middle; cursor: pointer; }
input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 6px; height: 6px; background: #555; }
input[type="checkbox"]:checked::after { left: 13px; background: #b0b0b0; }
input[type="range"] { accent-color: #a0a0a0 !important; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid #a0a0a0; outline-offset: 2px; }

.Outliner, .Listbox { color: var(--ink); background: var(--bg); border: 1px solid var(--line); font-size: 12px; }
.Outliner .option, .Listbox .ListboxItem { padding: 6px 5px; border-top: 1px solid transparent; border-bottom: 1px solid transparent; color: var(--muted); }
.Outliner .option:hover, .Listbox .ListboxItem:hover { color: var(--bright); background: var(--hover); }
.Outliner .option.active, .Listbox .ListboxItem.active { color: var(--bright); background: #111; border-color: #555; }
#outliner .type, #outliner .Object3D, #outliner .Mesh, #outliner .Light, #outliner .Camera, #outliner .Scene, #outliner .Geometry, #outliner .Material, #outliner .Line, #outliner .LineSegments, #outliner .Points, #outliner .Script { color: #777; }
#outliner .option.active .type { color: #bbb; }

#toolbar { height: 34px; gap: 0; border: 1px solid #454545; border-radius: 0; background: var(--bg); }
#toolbar .Button, #toolbar .Input { height: 32px; border: 0; border-right: 1px solid var(--line); background: var(--bg); }
#toolbar .Button.selected { background: #303030; }
#toolbar .Button:hover { background: #202020; }
#toolbar .Button img { opacity: .7; filter: grayscale(1) invert(1); }
#toolbar .Button:last-child { border-right: 0; }
#resizer:hover, #resizer:active, #animation-resizer:hover, #animation-resizer:active { background: #555; transition: none; }
#animation { background: var(--surface); border-color: var(--line); }
#animation .Panel { border-color: var(--line) !important; }
#animation .Text { color: var(--muted); font-size: 11px; }
#animation .timeline-container { background: var(--bg); }
#animation input { color: var(--ink) !important; }

dialog { border-radius: 0 !important; border-color: #454545 !important; background: var(--bg) !important; color: var(--ink) !important; font-family: var(--font); box-shadow: none !important; }
.Dialog-content { background: var(--bg); border: 1px solid #454545; }
.Dialog-title { background: var(--surface); border-bottom: 1px solid var(--line); color: var(--ink); font-size: 12px; text-transform: none; }
.Dialog-body .Row .Label { color: var(--muted); font-size: 11px; }
.TextureParametersDialog-groupHeading { color: var(--muted); border-color: var(--line); font-weight: 400; }
.TextureParametersDialog-preview canvas { border-color: var(--line); }
.read-only #viewport { bottom: 0; }
.viewer-viewport-controls { position: absolute; top: 10px; right: 10px; z-index: 1; }
.viewer-viewport-controls .Select { min-width: 110px; }
.read-only #menubar { display: flex; align-items: center; gap: 12px; padding: 0 12px; color: var(--muted); font-size: 11px; }
.viewer-menubar-status, .viewer-menubar-actions { display: flex; align-items: center; gap: 8px; }
.viewer-menubar-status { min-width: 0; }
.viewer-menubar-status #fiend-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.viewer-menubar-actions { margin-left: auto; flex-shrink: 0; }
.read-only #menubar .fiend-button { flex-shrink: 0; padding: 3px 8px; font-size: 11px; white-space: nowrap; }
.viewer-heading { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); font: 11px/1.5 var(--font); font-weight: 400; color: var(--muted); text-transform: uppercase; }
.viewer-tree { max-height: 55vh; overflow: auto; padding: 8px 0; }
.viewer-object { display: block; width: 100%; padding: 7px 16px; border: 1px solid transparent; background: transparent; color: var(--muted); text-align: left; font: 11px/1.5 var(--font); white-space: nowrap; }
.viewer-object:hover { color: var(--bright); background: var(--hover); }
.viewer-object.selected { color: var(--bright); background: var(--surface); border-color: #555; }
.viewer-properties { display: grid; grid-template-columns: 75px minmax(0, 1fr); gap: 12px; padding: 16px; margin: 0; font-size: 11px; }
.viewer-properties dt { color: var(--muted); }
.viewer-properties dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
#fiend-activity { position: fixed; bottom: 43px; left: 16px; z-index: 4; color: #888; font: 9px/1.5 var(--font); pointer-events: none; }
body.loading #viewport { opacity: .2; }
body.loading::after { content: "Loading scene…"; position: absolute; left: 30%; top: 45%; color: var(--muted); font: 12px var(--font); }

@media (max-width: 1000px) {
  #fiend-header { height: 94px; flex-wrap: wrap; align-content: center; gap: 12px 16px; padding: 10px 16px; }
  #fiend-header .header-actions { width: 100%; gap: 6px; }
  #menubar { top: var(--menu-top, 94px); }
  #viewport, #sidebar, #resizer, #script, #player { top: var(--content-top, 130px); }
}
@media (min-width: 1001px) and (max-width: 1200px) {
  #fiend-header { gap: 12px; padding: 0 12px; }
  #fiend-header .fiend-button { padding: 6px; font-size: 10px; }
  .fiend-title { padding-left: 12px; }
}
@media (max-width: 600px) {
  body.scene-editor { --content-top: 72px; }
  .scene-editor #menubar { height: 72px; flex-wrap: wrap; }
  .scene-editor .fiend-menubar-actions { width: 100%; height: 36px; justify-content: flex-end; }
  #fiend-header { padding: 10px 12px; gap: 12px; }
  #fiend-header .header-actions { overflow-x: auto; }
  #fiend-header .fiend-button { padding: 5px 8px; font-size: 10px; }
  .fiend-title { padding-left: 12px; font-size: 11px; }
  #fiend-status { font-size: 10px; }
  #menubar .menu .title { padding: 10px; }
  .scene-editor #menubar .menu .title { padding: 10px 4px; font-size: 10px; }
  .fiend-menubar-actions { gap: 8px; padding: 0 6px; }
  .fiend-menubar-actions .fiend-button { padding: 3px 6px; font-size: 10px; }
  .fiend-menubar-actions #fiend-status { max-width: 65px; overflow: hidden; text-overflow: ellipsis; }
  #viewport, #script, #player { top: var(--content-top, 130px); right: 0; bottom: 300px !important; height: auto !important; }
  #sidebar { top: calc(100% - 300px); height: 300px; width: 100%; min-width: 0; border-top: 1px solid var(--line); border-left: 0; overflow-x: auto; }
  #toolbar { bottom: 312px !important; }
  #fiend-activity { display: none; }
  .read-only #menubar { gap: 6px; padding: 0 6px; }
  .viewer-menubar-status, .viewer-menubar-actions { gap: 4px; }
  .read-only #menubar .fiend-button { padding: 3px 5px; font-size: 10px; }
  .viewer-tree { max-height: 150px; }
}
