/* The Doroobi 3D Studio: a dark workspace like desktop 3D tools, with Doroobi's teal for what is active. */
@font-face { font-family: 'Lama Sans'; src: url('../fonts/LamaSans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Lama Sans'; src: url('../fonts/LamaSans-700.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #1b1f22; --panel: #262c30; --panel-2: #2f363b; --line: #384046; --field: #1f2427; --text: #e3e7ea; --muted: #9aa6ae;
  --teal: #0E7C7B; --teal-2: #3CC2B6; --accent: #5FE0D4; --sun: #FFC93C; --coral: #FF6A3D; --bad: #ff9b85;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* hidden wins over the display set on a class */
html, body { height: 100%; margin: 0; }
body.st-body { background: var(--bg); color: var(--text); font: 13px/1.4 'Lama Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select, textarea { background: var(--field); border: 1px solid #3d464c; border-radius: 5px; padding: 4px 6px; min-width: 0; width: 100%; }
input[type='checkbox'] { width: auto; accent-color: var(--teal-2); }
input[type='color'] { padding: 1px; height: 28px; cursor: pointer; }
input[type='number'] { font-variant-numeric: tabular-nums; }
kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: #a9b4bb; }

#studio { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.st-loading, .st-fatal { margin: auto; padding: 24px; color: var(--muted); text-align: center; max-width: 520px; }

/* ---------------------------------------------------------------- header and menus */
.st-top { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: #171a1d; border-bottom: 1px solid var(--line); min-width: 0; }
.st-brand { display: flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; margin-inline-end: 6px; }
.st-brand img { width: 22px; height: 22px; }
.st-menus { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.st-menubtn { background: none; border: 0; padding: 4px 8px; border-radius: 4px; white-space: nowrap; }
.st-menubtn:hover, .st-menubtn:focus-visible { background: var(--panel-2); }
.st-name { width: 210px; flex: 0 1 auto; background: #22282c; }
.st-savestate { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-savestate.bad { color: var(--bad); }
.st-grow { flex: 1 1 auto; }
.st-link { color: var(--muted); text-decoration: none; padding: 4px 8px; white-space: nowrap; }
.st-link:hover { color: var(--text); }
.st-who { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

.st-popup { position: fixed; z-index: 50; background: #2a3035; border: 1px solid #454e55; border-radius: 8px; padding: 4px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45); display: flex; flex-direction: column; max-height: 80vh; overflow: auto; }
.st-popup button { display: flex; justify-content: space-between; align-items: center; gap: 22px; background: none; border: 0; padding: 6px 10px; border-radius: 5px; text-align: start; white-space: nowrap; }
.st-popup button:hover, .st-popup button:focus-visible { background: #3a4349; outline: none; }
.st-popup button.on span::before { content: '✓ '; color: var(--accent); }
.st-popup hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; width: auto; }

/* ---------------------------------------------------------------- toolbar */
.st-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 8px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.st-tb { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 6px; border: 1px solid transparent; background: none; color: #d6dce0; }
.st-tb svg { width: 20px; height: 20px; }
.st-tb:hover { background: #323a40; }
.st-tb.on { background: rgba(14, 124, 123, .25); border-color: var(--teal-2); color: var(--accent); }
.st-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: 0 0 auto; }
.st-gridsel { width: auto; flex: 0 0 auto; }
.st-sendbtn { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.st-sendbtn svg { width: 16px; height: 16px; }
.st-phone { display: none; }

/* ---------------------------------------------------------------- the three columns */
.st-main { display: grid; grid-template-columns: 236px minmax(0, 1fr) 300px; min-height: 0; }
.st-lib, .st-cmd { background: var(--panel); overflow: auto; min-height: 0; scrollbar-width: thin; }
.st-lib { border-inline-end: 1px solid var(--line); padding: 8px; }
.st-cmd { border-inline-start: 1px solid var(--line); }
.st-lib h2 { font-size: 13px; margin: 2px 2px 8px; }
.st-libsearch { margin-bottom: 6px; }
.st-cats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.st-cats button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.st-cats button[aria-selected='true'] { background: var(--teal); border-color: var(--teal); color: #fff; }
.st-libgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.st-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 6px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.st-tile:hover { border-color: var(--teal-2); }
.st-tile:active { cursor: grabbing; }
.st-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; pointer-events: none; }
.st-tile span { font-size: 12px; text-align: center; line-height: 1.25; }
.st-tile-x { position: absolute; top: 2px; inset-inline-end: 4px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: #1f2427; color: var(--muted); font-size: 14px; }
.st-tile-add { cursor: pointer; justify-content: center; min-height: 110px; }
.st-tile-add b { font-size: 26px; color: var(--accent); }
.st-dragchip { position: fixed; z-index: 60; pointer-events: none; background: var(--teal); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, .4); }

/* ---------------------------------------------------------------- viewports */
.st-views { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #16191c; }
.st-canvas { position: absolute; inset: 0; display: block; touch-action: none; outline: none; }
.st-vpframe { position: absolute; pointer-events: none; border: 1px solid transparent; z-index: 1; }
.st-vpframe.on { border-color: var(--sun); }
.st-vplabel { position: absolute; display: flex; gap: 0; z-index: 2; font-size: 12px; direction: ltr; background: rgba(18, 21, 24, .55); border-radius: 5px; padding: 0 2px; }
.st-vplabel .st-menubtn { padding: 1px 3px; color: #d2d8dc; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); }
.st-vplabel .st-menubtn:hover { color: #fff; background: rgba(0, 0, 0, .35); }
.st-vpnote { position: absolute; z-index: 3; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: rgba(18, 21, 24, .85); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12px; white-space: nowrap; }
.st-vpnote .st-btn { padding: 2px 10px; }
.st-band { position: absolute; border: 1px dashed #fff; background: rgba(95, 224, 212, .12); pointer-events: none; z-index: 3; }
.st-offmap { position: fixed; left: -12000px; top: 0; pointer-events: none; visibility: hidden; }

/* ---------------------------------------------------------------- command panel */
.st-tabs { display: flex; position: sticky; top: 0; z-index: 1; background: var(--panel); border-bottom: 1px solid var(--line); }
.st-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 4px; color: var(--muted); }
.st-tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--teal-2); }
.st-fold { border-bottom: 1px solid var(--line); padding: 8px 10px 10px; }
.st-fold h3 { font-size: 12px; font-weight: 700; color: #a9bac4; margin: 0 0 6px; letter-spacing: .02em; }
.st-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) auto; gap: 6px; align-items: center; margin: 4px 0; }
.st-field > span { color: #c5cdd2; }
.st-field em { font-style: normal; color: var(--muted); font-size: 12px; min-width: 12px; }
.st-check { display: flex; gap: 7px; align-items: center; margin: 5px 0; }
.st-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 6px; }
.st-btn { background: #323a40; border: 1px solid #434c53; padding: 5px 10px; border-radius: 6px; line-height: 1.3; }
.st-btn:hover:not(:disabled) { background: #3a4349; }
.st-btn.on { border-color: var(--teal-2); color: var(--accent); background: rgba(14, 124, 123, .25); }
.st-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.st-primary:hover:not(:disabled) { background: #0f8d8b; }
.st-danger { color: var(--bad); }
.st-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.st-col { flex-direction: column; align-items: stretch; }
.st-hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.st-warn { color: var(--sun); font-size: 12px; margin: 6px 0; }
.st-sendbtn.st-changed::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--sun); margin-inline-start: 2px; }
.st-badge.pending { background: #6b5a1f; }
.st-badge.replaced { opacity: .7; }
.st-tips { margin: 6px 0; padding-inline-start: 18px; color: #c5cdd2; }
.st-tips li { margin: 4px 0; }
.st-xyz { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.st-xyz label { display: flex; align-items: center; gap: 3px; }
.st-xyz span { color: var(--muted); font-size: 11px; }
.st-array { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.st-array input { width: 58px; }
.st-array em { font-style: normal; color: var(--muted); }
.st-outliner, .st-history, .st-replaced, .st-projects, .st-designs, .st-results { list-style: none; margin: 6px 0 0; padding: 0; }
.st-outliner { max-height: 46vh; overflow: auto; }
.st-outliner li { display: flex; align-items: center; gap: 2px; border-radius: 5px; }
.st-outliner li.on { background: rgba(14, 124, 123, .3); }
.st-eye { background: none; border: 0; color: var(--muted); width: 24px; padding: 4px 0; }
.st-oname { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 8px; background: none; border: 0; padding: 4px 6px; text-align: start; }
.st-oname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-oname em { font-style: normal; color: var(--muted); font-size: 11px; white-space: nowrap; }
.st-history { max-height: 36vh; overflow: auto; }
.st-history button { width: 100%; display: flex; justify-content: space-between; gap: 8px; background: none; border: 0; padding: 4px 6px; border-radius: 5px; text-align: start; }
.st-history li.on button { background: rgba(14, 124, 123, .3); color: #fff; }
.st-history li.undone { opacity: .5; }
.st-history time { color: var(--muted); font-size: 11px; }
.st-replaced li { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 4px 0; font-size: 12px; }
.st-credit { color: var(--muted); font-size: 11px; padding: 10px; }

/* ---------------------------------------------------------------- status bar */
.st-status { display: flex; gap: 14px; align-items: center; padding: 3px 10px; background: #171a1d; border-top: 1px solid var(--line); font-size: 12px; white-space: nowrap; min-width: 0; overflow: hidden; }
.st-selinfo { min-width: 120px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.st-xyzbar { display: flex; gap: 8px; }
.st-xyzbar label { display: inline-flex; gap: 4px; align-items: center; }
.st-xyzbar span { color: var(--muted); }
.st-xyzbar input { width: 78px; padding: 2px 5px; }
.st-cursor { color: var(--muted); font-variant-numeric: tabular-nums; }
.st-prompt { overflow: hidden; text-overflow: ellipsis; color: #cfd6db; flex: 1; }
.st-prompt.bad { color: var(--bad); }

/* ---------------------------------------------------------------- dialogs */
.st-dialog { background: var(--panel); color: var(--text); border: 1px solid #454e55; border-radius: 12px; padding: 18px 20px; width: min(560px, calc(100vw - 32px)); max-height: 88vh; overflow: auto; }
.st-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.st-dialog h2 { margin: 0 32px 10px 0; font-size: 18px; }
[dir='rtl'] .st-dialog h2 { margin: 0 0 10px 32px; }
.st-dialog p { margin: 6px 0; }
.st-dialog .st-field { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; }
.st-x { position: absolute; top: 10px; inset-inline-end: 12px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--panel-2); font-size: 18px; line-height: 1; }
.st-dialog { position: fixed; }
.st-row { display: flex; gap: 6px; margin: 6px 0; }
.st-row input { flex: 1; }
.st-results button { width: 100%; text-align: start; background: none; border: 0; padding: 6px 8px; border-radius: 5px; }
.st-results button:hover { background: var(--panel-2); }
.st-placemap { height: 320px; border-radius: 8px; overflow: hidden; background: #16191c; margin: 8px 0; }
.st-nomap { display: grid; place-items: center; padding: 20px; color: var(--muted); text-align: center; }
.st-projects li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.st-projects li.on strong::after { content: ' •'; color: var(--accent); }
.st-projects img, .st-nothumb { width: 96px; height: 68px; object-fit: contain; border-radius: 6px; background: #1f2427; display: block; }
.st-projects strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-projects small { color: var(--muted); }
.st-designs li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.st-designs small { flex-basis: 100%; color: var(--muted); }
.st-designs a { color: var(--accent); }
.st-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); }
.st-badge.approved { background: var(--teal); color: #fff; }
.st-badge.rejected { background: #6b2f26; }
.st-msg { min-height: 1.4em; }
.st-msg.bad { color: var(--bad); }
.st-keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.st-keys dd { margin: 0; color: #c5cdd2; }
.st-howto { padding-inline-start: 20px; }
.st-howto li { margin: 6px 0; }

/* The account box (assets/account.js) inside the Studio's dialogs. */
.studio-form { display: grid; gap: 8px; margin: 8px 0; }
.studio-field { display: grid; gap: 4px; }
.studio-tabs { display: flex; gap: 4px; margin: 6px 0; }
.studio-tabs button { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.studio-tabs button[aria-selected='true'] { background: var(--teal); border-color: var(--teal); color: #fff; }
.studio-msg { min-height: 1.2em; margin: 4px 0; }
.studio-msg.bad { color: var(--bad); }
.studio-hint { color: var(--muted); font-size: 12px; }
.studio-link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
.acct-check { display: flex; gap: 8px; align-items: flex-start; }
.acct-check a { color: var(--accent); }
.btn { background: #323a40; border: 1px solid #434c53; padding: 7px 12px; border-radius: 6px; color: var(--text); text-decoration: none; display: inline-block; text-align: center; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }

/* MapLibre's buttons in the place picker, on the dark dialog. */
.st-placemap .maplibregl-ctrl-group { background: #fff; }

/* ---------------------------------------------------------------- phones and small tablets */
@media (max-width: 900px) {
  .st-main { grid-template-columns: minmax(0, 1fr); }
  .st-lib, .st-cmd { position: fixed; z-index: 20; top: 86px; bottom: 28px; width: min(320px, 88vw); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); display: none; }
  .st-lib { inset-inline-start: 0; }
  .st-cmd { inset-inline-end: 0; }
  #studio.lib-open .st-lib, #studio.cmd-open .st-cmd { display: block; }
  .st-phone { display: grid; }
  .st-name { width: 120px; }
  .st-savestate, .st-link, .st-cursor { display: none; }
  .st-sendbtn span { display: none; }
  .st-xyzbar input { width: 62px; }
  .st-tb { width: 38px; height: 38px; }
}
@media (max-width: 560px) {
  .st-brand span { display: none; }
  .st-xyzbar { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
