:root {
  --bg: #0c0e0b;
  --panel: rgba(18, 21, 17, 0.88);
  --line: rgba(198, 243, 107, 0.14);
  --text: #e9eee4;
  --muted: #8f9a87;
  --accent: #c6f36b;
  --pink: #ff6be0;
  --water: #3aa0ff;
  --crit: #ff5470;
  --r: 18px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

#scene, .label-layer { position: fixed; inset: 0; }
.label-layer { pointer-events: auto; cursor: grab; }
.label-layer:active { cursor: grabbing; }

.loader { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: var(--bg); z-index: 50; transition: opacity .8s; color: var(--muted); }
.loader .leaf { font-size: 42px; animation: bob 1.4s ease-in-out infinite; }
body.ready .loader { opacity: 0; pointer-events: none; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-6deg); } }

.panel { position: fixed; z-index: 10; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 20px 50px rgba(0,0,0,.45); }

/* Top bar */
.topbar { position: fixed; top: 16px; left: 16px; right: 16px; z-index: 12; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.logo { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(135deg, var(--accent), #5fae3a); color: #10200a; font-size: 20px; box-shadow: 0 0 24px rgba(198,243,107,.35); }
.brand h1 { font: 800 22px/1 Outfit, sans-serif; letter-spacing: -.02em; }
.brand p { color: var(--muted); font-size: 12px; }

.seg { display: flex; padding: 4px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.seg button { padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); transition: .2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #142009; }

.dash-btn { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: rgba(198, 243, 107, 0.15); border: 1px solid var(--accent); color: var(--accent); font-weight: 700; font-size: 13px; text-decoration: none; transition: all .2s; box-shadow: 0 4px 14px rgba(0,0,0,0.3); }
.dash-btn:hover { background: var(--accent); color: #142009; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(198, 243, 107, 0.4); }

/* Sidebar */
.sidebar { top: 88px; left: 16px; width: 250px; max-height: calc(100vh - 200px); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.model-info strong { display: block; font: 700 16px Outfit, sans-serif; }
.model-info span { color: var(--accent); font-size: 12px; font-weight: 600; }
.model-info p { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.list-title { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.comp-list { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-right: -6px; padding-right: 6px; }
.comp-btn { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border-radius: 10px; transition: .15s; }
.comp-btn span { font-weight: 600; font-size: 13px; }
.comp-btn small { color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.comp-btn:hover { background: rgba(198,243,107,.08); }
.comp-btn.active { background: rgba(198,243,107,.16); box-shadow: inset 2px 0 0 var(--accent); }
.comp-list::-webkit-scrollbar { width: 4px; }
.comp-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* Details */
.details { top: 88px; right: 16px; width: 340px; max-height: calc(100vh - 120px); overflow-y: auto; padding: 22px; transform: translateX(calc(100% + 24px)); opacity: 0; transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s; }
.details.open { transform: none; opacity: 1; }
.details .close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); }
.details .close:hover { background: rgba(255,255,255,.06); color: var(--text); }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.details h2 { font: 700 24px/1.15 Outfit, sans-serif; margin: 6px 0 4px; padding-right: 30px; }
.details .sub { color: var(--muted); font-size: 12.5px; }
.desc { color: #c6cfbf; margin: 12px 0 16px; font-size: 13.5px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(198,243,107,.1); color: var(--accent); border: 1px solid var(--line); }
.specs { display: grid; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.specs div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; background: #141812; }
.specs dt { color: var(--muted); font-size: 12px; }
.specs dd { font-weight: 600; font-size: 12.5px; text-align: right; }
.telemetry { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.telemetry div { padding: 10px; border-radius: 12px; background: #141812; border: 1px solid var(--line); }
.telemetry span { display: block; font-size: 11px; color: var(--muted); }
.telemetry strong { font-size: 13px; }
.crit { color: var(--crit) !important; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { padding: 10px 16px; border-radius: 12px; background: var(--accent); color: #142009; font-weight: 700; font-size: 13px; transition: transform .15s, box-shadow .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(198,243,107,.3); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); box-shadow: none; }

/* HUD */
.hud { left: 16px; bottom: 16px; display: flex; gap: 2px; padding: 6px; border-radius: 14px; }
.hud div { padding: 6px 14px; text-align: center; }
.hud span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.hud strong { font: 700 16px Outfit, sans-serif; }
#hud-water { color: var(--water); }

/* Toolbar */
.toolbar { bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; border-radius: 16px; }
.toolbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 14px; border-radius: 12px; font-size: 18px; transition: .2s; opacity: .6; }
.toolbar button span { font-size: 11px; font-weight: 600; }
.toolbar button:hover { opacity: 1; background: rgba(255,255,255,.05); }
.toolbar button[aria-pressed="true"] { opacity: 1; background: rgba(198,243,107,.15); color: var(--accent); }

.tagline { position: fixed; right: 20px; bottom: 22px; z-index: 5; color: var(--muted); font: 500 13px Outfit, sans-serif; letter-spacing: .04em; }

.tooltip { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: #0f130d; border: 1px solid var(--accent); color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap; }
.dim-label { padding: 2px 8px; border-radius: 6px; background: var(--accent); color: #142009; font: 700 11px Inter, sans-serif; pointer-events: none; }

.toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 10px 16px; border-radius: 12px; background: #0f130d; border: 1px solid var(--line); font-weight: 600; font-size: 13px; animation: in .35s ease; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes in { from { opacity: 0; transform: translateY(-8px); } }

.mobile-only { display: none !important; }

@media (max-width: 900px) {
  :root { --tb: 52px; --safe: env(safe-area-inset-bottom, 0px); }
  .mobile-only { display: flex !important; }
  .tagline { display: none; }

  /* Topbar: Layout limpo de 1 linha no mobile */
  .topbar { top: 10px; left: 10px; right: 10px; gap: 8px; flex-wrap: nowrap; }
  .brand { margin-right: 0; gap: 8px; flex-shrink: 0; }
  .brand p { display: none; }
  .brand h1 { display: none; }
  .logo { width: 38px; height: 38px; font-size: 16px; border-radius: 11px; }

  .seg { padding: 3px; }
  .seg button { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
  .seg[aria-label="Modelo"] { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .seg[aria-label="Modelo"] button { flex: 1; }
  .seg[aria-label="Módulo de uso"] button span { display: none; }
  .seg[aria-label="Módulo de uso"] button { padding: 7px 9px; font-size: 15px; }

  /* Botão Dashboard OS: Fixo centralizado 40px acima do rodapé no mobile */
  .dash-btn {
    position: fixed;
    bottom: calc(var(--tb) + 40px + var(--safe));
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    background: var(--accent);
    color: #142009;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 18px rgba(198, 243, 107, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin: 0;
    white-space: nowrap;
    transition: transform .2s, opacity .3s;
  }
  .dash-btn .label { display: inline; }
  .details.open ~ .dash-btn, body.parts-open .dash-btn { opacity: 0; pointer-events: none; }

  /* HUD: faixa fina abaixo do topo */
  .hud { top: 58px; bottom: auto; left: 10px; right: 10px; transform: none; justify-content: space-between; padding: 4px; border-radius: 12px; }
  .hud div { flex: 1; padding: 3px 4px; }
  .hud span { font-size: 9px; }
  .hud strong { font-size: 13px; }

  /* Toolbar: barra inferior fixa, largura total */
  .toolbar { left: 0; right: 0; bottom: 0; transform: none; border-radius: 18px 18px 0 0; border-bottom: 0; justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + var(--safe)); }
  .toolbar button { flex: 1; padding: 6px 2px; font-size: 18px; min-width: 0; }
  .toolbar button span { font-size: 10px; white-space: nowrap; }

  /* Bottom sheets (detalhes e peças) */
  .details, .sidebar {
    left: 8px; right: 8px; width: auto; top: auto;
    bottom: calc(var(--tb) + var(--safe) + 8px);
    max-height: 52vh; border-radius: 18px;
    transform: translateY(calc(100% + 120px)); opacity: 0;
    transition: transform .4s cubic-bezier(.2,.8,.2,1), opacity .3s;
  }
  .details { padding: 18px; }
  .details h2 { font-size: 20px; }
  .desc { font-size: 13px; margin: 8px 0 12px; }
  .details.open, body.parts-open .sidebar { transform: none; opacity: 1; }
  .sidebar { display: flex; padding: 14px; }
  .sidebar .model-info p { display: none; }
  body.parts-open .details { transform: translateY(calc(100% + 120px)); opacity: 0; }
  .toasts { top: 112px; width: calc(100% - 20px); }
  .toast { text-align: center; font-size: 12px; }
}
@media (max-width: 380px) {
  .seg button { padding: 6px 7px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
