@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==================== Design tokens ==================== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;

  --gradient-main: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-subtle: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);

  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.6;
  text-align: left;
}

button, input, select { font-family: inherit; }

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
}
.btn-sm { padding: 6px 12px; font-size: 0.76rem; border-radius: var(--radius-sm); }
.btn-full, .full { width: 100%; }
.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.btn-danger { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.btn-danger:hover { background: rgba(244, 63, 94, 0.25); }

kbd {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ==================== App shell ==================== */
#app { position: relative; width: 100vw; height: 100vh; display: flex; flex-direction: column; }

/* ---- Header ---- */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
  gap: 10px;
  flex-wrap: wrap;
}
#app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; min-width: 0; }
#app-header .brand-icon { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--gradient-main); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
#app-header .header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#project-name-input {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.8rem;
  width: 190px;
  font-weight: 500;
}

/* ---- Main layout ---- */
#main-area { position: relative; flex: 1; display: flex; overflow: hidden; }

/* ---- Toolbar ---- */
#toolbar {
  width: 74px;
  flex-shrink: 0;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  z-index: 10;
}
.tool-group { display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border-subtle); padding-bottom: 10px; }
.tool-group:last-child { border-bottom: none; }
.tool-group-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); text-align: center; margin-bottom: 2px; }
.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 7px 4px;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.1;
}
.tool-btn span { font-size: 0.58rem; color: var(--text-tertiary); }
.tool-btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.tool-btn.active { background: var(--gradient-main); color: white; box-shadow: 0 2px 10px rgba(59,130,246,0.35); }
.tool-btn.active span { color: rgba(255,255,255,0.85); }
.tool-btn.danger.active { background: var(--accent-rose); }
.tool-group-actions .tool-btn { font-size: 1.05rem; }

/* ---- Viewer ---- */
#viewer-container { position: relative; flex: 1; min-width: 0; }
#viewer-canvas-wrap { position: absolute; inset: 0; }
#viewer-canvas-wrap canvas { display: block; width: 100%; height: 100%; }

#camera-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(139, 92, 246, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  box-shadow: var(--shadow-lg);
}
#camera-banner.hidden { display: none; }

#draw-status {
  position: absolute;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 0.8rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
#draw-status.hidden { display: none; }

#hint-bar {
  position: absolute;
  bottom: 12px;
  right: 14px;
  z-index: 9;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  pointer-events: none;
  max-width: 60%;
  text-align: right;
}

/* ---- Info panel ---- */
#info-panel {
  position: absolute;
  bottom: 40px;
  left: 12px;
  z-index: 9;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.74rem;
  color: var(--text-secondary);
  min-width: 150px;
}
#info-panel.hidden { display: none; }
#info-panel .info-title { font-size: 0.66rem; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 5px; }
#info-panel .info-row { display: flex; justify-content: space-between; gap: 12px; }
#info-panel .info-row span:last-child { color: var(--text-primary); font-weight: 500; }

/* ---- Right panel (tabs) ---- */
#control-panel {
  width: 300px;
  flex-shrink: 0;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-subtle);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
#control-panel.hidden { display: none; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  padding: 7px 10px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.74rem;
  cursor: pointer;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); background: var(--bg-glass); }

.tab-content { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.tab-content > * { flex-shrink: 0; }

.section-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); }
.panel-section { display: flex; flex-direction: column; gap: 10px; }
.toggle-group { display: flex; gap: 6px; background: var(--bg-glass); border-radius: var(--radius-md); padding: 4px; }
.toggle-btn { flex: 1; border: none; background: transparent; color: var(--text-secondary); padding: 8px 6px; border-radius: var(--radius-sm); font-size: 0.74rem; cursor: pointer; }
.toggle-btn.active { background: var(--gradient-main); color: white; }
.select-input, .color-input {
  width: 100%;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.8rem;
}
input[type="number"] {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  font-size: 0.8rem;
  width: 100%;
}
.slider-row { display: flex; flex-direction: column; gap: 4px; }
.slider-row .slider-label { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--text-secondary); }
.slider-row input[type="range"] { width: 100%; accent-color: var(--accent-blue); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-secondary); }
.prop-note { font-size: 0.72rem; color: var(--text-tertiary); line-height: 1.5; }
.prop-note code { background: var(--bg-glass); padding: 1px 5px; border-radius: 4px; font-size: 0.7rem; }

/* ---- Outliner ---- */
.outliner-actions { display: flex; gap: 8px; }
.outliner-tree { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap;
}
.tree-item:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.tree-item.selected { background: var(--gradient-subtle); border-color: rgba(59,130,246,0.4); color: var(--text-primary); }
.tree-item .tree-arrow { width: 14px; flex-shrink: 0; display: inline-block; text-align: center; color: var(--text-tertiary); cursor: pointer; }
.tree-item .tree-arrow.empty { visibility: hidden; }
.tree-item .tree-icon { flex-shrink: 0; }
.tree-item .tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tree-item .tree-visible { opacity: 0.4; cursor: pointer; }
.tree-item .tree-visible.off { opacity: 0.2; }
.tree-children { margin-left: 16px; border-left: 1px solid var(--border-subtle); padding-left: 6px; display: flex; flex-direction: column; gap: 2px; }
.tree-children.collapsed { display: none; }

/* ---- Properties ---- */
.props-empty { font-size: 0.8rem; color: var(--text-tertiary); text-align: center; padding: 20px 0; }
.props-body { display: flex; flex-direction: column; gap: 8px; }
.prop-type { font-size: 0.7rem; color: var(--accent-blue); text-transform: uppercase; letter-spacing: 0.04em; }
.field-row { display: flex; flex-direction: column; gap: 4px; }
.field-row label { font-size: 0.7rem; color: var(--text-tertiary); }
.vec-row { display: flex; gap: 6px; }
.vec-row input[type="number"] { padding: 6px 6px; font-size: 0.74rem; }
.prop-params { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.prop-params .param-group-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; color: var(--text-tertiary); margin-top: 4px; }

/* ---- Materials ---- */
.material-presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.mat-swatch {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}
.mat-swatch:hover { transform: scale(1.1); border-color: var(--text-secondary); }
.mat-swatch.selected { border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.4); }

/* ---- Library ---- */
.library-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.library-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
  overflow: hidden;
}
.library-card:hover { background: var(--bg-glass-hover); border-color: var(--accent-blue); }
.library-card .lib-icon { font-size: 1.4rem; margin-bottom: 4px; }
.library-card .lib-name { font-size: 0.68rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-card .lib-meta { font-size: 0.6rem; color: var(--text-tertiary); }
.library-empty { font-size: 0.75rem; color: var(--text-tertiary); }

/* ---- Cameras ---- */
.camera-list { display: flex; flex-direction: column; gap: 6px; }
.camera-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 0.76rem;
}
.camera-item .cam-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-item .cam-actions { display: flex; gap: 6px; }

/* ---- Animation ---- */
#anim-object-select option, #anim-clip-select option { background: #111827; }

/* ---- Modal ---- */
#login-gate { position: fixed; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #17233d 0%, #0a0e1a 55%, #060910 100%); padding: 20px; }
.login-gate-card { width: 100%; max-width: 400px; background: var(--bg-secondary); border: 1px solid var(--border-medium); border-radius: var(--radius-lg); padding: 32px 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; }
.login-gate-brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.login-gate-title { font-size: 1.5rem; font-weight: 800; letter-spacing: 1px; background: var(--gradient-main); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.login-gate-sub { text-align: center; color: var(--text-secondary); font-size: 0.85rem; margin: -4px 0 8px; }
#login-gate input[type="email"], #login-gate input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  font-size: 0.92rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
#login-gate input[type="email"]:focus, #login-gate input[type="password"]:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(10, 14, 26, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
.modal-title { font-weight: 700; font-size: 0.95rem; }
.modal-close { background: transparent; border: none; color: var(--text-tertiary); font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.modal .drop-card { max-width: none; padding: 18px; margin: 0; }
#add-model-modal #drop-zone { position: static; background: none; overflow: visible; padding: 0; }

/* ---- Gallery (in modal) ---- */
#gallery-panel { width: 100%; padding: 0 18px 18px; }
#gallery-panel h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); margin-bottom: 10px; }
#gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 220px; overflow-y: auto; }
.gallery-card { position: relative; background: var(--bg-glass); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 14px 10px; cursor: pointer; text-align: center; transition: all var(--transition-fast); }
.gallery-card:hover { background: var(--bg-glass-hover); border-color: var(--border-medium); }
.gallery-card .g-icon { font-size: 1.6rem; margin-bottom: 6px; }
.gallery-card .g-name { font-size: 0.72rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-card .g-meta { font-size: 0.65rem; color: var(--text-tertiary); margin-top: 2px; }
.gallery-card .g-delete { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); font-size: 0.7rem; cursor: pointer; display: none; align-items: center; justify-content: center; }
.gallery-card:hover .g-delete { display: flex; }
.gallery-empty { font-size: 0.75rem; color: var(--text-tertiary); }

/* ---- Projects list ---- */
.projects-list { display: flex; flex-direction: column; gap: 6px; padding: 0 18px 18px; max-height: 55vh; overflow-y: auto; }
.project-item { display: flex; align-items: center; gap: 8px; background: var(--bg-glass); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 10px 12px; }
.project-item .pj-name { flex: 1; font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .pj-meta { font-size: 0.66rem; color: var(--text-tertiary); }
.project-item .pj-actions { display: flex; gap: 6px; }

/* ---- Drop zone ---- */
#drop-zone { display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
#drop-zone.hidden { display: none; }
.drop-card { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; margin: auto; }
.drop-target { width: 100%; padding: 40px 24px; border: 2px dashed var(--border-medium); border-radius: var(--radius-lg); background: var(--bg-glass); cursor: pointer; transition: all var(--transition-base); position: relative; }
.drop-target.dragging { border-color: var(--accent-blue); background: var(--gradient-subtle); }
.drop-target svg { color: var(--text-secondary); margin-bottom: 12px; }
.drop-primary { display: block; font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.drop-secondary { display: block; font-size: 0.8rem; color: var(--text-tertiary); }
.folder-btn { background: transparent; border: 1px dashed var(--border-medium); color: var(--text-secondary); border-radius: var(--radius-full); padding: 8px 16px; font-size: 0.78rem; cursor: pointer; }
.folder-btn:hover { background: var(--bg-glass); color: var(--text-primary); }
.format-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.format-badge { padding: 6px 10px; border-radius: var(--radius-sm); background: var(--bg-glass); border: 1px solid var(--border-subtle); font-size: 0.72rem; color: var(--text-tertiary); }
.format-badge strong { color: var(--accent-blue); }
.drop-error { font-size: 0.8rem; color: var(--accent-rose); background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.3); border-radius: var(--radius-sm); padding: 8px 12px; }
.drop-tip { font-size: 0.75rem; color: var(--text-tertiary); line-height: 1.5; }

/* ---- Loading / Toast ---- */
#loading-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 14, 26, 0.6); z-index: 60; }
#loading-overlay.hidden { display: none; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--border-subtle); border-top-color: var(--accent-blue); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 70; background: rgba(17, 24, 39, 0.95); border: 1px solid var(--border-medium); border-radius: var(--radius-md); padding: 10px 18px; font-size: 0.82rem; opacity: 0; pointer-events: none; transition: all var(--transition-base); max-width: 80vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: rgba(244, 63, 94, 0.4); color: #fda4af; }

.hidden { display: none !important; }

@media (max-width: 860px) {
  #control-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow-lg); width: 280px; }
  #toolbar { width: 60px; }
  .tool-btn span { display: none; }
  #hint-bar { display: none; }
}


/* ==================== Autenticación ==================== */
.auth-area { display: flex; gap: 8px; align-items: center; }
.auth-area.hidden { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--border-medium); border-radius: 999px; background: var(--bg-glass); }
.user-chip.hidden { display: none; }
.user-chip-name { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-sm { max-width: 400px; }
.auth-form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.auth-error { background: rgba(220, 38, 38, 0.12); border: 1px solid rgba(220, 38, 38, 0.4); color: #fca5a5; font-size: 0.8rem; padding: 8px 10px; border-radius: var(--radius-sm); word-break: break-word; }
.auth-error.hidden { display: none; }
.auth-ok { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.4); color: #6ee7b7; font-size: 0.8rem; padding: 8px 10px; border-radius: var(--radius-sm); word-break: break-word; }
.auth-ok.hidden { display: none; }
.auth-links { display: flex; flex-direction: column; gap: 6px; font-size: 0.78rem; }
.auth-links a { color: var(--accent-blue); text-decoration: none; cursor: pointer; }
.auth-links a:hover { text-decoration: underline; }
.auth-switch { font-size: 0.8rem; color: var(--text-secondary); text-align: center; }
.auth-switch a { color: var(--accent-blue); text-decoration: none; cursor: pointer; }
.auth-switch a:hover { text-decoration: underline; }
.auth-note { font-size: 0.72rem; color: var(--text-tertiary); line-height: 1.45; }
.auth-link-box { margin-top: 2px; background: var(--bg-glass); border: 1px dashed var(--border-medium); border-radius: var(--radius-sm); padding: 10px 12px; }
.auth-link-box a { color: var(--accent-blue); font-size: 0.76rem; word-break: break-all; }
.auth-link-box button { margin-top: 8px; }

/* ==================== Pintar texturas ==================== */
.texture-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.texture-pick-name { font-size: 0.9rem; font-weight: 700; }
.texture-face-row { display: flex; flex-wrap: wrap; gap: 6px; }
.face-chip {
  font-size: 0.7rem; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  background: var(--bg-glass); border: 1px solid var(--border-medium); color: var(--text-secondary);
  transition: var(--transition-fast);
}
.face-chip:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.face-chip.active { background: var(--gradient-main); color: #fff; border-color: transparent; }
.texture-current { font-size: 0.72rem; color: var(--text-tertiary); }
.face-chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.prop-face-label { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 6px; }
.prop-face-info { font-size: 0.72rem; color: var(--text-tertiary); margin: 6px 0; line-height: 1.45; }
.prop-face-info b { color: var(--text-primary); font-weight: 600; }
.texture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.texture-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px;
  background: var(--bg-glass); border: 1px solid var(--border-medium); border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition-fast);
}
.texture-card:hover { border-color: var(--accent-blue); background: var(--bg-glass-hover); transform: translateY(-2px); }
.texture-card img { width: 100%; height: 56px; object-fit: cover; border-radius: 4px; background: #1e293b; }
.texture-card .lib-name { font-size: 0.62rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; text-align: center; }
.mat-texture-grid { margin-top: 6px; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.texture-empty { font-size: 0.78rem; color: var(--text-tertiary); }
.texture-empty.hidden { display: none; }
.texture-modal-body code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 4px; font-size: 0.72rem; }

/* ---- Línea de tiempo (keyframes) ---- */
.kf-transport { display: flex; gap: 4px; margin-top: 8px; }
.kf-transport .btn { flex: 1; }
.kf-time-label { font-size: 0.72rem; color: var(--text-secondary); text-align: center; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kf-loop-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.kf-loop-row .slider-row { flex: 1; }
.kf-timeline { position: relative; background: var(--bg-glass); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); overflow: hidden; --kf-name-w: 86px; }
.kf-ruler { position: relative; height: 20px; border-bottom: 1px solid var(--border-subtle); display: flex; }
.kf-ruler-name { width: var(--kf-name-w); flex-shrink: 0; border-right: 1px solid var(--border-subtle); }
.kf-ruler-lane { position: relative; flex: 1; min-width: 0; }
.kf-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,0.08); }
.kf-tick.major { background: rgba(255,255,255,0.18); }
.kf-tick.major::after { content: attr(data-t); position: absolute; top: 1px; left: 2px; font-size: 0.55rem; color: var(--text-tertiary); }
.kf-tracks-area { position: relative; min-height: 30px; max-height: 140px; overflow-y: auto; }
.kf-empty { font-size: 0.72rem; color: var(--text-tertiary); padding: 8px 10px; }
.kf-track { display: flex; align-items: center; border-bottom: 1px solid var(--border-subtle); min-height: 24px; }
.kf-track-name { width: var(--kf-name-w); flex-shrink: 0; font-size: 0.66rem; color: var(--text-secondary); padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-right: 1px solid var(--border-subtle); align-self: stretch; display: flex; align-items: center; }
.kf-lane { position: relative; flex: 1; height: 24px; }
.kf-dot { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; border-radius: 2px; background: var(--accent-amber); border: 1px solid rgba(0,0,0,0.4); cursor: pointer; }
.kf-dot:hover { transform: translate(-50%, -50%) scale(1.3); }
.kf-dot.selected { background: var(--accent-emerald); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35); }
.kf-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent-rose); pointer-events: none; z-index: 3; box-shadow: 0 0 6px rgba(244, 63, 94, 0.6); }
.kf-object-row { display: flex; gap: 6px; margin-top: 8px; }
.kf-object-row .select-input { flex: 1; min-width: 0; }
.kf-vec { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.kf-vec-label { width: 74px; flex-shrink: 0; font-size: 0.68rem; color: var(--text-tertiary); }
.kf-vec input { flex: 1; min-width: 0; }
/* ---- Línea de tiempo inferior (estilo After Effects) ---- */
#timeline-bar {
  flex-shrink: 0;
  height: 148px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(11, 16, 27, 0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 15;
}
#timeline-bar.hidden { display: none; }
.tl-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tl-transport { display: flex; align-items: center; gap: 4px; }
.tl-transport .btn { padding: 5px 8px; }
.tl-transport .kf-time-label { margin: 0 2px 0 8px; min-width: 96px; text-align: left; font-size: 0.74rem; }
.tl-controls { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; justify-content: flex-end; flex-wrap: wrap; }
.tl-controls .select-input { width: 130px; font-size: 0.72rem; padding: 4px 6px; }
.tl-check { font-size: 0.72rem; white-space: nowrap; }
.tl-dur { display: flex; align-items: center; gap: 6px; }
.tl-dur-label { font-size: 0.68rem; color: var(--text-tertiary); }
.tl-dur input[type="range"] { width: 90px; }
.tl-dur-value { font-size: 0.72rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 34px; }
#timeline-bar .kf-timeline { flex: 1; border-radius: var(--radius-sm); --kf-name-w: 110px; }
#timeline-bar .kf-ruler { height: 22px; }
#timeline-bar .kf-tracks-area { min-height: 0; max-height: none; flex: 1; overflow-y: auto; }
#timeline-bar .kf-track { min-height: 26px; }
#timeline-bar .kf-track-name { width: 110px; }
#timeline-bar .kf-lane { height: 26px; cursor: crosshair; }
#timeline-bar .kf-empty { display: flex; align-items: center; justify-content: center; height: 100%; }
#timeline-bar .kf-dot { width: 12px; height: 12px; border-radius: 50%; cursor: grab; }
#timeline-bar .kf-dot:hover { transform: translate(-50%, -50%) scale(1.35); }
#timeline-bar .kf-dot.selected { background: var(--accent-emerald); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4); }
#timeline-bar .kf-dot.dragging { transform: translate(-50%, -50%) scale(1.5); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5); cursor: grabbing; }

/* Teclas estilizadas del hint-bar */
#hint-bar kbd {
  display: inline-block;
  min-width: 16px;
  padding: 2px 6px;
  font-size: 0.66rem;
  font-family: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--text-primary);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 5px;
  margin: 0 1px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  vertical-align: middle;
}

/* ---- Menú contextual (clic derecho) ---- */
#ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 170px;
  background: rgba(15, 22, 36, 0.97);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  font-size: 0.8rem;
  animation: ctxIn 0.12s ease;
}
@keyframes ctxIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
#ctx-menu .ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-size: 0.8rem;
}
#ctx-menu .ctx-item:hover { background: var(--bg-glass-hover); }
#ctx-menu .ctx-item .ctx-key { margin-left: auto; font-size: 0.62rem; color: var(--text-tertiary); }
#ctx-menu .ctx-sep { height: 1px; background: var(--border-subtle); margin: 4px 6px; }
#ctx-menu .ctx-title { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); padding: 4px 10px 2px; }

/* Responsive: línea de tiempo compacta */
@media (max-width: 820px) {
  #timeline-bar { height: 168px; padding: 6px 8px; }
  .tl-top { gap: 6px; }
  .tl-dur input[type="range"] { width: 60px; }
  .tl-controls .select-input { width: 100px; }
  .tl-check { font-size: 0.64rem; }
  #timeline-bar .kf-timeline { --kf-name-w: 74px; }
}
