/* ---------- Atelier 3D ---------- */
body.editor { overflow: hidden; }

.app {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* Top bar */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.logo__tag {
  font-family: var(--font-body); font-size: .72rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  padding: .15rem .5rem; border-radius: 999px; margin-left: .2rem;
}
.project-name {
  font: 600 .95rem var(--font-body); color: var(--ink);
  border: 1px solid transparent; border-radius: 10px; background: transparent;
  padding: .45rem .7rem; width: 180px; min-width: 0;
}
.project-name:hover { border-color: var(--line); }
.project-name:focus { outline: none; border-color: var(--accent); background: var(--bg); }

.branch-pick { display: flex; align-items: center; gap: .3rem; min-width: 0; }
.branch-pick select {
  font: 600 .85rem var(--font-body); color: var(--ink); height: 36px; max-width: 210px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 0 .5rem;
}
.mat-desc { font-size: .8rem; color: var(--muted); margin-top: .5rem; line-height: 1.4; }
.prop-section .avail { margin-top: .6rem; }
.scene-list .obj small { margin-left: auto; font-size: .7rem; font-weight: 700; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: .6rem; margin-left: auto; min-width: 0; }
.tool-group { display: flex; gap: .3rem; padding-left: .6rem; border-left: 1px solid var(--line); }
.tool-group:first-child { border-left: 0; padding-left: 0; }
.tool {
  height: 36px; padding: 0 .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 500; font-size: .88rem; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.tool:hover { border-color: var(--ink); }
.tool.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tool:disabled { opacity: .35; cursor: not-allowed; border-color: var(--line); }
.btn--small { padding: .55rem 1rem; font-size: .88rem; white-space: nowrap; }

/* Panels */
.panel {
  overflow-y: auto; padding: 1.1rem;
  background: var(--bg);
}
.panel--left { border-right: 1px solid var(--line); }
.panel--right { border-left: 1px solid var(--line); }
.panel h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 1.4rem 0 .7rem; font-weight: 600;
}
.panel h2:first-child { margin-top: 0; }
.hint { font-size: .83rem; color: var(--muted); margin: -.3rem 0 .7rem; line-height: 1.4; }

.lib { display: grid; gap: .45rem; }
.lib--grid { grid-template-columns: 1fr 1fr; }
.lib-item {
  display: flex; align-items: center; gap: .65rem; text-align: left;
  padding: .5rem; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 500; font-size: .88rem; line-height: 1.25;
  transition: border-color .15s, transform .15s;
}
.lib-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.lib-item__icon {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-size: 1.3rem; background: var(--bg-alt);
}
.lib-item small { display: block; color: var(--muted); font-weight: 400; font-size: .76rem; }
.lib--grid .lib-item { flex-direction: column; text-align: center; gap: .35rem; padding: .7rem .4rem; }

.keys { list-style: none; display: grid; gap: .45rem; font-size: .8rem; color: var(--muted); }
kbd {
  font: 600 .72rem var(--font-body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: .05rem .35rem; margin-right: .15rem;
}

/* Viewport */
.viewport { position: relative; overflow: hidden; background: #f2efe8; }
.viewport canvas { position: absolute; inset: 0; display: block; touch-action: none; outline: none; }
.empty {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  text-align: center; background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.75rem; width: min(320px, calc(100% - 32px));
  pointer-events: none; box-shadow: var(--shadow);
}
.empty span { font-size: 2.4rem; display: block; }
.empty p { font-size: .9rem; color: var(--muted); margin-top: .3rem; }
.empty[hidden] { display: none; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 600; color: var(--muted); background: #f2efe8;
}
.loading[hidden] { display: none; }

.stats {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: .4rem; pointer-events: none;
}
.stat {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: 10px;
  padding: .35rem .7rem; font-size: .8rem; color: var(--muted);
  backdrop-filter: blur(6px);
}
.stat b { color: var(--ink); font-weight: 600; }
.stat--price b { color: var(--accent); }
.stat--warn { background: #fff1e6; border-color: #ffb48f; color: #b13a00; font-weight: 600; }

/* Properties */
.props-empty { text-align: center; color: var(--muted); font-size: .9rem; padding: 1.5rem .5rem; }
.props-empty span { font-size: 2rem; display: block; margin-bottom: .4rem; }
.prop-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.prop-head .lib-item__icon { background: var(--accent-soft); }
.prop-head h3 { font-size: 1.05rem; }
.prop-section { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.prop-section h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .6rem; }

.field { display: grid; gap: .3rem; margin-bottom: .7rem; font-size: .85rem; font-weight: 500; }
.field:last-child { margin-bottom: 0; }
.field__top { display: flex; justify-content: space-between; }
.field output { color: var(--accent); font-weight: 600; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field input[type="text"], .field select, .xyz input {
  font: inherit; width: 100%; padding: .5rem .65rem;
  border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink);
}
.field input[type="text"]:focus, .field select:focus, .xyz input:focus { outline: none; border-color: var(--accent); }

.xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.xyz label { display: grid; gap: .2rem; font-size: .72rem; font-weight: 600; color: var(--muted); }
.xyz input { padding: .4rem .45rem; font-size: .85rem; -moz-appearance: textfield; }
.xyz input::-webkit-inner-spin-button { opacity: .5; }

.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatches .swatch { width: 28px; height: 28px; }

.prop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding-top: .9rem; }
.prop-actions .tool { justify-content: center; }
.tool--danger { color: #c62f00; }
.tool--danger:hover { border-color: #c62f00; }
.prop-actions .tool:first-child { grid-column: 1 / -1; }

.scene-list { display: grid; gap: .3rem; }
.scene-list .obj {
  display: flex; align-items: center; gap: .5rem; text-align: left;
  padding: .45rem .6rem; border-radius: 9px; font-size: .85rem; border: 1px solid transparent;
}
.scene-list .obj:hover { background: var(--surface); border-color: var(--line); }
.scene-list .obj.is-active { background: var(--surface); border-color: var(--accent); }
.scene-list .obj i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px var(--line); flex: none; }
.scene-list p { font-size: .83rem; color: var(--muted); }

.export-note {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5;
  width: min(460px, calc(100% - 24px)); display: grid; gap: .45rem; text-align: center;
  background: #e8f6ee; border: 1px solid #b6e2c8; border-radius: 14px; padding: .9rem 1rem;
  box-shadow: var(--shadow); font-size: .9rem;
}
.export-note span:last-child { display: flex; justify-content: center; gap: .4rem; flex-wrap: wrap; }

.toast a { color: var(--accent); font-weight: 600; margin-left: .4rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 220px minmax(0, 1fr) 270px; }
  .tool span { display: none; }
}
@media (max-width: 900px) {
  body.editor { overflow: auto; }
  .app { display: flex; flex-direction: column; height: auto; }
  .topbar { flex-wrap: wrap; gap: .5rem; position: sticky; top: 0; z-index: 10; }
  .project-name { flex: 1; width: auto; }
  .toolbar { width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 2px; }
  .viewport { height: 62vh; height: 62svh; flex: none; }
  .panel { overflow: visible; border: 0; border-top: 1px solid var(--line); }
  .panel--right { order: 3; }
  .panel--left { order: 4; }
  .lib--grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}
