:root {
  --bg: #12151b; --panel: #1a1e26; --panel2: #222733; --line: #2e3442; --text: #e6e9ef; --muted: #8c94a6;
  --accent: #f5a524; --accent2: #ffbf4d; --ok: #3ecf8e; --err: #f2545b; --blue: #4c9aff;
  --radius: 8px; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
#app { display: flex; height: 100vh; }
#nav { width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; border-bottom: 1px solid var(--line); }
.brand .logo { font-size: 26px; }
.brand b { display: block; font-size: 15px; } .brand small { color: var(--muted); }
#nav nav { display: flex; flex-direction: column; gap: 2px; }
#nav nav button { background: none; border: 0; color: var(--text); text-align: left; padding: 10px; border-radius: var(--radius); cursor: pointer; font-size: 14px; display: flex; gap: 10px; align-items: center; }
#nav nav button:hover { background: var(--panel2); }
#nav nav button.active { background: var(--accent); color: #1a1300; font-weight: 600; }
#proj-box { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.proj-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#main { flex: 1; min-width: 0; overflow: auto; }
.view { display: none; padding: 20px 24px; min-height: 100%; }
.view.active { display: block; }
.view.full { padding: 0; height: 100%; }
#view-studio.active, #view-livery.active { display: flex; padding: 0; height: 100%; }

h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 18px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
p { line-height: 1.5; }
.muted { color: var(--muted); } .small { font-size: 12px; } .warn { color: var(--accent2); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: #47506a; background: #2a3040; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1300; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: #3a1d22; border-color: #6a2a33; color: #ffb3b8; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 7px; border-radius: 6px; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 20px; }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  background: #0f1217; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 13px; font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; line-height: 1.45; }
input[type=color] { width: 40px; height: 30px; border: 1px solid var(--line); background: none; border-radius: 6px; padding: 2px; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); width: 100%; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span:first-child { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
label.check { display: flex; gap: 8px; align-items: center; cursor: pointer; padding: 6px 0; }
.slider { display: flex; gap: 8px; align-items: center; }
.slider .num { width: 90px; flex: none; }
.dl-wrap { display: block; }

/* tabs / steps */
.steps { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.steps button { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 10px 14px; cursor: pointer; font-size: 13.5px; }
.steps button .n { display: inline-block; width: 20px; height: 20px; line-height: 20px; border-radius: 50%; background: var(--panel2); text-align: center; font-size: 11px; margin-right: 6px; }
.steps button.active { color: var(--text); border-bottom-color: var(--accent); }
.steps button.active .n { background: var(--accent); color: #1a1300; }
.step-foot { display: flex; justify-content: space-between; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

.builder { display: flex; gap: 20px; align-items: flex-start; }
.veh-list { width: 220px; flex: none; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; }
.veh-item { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.veh-item.active { border-color: var(--accent); background: #2a2416; }
.veh-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.veh-item .nm small { display: block; color: var(--muted); }
.builder-body { flex: 1; min-width: 0; }

.group { margin-bottom: 18px; }
.group > h3 { display: flex; align-items: center; gap: 8px; color: var(--accent2); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
details.adv { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; margin-top: 14px; }
details.adv > summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--muted); }
details.adv[open] > summary { color: var(--text); }
details.adv > div { padding-bottom: 16px; }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.preset { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px; text-align: center; cursor: pointer; color: var(--text); font-size: 13px; }
.preset:hover { border-color: var(--accent); }
.preset .ic { font-size: 26px; display: block; margin-bottom: 4px; }

.easy-sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px 24px; }
.easy { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.easy .top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.easy .top b { font-size: 14px; } .easy .top span { color: var(--accent2); font-variant-numeric: tabular-nums; }
.easy .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }

.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(255,255,255,.2); vertical-align: middle; flex: none; }
.swatch.big { width: 28px; height: 28px; }
.cp-btn { display: flex; align-items: center; gap: 8px; background: #0f1217; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; cursor: pointer; width: 100%; text-align: left; font-size: 12.5px; }
.cp-btn:hover { border-color: var(--accent); }
.cp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; max-height: 55vh; overflow: auto; margin-top: 10px; }
.cp-cell { display: flex; gap: 8px; align-items: center; background: var(--panel2); border: 1px solid transparent; color: var(--text); border-radius: 6px; padding: 5px; cursor: pointer; text-align: left; }
.cp-cell small { font-size: 11px; line-height: 1.2; }
.cp-cell:hover, .cp-cell.sel { border-color: var(--accent); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl tr:hover td { background: rgba(255,255,255,.02); }

.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--text); background: rgba(245,165,36,.05); }
.dz-icon { font-size: 26px; margin-bottom: 6px; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); } .big-icon { font-size: 46px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--panel2); color: var(--muted); }
.badge.ok { background: #173a2b; color: var(--ok); } .badge.warn { background: #3a2f16; color: var(--accent2); }
.tip { background: #1b2433; border: 1px solid #2b3a52; border-radius: 8px; padding: 10px 12px; color: #bcd2f2; font-size: 12.5px; line-height: 1.5; margin-bottom: 14px; }
code { background: #0f1217; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(760px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-foot:empty { display: none; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 420px; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4); transition: .3s; font-size: 13px; }
.toast.ok { border-left-color: var(--ok); } .toast.error { border-left-color: var(--err); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* editor layouts (studio + livery) */
.ed { display: flex; flex: 1; min-width: 0; height: 100%; }
.ed-tools { width: 56px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 4px; overflow-y: auto; }
.ed-tools button { width: 42px; height: 42px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--text); font-size: 18px; cursor: pointer; position: relative; flex: none; }
.ed-tools button:hover { background: var(--panel2); }
.ed-tools button.on { background: var(--accent); color: #1a1300; }
.ed-tools .sep { width: 34px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
.ed-center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ed-top { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-top .title { font-weight: 600; margin-right: 8px; }
.ed-canvas { flex: 1; position: relative; overflow: hidden; background: #0b0d11; }
.ed-canvas canvas { display: block; }
.ed-side { width: 300px; flex: none; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.ed-side section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ed-side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.ed-side .field { margin-bottom: 8px; }
.prop-row { display: grid; grid-template-columns: 70px 1fr; gap: 6px; align-items: center; margin-bottom: 6px; font-size: 12px; }
.prop-row > span { color: var(--muted); }
.vec3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.vec3 input { padding: 5px; font-size: 12px; }
.list { display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow-y: auto; }
.list-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; border: 1px solid transparent; }
.list-item:hover { background: var(--panel2); }
.list-item.sel { background: #2a2416; border-color: var(--accent); }
.list-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .icon-btn { padding: 2px 4px; font-size: 13px; }
.hud { position: absolute; left: 10px; bottom: 10px; font-size: 11.5px; color: var(--muted); background: rgba(10,12,16,.75); padding: 6px 9px; border-radius: 6px; pointer-events: none; line-height: 1.5; }
.viewcube { position: absolute; right: 10px; top: 10px; display: flex; gap: 4px; }
.viewcube button { background: rgba(26,30,38,.9); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; }
.viewcube button:hover { border-color: var(--accent); }
.tool-tip-label { font-size: 10px; color: var(--muted); text-align: center; margin-top: -2px; }

.xml-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.xml-area { width: 100%; height: 60vh; white-space: pre; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--panel2); border-radius: 6px; font-size: 12px; margin: 2px; }
@media (max-width: 900px) {
  #nav { width: 64px; } #nav nav button { font-size: 0; justify-content: center; } #nav nav button span { font-size: 18px; }
  .brand div, #proj-box { display: none; } .veh-list { width: 160px; } .ed-side { width: 240px; }
}

/* accounts */
#user-box { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
#user-box b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
#login[hidden], #app[hidden] { display: none; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login-card .brand { border: 0; padding: 0 0 6px; }
.login-card .err { color: var(--err); font-size: 13px; min-height: 18px; }
.login-switch { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-size: 13px; }
.login-card .field[hidden] { display: none; }
