:root {
  color-scheme: dark;
  --bg: #111111;
  --sidebar: #191919;
  --surface: #1b1b1b;
  --surface-up: #222222;
  --line: #2e2e2e;
  --text: #dfddda;
  --muted: #969692;
  --accent: #b8d4bd;
  --accent-hover: #d0e2d3;
  --selected: #2b302d;
  --green: #b8d4bd;
  --font: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .4; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon { width: 17px; height: 17px; flex-shrink: 0; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

/* App chrome */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 184px; padding: 24px 12px 17px; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.brand-mark { display: flex; align-items: center; gap: 9px; padding: 0 5px; font-size: 21px; font-weight: 600; letter-spacing: -.8px; }
.brand-mark > svg { width: 27px; height: 27px; padding: 4px; color: #c4d1c5; background: #2b302d; border: 1px solid #414942; border-radius: 5px; stroke-width: 2; }
.nav-stack { display: flex; flex-direction: column; gap: 5px; margin-top: 32px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid transparent; background: none; border-radius: 5px; color: #aaa9a5; text-align: left; font-size: 13px; }
.nav-item > svg { width: 17px; height: 17px; }
.nav-item:hover { background: #242424; color: #e2e1dc; }
.nav-item.active { background: var(--selected); color: var(--accent); }
.nav-count { margin-left: auto; font-size: 11px; color: #9faaa0; }
.sidebar-bottom { margin-top: auto; padding: 15px 7px 0; border-top: 1px solid #303030; display: flex; align-items: center; gap: 7px; font-size: 10px; line-height: 1.4; color: #8d8d87; }
.local-orb { width: 4px; height: 4px; flex-shrink: 0; border-radius: 50%; background: #a3afa1; }
.app-shell { margin-left: 184px; }
.topbar { height: 58px; padding: 0 30px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); background: #141414; }
.workspace-title, .topbar-title { font-size: 14px; font-weight: 400; color: #c9c8c2; }
.wordmark { font-size: 18px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.engine-pill { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 4px; padding: 6px 0 6px 10px; background: none; color: #92948d; font-size: 11px; }
.engine-pill:hover { color: #d8ddd5; }
.engine-pill .icon { width: 12px; height: 12px; margin-left: 4px; }
.status-dot { width: 4px; height: 4px; display: inline-block; flex-shrink: 0; border-radius: 50%; background: #999d96; }
.status-dot.ready { background: var(--accent); }
main { max-width: 1530px; margin: 0 auto; padding: 30px 30px 20px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
h1 { font-size: 25px; font-weight: 500; letter-spacing: -.6px; line-height: 1.3; }
.page-heading p { color: var(--muted); font-size: 13px; margin-top: 7px; }
.eyebrow { color: #969a92; font-size: 11px; font-weight: 400; letter-spacing: 0; }

/* Source controls */
.studio-grid { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 20px; align-items: start; }
.creation-panel { padding: 19px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 22px; margin-bottom: 20px; }
.panel-heading h2 { font-size: 13px; font-weight: 500; }
.panel-heading > span { font-size: 10px; color: #85857f; }
.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.field-heading label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 400; }
.step-number { color: #999b93; font-size: 10px; }
.small-tag { padding: 1px 5px; border: 1px solid #333; border-radius: 3px; color: #81817a; font-size: 9px; }
.drop-zone { position: relative; min-height: 128px; overflow: hidden; border: 1px dashed #3b3b39; border-radius: 4px; background: #171717; }
.drop-zone.dragging { background: #232923; border-color: var(--accent); }
.drop-zone.has-file { border-style: solid; border-color: #3e433e; }
.drop-zone:focus-within { border-color: #9da99d; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0,0,0,0); }
.drop-idle { padding: 17px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.upload-icon { width: 25px; height: 25px; color: #878a80; margin-bottom: 9px; }
.upload-icon .icon { width: 24px; height: 24px; stroke-width: 1.25; }
.upload-icon > span { display: none; }
.drop-idle > p { font-size: 12px; color: #cbc9c3; }
.drop-idle > span { font-size: 11px; color: #999995; margin-top: 2px; }
.drop-idle small { font-size: 10px; color: #797975; margin-top: 9px; }
.inline-upload { padding: 0; border: 0; background: none; color: #bacfbd; font: inherit; }
.inline-upload:hover { text-decoration: underline; }
.field-hint { margin-top: 7px; color: #92928e; font-size: 11px; line-height: 1.6; }
.field-hint .inline-upload { display: inline; margin-left: 4px; font-size: 11px; }
.ingredient-connector { display: none; }
.upload-section + .upload-section, .ingredient-connector + .upload-section { margin-top: 21px; }
.upload-preview { height: 150px; position: relative; background: #0e0e0e; }
.upload-preview > img, .upload-preview > video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-upload-preview { height: 150px; }
.video-upload-preview > video { height: calc(100% - 29px); }
.upload-file-bar { position: absolute; inset: auto 0 0; height: 29px; padding: 3px 6px 3px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #202020ed; border-top: 1px solid #333; }
.upload-file-bar > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; color: #b5b6ad; }
.icon-button { border: 0; background: none; color: #a3a69c; padding: 5px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.icon-button:hover { background: #333; color: #e3e6dd; }
.icon-button .icon { width: 15px; height: 15px; }
.settings-section { border-top: 1px solid #303030; padding-top: 18px; margin-top: 20px; }
.settings-section h3 { font-size: 12px; font-weight: 400; }
.muted-icon { display: none; }
.settings-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; margin-top: 14px; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
legend { padding: 0; font-size: 11px; color: #979792; margin-bottom: 7px; }
.segmented-control { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #323232; border-radius: 4px; background: #161616; }
.segmented-control label { flex: 1; position: relative; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented-control span { display: block; padding: 5px 4px; text-align: center; white-space: nowrap; font-size: 10px; border: 1px solid transparent; border-radius: 3px; color: #a5a79f; }
.segmented-control input:checked + span { background: #2c322d; border-color: #454c46; color: #c9ddcc; }
.segmented-control input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-label { display: block; color: #a9aba3; font-size: 11px; margin: 14px 0 7px; }
select { width: 100%; padding: 8px 10px; border: 1px solid #343434; border-radius: 4px; background: #222; color: #d5d7cf; font-size: 12px; }
.background-setting .field-hint { font-size: 10px; color: #858580; }
.generate-button { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; margin-top: 19px; padding: 11px 14px; border: 1px solid #c5d3c6; border-radius: 4px; background: #b9cdbb; color: #18211b; font-size: 13px; font-weight: 500; }
.generate-button:not(:disabled):hover { background: #cedbcf; }
.generate-button > .icon:last-child { display: none; }
.generate-button .icon { width: 15px; height: 15px; }
.generate-button:disabled { opacity: 1; background: #2b302c; border-color: #363d37; color: #7f8b80; }
.generate-hint { margin-top: 9px; color: #898984; font-size: 10px; text-align: center; line-height: 1.5; }
.inline-error { padding: 10px 12px; margin: 12px 0; border: 1px solid #614a45; border-radius: 4px; background: #2c2220; color: #dfb3a9; font-size: 12px; overflow-wrap: anywhere; }

/* Preview */
.output-panel { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.output-heading { min-height: 52px; padding: 15px 19px; margin: 0; border-bottom: 1px solid var(--line); }
.output-heading > div { display: flex; align-items: center; gap: 10px; }
.format-tag { font-size: 10px; color: #85867f; font-weight: 400; }
.live-badge { font-size: 10px; color: #898e83; }
.preview-stage { position: relative; min-height: 470px; height: min(58vh,650px); display: grid; place-items: center; overflow: hidden; background: #141414; }
.empty-stage { text-align: center; max-width: 300px; padding: 30px; }
.empty-preview-icon, .empty-icon { color: #70706b; margin: 0 auto 16px; }
.empty-preview-icon .icon, .empty-preview-icon svg { width: 34px; height: 34px; stroke-width: 1; }
.empty-stage h3 { font-size: 14px; font-weight: 400; color: #bbbbb6; }
.empty-stage > p { font-size: 12px; line-height: 1.8; color: #81817c; margin-top: 6px; }
.stage-watermark-note { position: absolute; bottom: 15px; left: 15px; right: 15px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 10px; color: #777772; pointer-events: none; }
.stage-watermark-note .icon { width: 12px; height: 12px; }
.preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 51px; padding: 12px 17px; border-top: 1px solid var(--line); font-size: 11px; color: #989893; }
.preview-footer > div { display: flex; align-items: center; gap: 6px; }
.subtle-dot { display: none; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0; border: 0; background: none; color: #bdccbb; font-size: 12px; white-space: nowrap; }
.text-button:not(:disabled):hover { color: #e0eadd; }
.text-button .icon { width: 14px; height: 14px; }
.job-state { max-width: 400px; width: 100%; padding: 35px 28px; text-align: center; }
.render-orb { color: #aabda6; margin-bottom: 17px; }
.render-orb .icon { width: 26px; height: 26px; }
.job-state .eyebrow { font-size: 10px; color: #858580; }
.job-state h3 { font-size: 17px; font-weight: 400; margin: 9px 0; }
.job-state > p { color: #979792; font-size: 12px; line-height: 1.7; }
.progress-track { height: 3px; background: #343b30; margin: 22px 0; border-radius: 1px; overflow: hidden; }
.progress-track > div { height: 100%; width: 0; background: #b8c8ad; transition: width .15s; }
.job-state.error .progress-track { display: none; }
.job-state.error .render-orb { color: #cb9f91; }
.job-state .secondary-button { margin-top: 4px; }
.result-stage { position: absolute; inset: 0; background: #0a0a0a; padding: 12px; }
.result-stage video { width: 100%; height: 100%; object-fit: contain; }
.page-footer { font-size: 10px; color: #757570; padding-top: 18px; display: flex; justify-content: space-between; }
.secondary-button, .primary-button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; border: 1px solid #3b4036; border-radius: 4px; padding: 8px 12px; background: #252922; color: #c8cebf; font-size: 12px; }
.secondary-button:hover { background: #30372b; }
.primary-button { background: #b9cdbb; color: #1c281e; border-color: #c4d7c6; }
.primary-button:hover { background: #d0dfd1; }
.secondary-button .icon, .primary-button .icon { width: 15px; height: 15px; }

/* Saved files and documentation */
.library-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 16px; border-bottom: 1px solid var(--line); }
.library-toolbar h2 { font-size: 13px; font-weight: 400; }
.library-toolbar h2 > span { color: #8a9380; margin-left: 7px; font-size: 11px; }
.library-storage-note { font-size: 11px; color: #898984; margin-top: 12px; }
.library-empty { min-height: 380px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.empty-icon .icon { width: 28px; height: 28px; stroke-width: 1.3; }
.library-empty h2 { font-size: 17px; font-weight: 400; }
.library-empty p { font-size: 12px; color: #93938e; margin: 9px 0 20px; line-height: 1.7; }
.library-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-top: 23px; }
.library-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.library-media { position: relative; height: 230px; background: #101010; display: grid; place-items: center; }
.library-media > video { width: 100%; height: 100%; object-fit: contain; }
.library-status { position: absolute; top: 10px; left: 10px; padding: 3px 6px; background: #20221eef; color: #a8b39e; border-radius: 3px; font-size: 9px; }
.library-card-content { padding: 14px; }
.library-card h3 { font-size: 13px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-card time { display: block; font-size: 10px; color: #898984; margin: 4px 0 15px; }
.library-card-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.library-card-footer > span { font-size: 10px; color: #91918b; margin-right: auto; }
.library-card-footer .text-button { font-size: 11px; }
.library-card-footer .icon-button { padding: 3px; }
.engine-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(250px,1fr); gap: 20px; align-items: start; }
.engine-main { display: grid; gap: 18px; }
.settings-card { padding: 23px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.settings-card h2 { font-size: 16px; font-weight: 400; margin-bottom: 12px; }
.settings-card p { font-size: 13px; line-height: 1.85; color: #a7a7a2; }
.settings-card-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.settings-card-heading h2 { margin-bottom: 3px; }
.settings-card-heading p { font-size: 11px; }
.engine-icon { color: #a8ba9e; }
.connection-indicator { margin-left: auto; font-size: 10px; color: #afc3a2; }
.engine-diagnostic { display: flex; gap: 8px; align-items: flex-start; padding: 13px 0; margin: 15px 0; border-top: 1px solid #30302d; border-bottom: 1px solid #30302d; }
.engine-diagnostic .status-dot { margin-top: 8px; }
.engine-diagnostic p { font-size: 12px; }
.hardware-card > p + p { margin-top: 13px; }
.setup-sidebar h2 { font-size: 16px; margin-bottom: 23px; }
.setup-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.setup-steps li { display: flex; gap: 11px; }
.setup-steps li > span { color: #85857f; font-size: 11px; padding-top: 3px; }
.setup-steps h3 { font-size: 13px; font-weight: 400; }
.setup-steps p { margin-top: 5px; font-size: 12px; }
.privacy-note { border-top: 1px solid #30302d; margin-top: 22px; padding-top: 18px; display: flex; gap: 10px; }
.privacy-note .icon { color: #8d9e80; margin-top: 4px; }
.privacy-note p { font-size: 11px; }
.settings-card .engine-fineprint { font-size: 11px; color: #858580; margin: 15px 0 20px; }

/* Joint editor */
.rig-dialog { width: min(800px,calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; padding: 23px; background: #191919; color: var(--text); border: 1px solid #41413d; border-radius: 7px; box-shadow: 0 20px 70px #0008; }
.rig-dialog::backdrop { background: #000b; }
.rig-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.rig-dialog h2 { font-size: 21px; font-weight: 400; letter-spacing: -.3px; }
.rig-dialog > p { color: #a3a39e; font-size: 12px; line-height: 1.8; margin-top: 9px; }
.rig-editor-layout { display: grid; grid-template-columns: minmax(0,1fr) 190px; gap: 20px; margin-top: 20px; }
.rig-canvas-wrap { min-height: 280px; display: flex; align-items: center; justify-content: center; background: #0d0d0d; border: 1px solid #343430; border-radius: 4px; overflow: hidden; }
.rig-canvas-wrap > canvas { max-width: 100%; width: auto; height: auto; max-height: 55vh; display: block; touch-action: none; cursor: crosshair; }
.rig-joints-panel input[type=range] { width: 100%; accent-color: #b6c6a9; }
.rig-joints-panel > .form-label:first-child { margin-top: 0; }
.rig-joints-panel .field-hint { margin-top: 9px; font-size: 11px; }
.rig-key { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 20px; font-size: 10px; color: #a0a09b; }
.rig-key > span { width: 6px; height: 6px; border-radius: 50%; background: #d8d8d4; }
.rig-key > span:nth-child(2) { margin-left: 8px; background: #b8d4bd; }
.rig-dialog-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.toast { position: fixed; bottom: 22px; left: calc(50% + 92px); transform: translateX(-50%); max-width: calc(100vw - 230px); padding: 11px 16px; border: 1px solid #4c5542; border-radius: 5px; background: #252a20; color: #d1dbc4; font-size: 12px; z-index: 100; }
.toast.error { color: #e6b9ad; background: #30231f; border-color: #61483f; }

@media (min-width:1500px) {
  .studio-grid { grid-template-columns: 365px minmax(0,1fr); gap: 24px; }
  .preview-stage { min-height: 540px; }
}
@media (max-width:1100px) {
  .sidebar { width: 166px; padding-inline: 10px; }
  .brand-mark { font-size: 19px; gap: 7px; padding-inline: 3px; }
  .brand-mark > svg { width: 25px; height: 25px; }
  .app-shell { margin-left: 166px; }
  .topbar { padding-inline: 23px; }
  main { padding: 25px 23px 20px; }
  .studio-grid { grid-template-columns: 310px minmax(0,1fr); gap: 16px; }
  .creation-panel { padding: 16px; }
  .settings-row { gap: 8px; }
  .preview-footer { align-items: flex-start; flex-direction: column; gap: 8px; }
  .library-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .engine-grid { grid-template-columns: 1fr; }
}
@media (max-width:850px) {
  .sidebar { width: 60px; padding-inline: 8px; }
  .brand-mark { justify-content: center; padding: 0; }
  .brand-mark > span { display: none; }
  .nav-item { padding: 11px; justify-content: center; position: relative; }
  .nav-item > span:not(.nav-count) { display: none; }
  .nav-count { position: absolute; top: 1px; right: 1px; font-size: 9px; }
  .sidebar-bottom > span:not(.local-orb) { display: none; }
  .sidebar-bottom { justify-content: center; padding-inline: 0; }
  .app-shell { margin-left: 60px; }
  .studio-grid { grid-template-columns: 290px minmax(0,1fr); }
  .toast { left: calc(50% + 30px); max-width: calc(100vw - 100px); }
}
@media (max-width:680px) {
  .sidebar { inset: auto 0 0; width: 100%; height: 57px; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 0 15px; background: #191919; }
  .brand-mark, .sidebar-bottom { display: none; }
  .nav-stack { width: 100%; margin: 0; flex-direction: row; align-items: center; justify-content: space-around; gap: 4px; }
  .nav-item { flex: 1; gap: 7px; width: auto; padding: 8px 10px; font-size: 11px; }
  .nav-item > span:not(.nav-count) { display: inline; }
  .nav-count { position: static; margin-left: 0; }
  .app-shell { margin-left: 0; padding-bottom: 57px; }
  .topbar { height: 52px; padding-inline: 18px; }
  main { padding: 23px 17px 20px; }
  h1 { font-size: 23px; }
  .page-heading { margin-bottom: 21px; }
  .page-heading p { font-size: 12px; }
  .studio-grid { display: flex; flex-direction: column; gap: 18px; }
  .creation-panel, .output-panel { width: 100%; }
  .creation-panel { padding: 18px; }
  .drop-zone { min-height: 125px; }
  .settings-row { grid-template-columns: 1fr 1.5fr; gap: 14px; }
  .segmented-control span { font-size: 11px; }
  .preview-stage { min-height: 350px; height: 440px; }
  .preview-footer { flex-direction: row; align-items: center; font-size: 10px; }
  .preview-footer .text-button { font-size: 11px; }
  .library-grid { grid-template-columns: 1fr; }
  .library-media { height: 260px; }
  .library-empty { min-height: 330px; }
  .settings-card { padding: 20px; }
  .rig-dialog { padding: 18px; }
  .rig-editor-layout { grid-template-columns: 1fr; }
  .rig-canvas-wrap { min-height: 220px; }
  .rig-canvas-wrap > canvas { max-height: 44vh; }
  .rig-joints-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 15px; }
  .rig-joints-panel > .form-label:first-child, .rig-joints-panel > select, .rig-joints-panel > .field-hint { grid-column: 1/-1; }
  .rig-joints-panel input[type=range] { grid-row: 5; }
  .rig-key { display: none; }
  .toast { left: 50%; bottom: 70px; width: max-content; max-width: calc(100vw - 30px); font-size: 11px; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}


.rig-status { min-height: 1.5em; margin-top: 7px; }
.rig-status[data-state="ready"] { color: #bdccbb; }
.rig-status[data-state="review"] { color: #dfbc77; }
.rig-status[data-state="error"] { color: #dfb3a9; }
