/* ============================================================
   Formo Studio — custom layer on top of Tailwind
   ============================================================ */

:root {
  --rail-hover: #212836;
  --accent: #3b95ff;
}

* { -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; overscroll-behavior: none; touch-action: none; }

canvas#gl { display: block; touch-action: none; cursor: default; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3242; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4459; background-clip: padding-box; }
.no-scrollbar::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- top bar ---------- */
.topbtn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; min-width: 28px; padding: 0 6px;
  border-radius: 6px; color: #94a3b8; transition: background .12s, color .12s;
}
.topbtn:hover { background: var(--rail-hover); color: #e2e8f0; }
.topbtn:active { transform: translateY(0.5px); }
.topbtn[disabled] { opacity: .35; pointer-events: none; }

.menubtn {
  padding: 4px 9px; border-radius: 6px; color: #cbd5e1; transition: background .12s;
}
.menubtn:hover, .menubtn.is-open { background: var(--rail-hover); color: #fff; }

.viewbtn {
  padding: 3px 9px; font-size: 11.5px; font-weight: 500; border-radius: 5px;
  color: #94a3b8; transition: background .12s, color .12s;
}
.viewbtn:hover { background: #2a3242; color: #e2e8f0; }
.viewbtn.is-active { background: #2f6fd0; color: #fff; }

.topselect {
  height: 28px; border-radius: 6px; background: #141821; border: 1px solid #2a3242;
  color: #cbd5e1; font-size: 12px; padding: 0 8px; outline: none;
}
.topselect:focus { border-color: #1f7ae0; }

/* ---------- dropdown menu ---------- */
.menu-pop {
  position: absolute; top: 100%; left: 0; margin-top: 4px; min-width: 232px;
  background: #141821; border: 1px solid #2a3242; border-radius: 8px;
  box-shadow: 0 16px 44px -12px rgba(0,0,0,.75); padding: 5px; z-index: 60;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 9px; border-radius: 5px; font-size: 12.5px; color: #cbd5e1; text-align: left;
}
.menu-item:hover { background: #1f7ae0; color: #fff; }
.menu-item .kbd { margin-left: auto; font-size: 10.5px; color: #64748b; font-family: ui-monospace, monospace; }
.menu-item:hover .kbd { color: #cfe3ff; }
.menu-sep { height: 1px; margin: 5px 6px; background: #2a3242; }

/* ---------- tool rail ---------- */
.toolbtn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 36px; border-radius: 8px; color: #94a3b8;
  transition: background .12s, color .12s;
}
.toolbtn:hover { background: var(--rail-hover); color: #e2e8f0; }
.toolbtn.is-active { background: #1f7ae0; color: #fff; box-shadow: 0 3px 10px -3px rgba(31,122,224,.9); }
.toolbtn .badge {
  position: absolute; right: 3px; bottom: 2px; font-size: 8.5px; font-weight: 700;
  color: #64748b; font-family: ui-monospace, monospace;
}
.toolbtn.is-active .badge { color: #cfe3ff; }
.rail-sep { width: 26px; height: 1px; background: #2a3242; margin: 5px 0; }

/* tooltip */
.tip {
  position: fixed; z-index: 120; pointer-events: none; white-space: nowrap;
  background: #0b0d12; border: 1px solid #2a3242; color: #e2e8f0;
  font-size: 11.5px; padding: 5px 9px; border-radius: 6px;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.8); opacity: 0; transition: opacity .1s;
}
.tip .k { color: #64748b; margin-left: 6px; font-family: ui-monospace, monospace; }

/* ---------- viewport nav ---------- */
.navbtn {
  display: flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 7px; color: #94a3b8; background: rgba(20,24,33,.85);
  border: 1px solid rgba(42,50,66,.9); backdrop-filter: blur(6px); transition: all .12s;
}
.navbtn:hover { color: #fff; background: rgba(31,122,224,.9); border-color: transparent; }
.navbtn.is-active { color:#fff; background: rgba(31,122,224,.95); border-color: transparent; }

/* ---------- tool options bar ---------- */
#toolOptions:empty { display: none; }
.opt-label { color: #94a3b8; font-size: 11.5px; }
.opt-input {
  height: 24px; width: 62px; border-radius: 5px; background: #0b0d12; border: 1px solid #2a3242;
  color: #e2e8f0; font-size: 11.5px; padding: 0 6px; outline: none; font-family: ui-monospace, monospace;
}
.opt-input:focus { border-color: #1f7ae0; }
.opt-chip {
  height: 24px; padding: 0 9px; border-radius: 5px; background: #0b0d12; border: 1px solid #2a3242;
  color: #94a3b8; font-size: 11.5px; display: inline-flex; align-items: center; gap: 5px;
}
.opt-chip:hover { color: #e2e8f0; border-color: #3a4459; }
.opt-chip.is-on { background: #1f7ae0; border-color: #1f7ae0; color: #fff; }

/* ---------- panels ---------- */
.paneltab {
  flex: 1; padding: 8px 4px; font-size: 11.5px; font-weight: 500; color: #64748b;
  border-bottom: 2px solid transparent; transition: color .12s, border-color .12s;
}
.paneltab:hover { color: #cbd5e1; }
.paneltab.is-active { color: #fff; border-color: var(--accent); }

.sec-title {
  display: flex; align-items: center; gap: 6px; padding: 9px 12px 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #64748b;
}
.row { display: flex; align-items: center; gap: 8px; padding: 4px 12px; font-size: 12px; }
.row-label { width: 84px; flex-shrink: 0; color: #94a3b8; }
.field {
  flex: 1; min-width: 0; height: 26px; border-radius: 5px; background: #0b0d12;
  border: 1px solid #2a3242; color: #e2e8f0; font-size: 12px; padding: 0 7px; outline: none;
}
.field:focus { border-color: #1f7ae0; }
.field[readonly] { color: #94a3b8; }
textarea.field { height: auto; padding: 6px 7px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 11px; border-radius: 6px; font-size: 12px; font-weight: 500;
  background: #212836; color: #cbd5e1; border: 1px solid #2a3242; transition: all .12s;
}
.btn:hover { background: #2a3242; color: #fff; }
.btn-primary { background: #1f7ae0; border-color: #1f7ae0; color: #fff; }
.btn-primary:hover { background: #2f8bf5; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* swatch grid */
.swatch {
  position: relative; aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(255,255,255,.09);
  overflow: hidden; transition: transform .1s, box-shadow .1s;
}
.swatch:hover { transform: translateY(-1px); box-shadow: 0 6px 14px -6px rgba(0,0,0,.9); }
.swatch.is-active { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch .nm {
  position: absolute; inset-inline: 0; bottom: 0; padding: 2px 3px; font-size: 8.5px;
  color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.8)); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* outliner */
.tree-item {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px;
  font-size: 12px; color: #cbd5e1; border-radius: 5px; margin: 1px 6px;
}
.tree-item:hover { background: #1a1f2b; }
.tree-item.is-selected { background: #1f7ae0; color: #fff; }
.tree-item .ico { flex-shrink: 0; opacity: .65; }
.tree-item.is-selected .ico { opacity: 1; }
.tree-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .act { opacity: 0; flex-shrink: 0; padding: 2px; border-radius: 4px; }
.tree-item:hover .act { opacity: .6; }
.tree-item .act:hover { opacity: 1; background: rgba(255,255,255,.12); }
.tree-item .act.is-on { opacity: 1; }
.tree-item.is-hidden .nm { opacity: .45; font-style: italic; }

/* range */
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 3px; background: #2a3242; outline: none; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: #cbd5e1; cursor: pointer; border: 2px solid #0f1218; box-shadow: 0 0 0 1px #3a4459;
}
input[type=range]::-webkit-slider-thumb:hover { background: var(--accent); }

input[type=color] {
  -webkit-appearance: none; appearance: none; border: 1px solid #2a3242; border-radius: 5px;
  background: transparent; padding: 0; width: 34px; height: 26px; cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 3px; }

input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

/* modal */
.modal-card {
  width: 100%; max-width: 520px; background: #0f1218; border: 1px solid #2a3242;
  border-radius: 12px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.9); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid #1a1f2b; }
.modal-body { padding: 14px 16px; max-height: 62vh; overflow-y: auto; font-size: 12.5px; line-height: 1.65; color: #cbd5e1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 11px 16px; border-top: 1px solid #1a1f2b; background: #0b0d12; }

kbd {
  display: inline-block; padding: 1px 5px; border-radius: 4px; background: #1a1f2b;
  border: 1px solid #2a3242; border-bottom-width: 2px; font-family: ui-monospace, monospace;
  font-size: 10.5px; color: #cbd5e1; min-width: 18px; text-align: center;
}

/* misc */
.hidden-imp { display: none !important; }
#vcb.is-armed { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,149,255,.2); }
#toast.show { opacity: 1; }

@keyframes pulseRing { 0%{transform:scale(.9);opacity:.9} 100%{transform:scale(1.5);opacity:0} }
