* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #000; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #fff; }
#app { position: fixed; inset: 0; touch-action: none; }
#app canvas { display: block; width: 100%; height: 100%; }

#ui {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.panel {
  display: flex; gap: 8px; padding: 8px;
  background: rgba(20,20,20,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events: auto; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 24px);
}
.btn {
  cursor: pointer; padding: 10px 14px; font-size: 14px; font-weight: 500;
  color: #fff; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 10px;
  user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: rgba(255,255,255,0.16); }
.btn:active { transform: scale(.97); }
.btn.primary { background: #2563eb; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }

.hint { margin: 0; font-size: 12px; opacity: .6; text-align: center; pointer-events: none; }

#loading {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  padding: 12px 20px; background: rgba(0,0,0,.7); border-radius: 10px; font-size: 14px; z-index: 20;
}
body.light #loading { background: rgba(255,255,255,.85); color: #111; }

/* AUTH */
[hidden] { display: none !important; }
.auth-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1a1a1a, #000 70%);
  padding: 16px;
}
.auth-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
  padding: 24px; border-radius: 16px;
  background: rgba(20,20,20,.85);
  border: 1px solid rgba(255,255,255,.12);
}
.auth-card h1 { margin: 0; font-size: 24px; font-weight: 600; }
.muted { margin: 0 0 8px; color: rgba(255,255,255,.6); font-size: 14px; }
.auth-card input {
  padding: 12px; border-radius: 10px; font-size: 15px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15);
  color: #fff;
}
.auth-card input:focus { outline: none; border-color: #2563eb; }
.link {
  background: none; border: none; color: #93c5fd; cursor: pointer;
  font-size: 13px; padding: 4px;
}
.link.small { font-size: 12px; margin-left: 8px; }
.error { color: #fca5a5; font-size: 13px; margin: 0; }
.msg { font-size: 13px; margin: 0; }
.msg.ok { color: #86efac; }
.msg.err { color: #fca5a5; }

/* SIDEBAR */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 320px; z-index: 30;
  background: rgba(15,15,15,.92);
  border-right: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column;
  padding: 16px; gap: 12px;
  overflow-y: auto;
}
.sidebar[hidden] { display: none; }
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header strong { font-size: 13px; word-break: break-all; }
.icon-btn {
  background: none; border: none; color: #fff; font-size: 22px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }

.upload { display: flex; flex-direction: column; gap: 8px; }
.upload input[type="text"], .upload textarea, .upload select {
  padding: 10px; border-radius: 8px; font-size: 14px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15);
  color: #fff; font-family: inherit;
}
.upload input[type="text"]:focus, .upload textarea:focus, .upload select:focus {
  outline: none; border-color: #2563eb;
}
.file-drop {
  display: flex; align-items: center; justify-content: center;
  padding: 16px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.04);
  border: 1px dashed rgba(255,255,255,.25);
  font-size: 13px; color: rgba(255,255,255,.8);
  text-align: center;
}
.file-drop input { display: none; }
.file-drop:hover { background: rgba(255,255,255,.08); }

.section-title { margin: 8px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.5); }

.product-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.product-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px; border-radius: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer; transition: background .15s ease;
}
.product-item:hover { background: rgba(255,255,255,.1); }
.product-item.active { border-color: #2563eb; background: rgba(37,99,235,.15); }
.product-item .name { font-size: 14px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-item .del {
  background: none; border: none; color: rgba(255,255,255,.5);
  font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.product-item .del:hover { color: #fca5a5; background: rgba(255,255,255,.06); }
.empty { color: rgba(255,255,255,.4); font-size: 13px; padding: 8px; text-align: center; }

@media (max-width: 600px) {
  .sidebar { width: 100%; max-width: 320px; }
  .btn { padding: 9px 11px; font-size: 13px; }
  .hint { font-size: 11px; }
}
