:root { --bg: #07090d; --panel: #10141c; --line: #263040; --text: #dbe4f0; --dim: #8393a7; --accent: #4fd8ff; color-scheme: dark; }
:root[data-theme="light"] { --bg: #e9edf3; --panel: #f8fafc; --line: #c5cedb; --text: #18202c; --dim: #5a6778; --accent: #0a6fb8; color-scheme: light; }
:root[data-theme="night"] { --bg: #000; --panel: #0c0404; --line: #3a1412; --text: #d9776b; --dim: #8e4a42; --accent: #ff5a48; color-scheme: dark; }
* { box-sizing: border-box; scrollbar-color: var(--line) transparent; }
html, body { height: 100%; margin: 0; }
body { display: flex; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, sans-serif; }

#library { display: flex; flex-direction: column; width: 240px; flex: none; padding: 16px 16px 8px; background: var(--panel); border-right: 1px solid var(--line); }
#library .logo { display: block; width: 100%; max-width: 208px; margin-bottom: 12px; }
#library h1 { margin: 0; font-size: 26px; letter-spacing: .2em; color: var(--accent); }
.tag { margin: 4px 0 16px; color: var(--dim); }
#machines { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
#library footer { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); color: var(--dim); }
#gear { padding: 0 4px; font-size: 22px; color: var(--dim); background: none; border: 0; cursor: pointer; }
#gear:hover { color: var(--accent); }

#settings { width: min(360px, calc(100vw - 32px)); padding: 16px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
#settings::backdrop { background: rgb(0 0 0 / .5); }
#settings header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#settings h2 { margin: 0; font-size: 18px; }
#settings header button { color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.setting { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.setting select, .setting button { min-width: 110px; padding: 4px 8px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; font: inherit; cursor: pointer; }
#machines button { width: 100%; padding: 8px 10px; margin-bottom: 4px; text-align: left; color: var(--text); background: none; border: 1px solid transparent; border-radius: 4px; font: inherit; cursor: pointer; }
#machines button:hover { border-color: var(--accent); }
#machines button:disabled { color: var(--dim); cursor: default; border-color: transparent; }
#machines small { display: block; color: var(--dim); }

#desktop { position: relative; flex: 1; overflow: hidden; }
.win { position: absolute; display: flex; flex-direction: column; min-width: 320px; min-height: 240px; background: #000; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; resize: both; }
.win.focused { border-color: var(--accent); }
.win header { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--panel); cursor: move; user-select: none; }
.win header span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win header button { color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.win iframe { flex: 1; width: 100%; border: 0; }
.win.dragging iframe { pointer-events: none; }

@media (max-width: 700px) {
  body { flex-direction: column; }
  #library { width: 100%; max-height: 40%; border-right: 0; border-bottom: 1px solid var(--line); }
  #library .logo { width: 72px; }
}
